mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 22:31:52 +00:00
Migrated from react-scripts and webpack to vite
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import csv from 'csvtojson';
|
||||
import { parse } from 'json2csv';
|
||||
// @ts-expect-error gfgf
|
||||
import { Parser } from '@json2csv/plainjs';
|
||||
|
||||
export const csvToJson = <T>(csvContent: string) => new Promise<T[]>((resolve) => {
|
||||
csv().fromString(csvContent).then(resolve);
|
||||
@@ -7,6 +8,8 @@ export const csvToJson = <T>(csvContent: string) => new Promise<T[]>((resolve) =
|
||||
|
||||
export type CsvToJson = typeof csvToJson;
|
||||
|
||||
export const jsonToCsv = <T>(data: T[]): string => parse(data);
|
||||
const jsonParser = new Parser(); // TODO This accepts options if needed
|
||||
|
||||
export const jsonToCsv = <T>(data: T[]): string => jsonParser.parse(data);
|
||||
|
||||
export type JsonToCsv = typeof jsonToCsv;
|
||||
|
||||
@@ -5,15 +5,15 @@ import { ColorGenerator } from './ColorGenerator';
|
||||
import { csvToJson, jsonToCsv } from '../helpers/csvjson';
|
||||
|
||||
const provideServices = (bottle: Bottle) => {
|
||||
bottle.constant('localStorage', (global as any).localStorage);
|
||||
bottle.constant('localStorage', window.localStorage);
|
||||
bottle.service('Storage', LocalStorage, 'localStorage');
|
||||
bottle.service('ColorGenerator', ColorGenerator, 'Storage');
|
||||
|
||||
bottle.constant('csvToJson', csvToJson);
|
||||
bottle.constant('jsonToCsv', jsonToCsv);
|
||||
|
||||
bottle.constant('setTimeout', global.setTimeout);
|
||||
bottle.constant('clearTimeout', global.clearTimeout);
|
||||
bottle.constant('setTimeout', window.setTimeout);
|
||||
bottle.constant('clearTimeout', window.clearTimeout);
|
||||
bottle.serviceFactory('useTimeoutToggle', useTimeoutToggle, 'setTimeout', 'clearTimeout');
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user