Procházet zdrojové kódy

import swr from node_modules & add with-utils at growi/core/src/utils

yohei0125 před 3 roky
rodič
revize
cceaa86ac3

+ 1 - 0
packages/core/src/index.js

@@ -20,3 +20,4 @@ export * from './service/localstorage-manager';
 export * from './utils/basic-interceptor';
 export * from './utils/basic-interceptor';
 export * from './utils/browser-utils';
 export * from './utils/browser-utils';
 export * from './utils/mongoose-utils';
 export * from './utils/mongoose-utils';
+export * from '../../../node_modules/swr';

+ 7 - 0
packages/core/src/utils/with-utils.ts

@@ -0,0 +1,7 @@
+import { SWRResponse } from '../index';
+
+export type SWRResponseWithUtils<R extends SWRResponse, Utils> = R & Utils;
+
+export const withUtils = <R extends SWRResponse, U>(response: R, utils: U): SWRResponseWithUtils<R, U> => {
+  return Object.assign(response, utils);
+};