Update dependencies
This commit is contained in:
parent
8c49cabc35
commit
9b959ff57b
@ -72,7 +72,7 @@ export function typedEventEmitter<
|
||||
const NewClass = class extends Base {
|
||||
constructor(...args: any[]) {
|
||||
super(...args);
|
||||
EventEmitter.call(this);
|
||||
EventEmitter.call(this as any);
|
||||
}
|
||||
};
|
||||
Object.getOwnPropertyNames(EventEmitter.prototype).forEach(name => {
|
||||
|
@ -79,7 +79,7 @@ export function write(value: any) {
|
||||
} else {
|
||||
fn = console.log;
|
||||
}
|
||||
fn.apply(null, args);
|
||||
fn.apply(null, args as any);
|
||||
}
|
||||
|
||||
function filter(value: any) {
|
||||
|
@ -1,28 +1,29 @@
|
||||
import { ModelSchema, primitive, PropSchema } from "serializr";
|
||||
import * as s from "..";
|
||||
import {Context, custom, ModelSchema, primitive, PropSchema} from 'serializr';
|
||||
|
||||
import * as s from '..';
|
||||
|
||||
export const duration: PropSchema = primitive();
|
||||
|
||||
export const date: PropSchema = {
|
||||
serializer: (jsDate: Date | null) =>
|
||||
jsDate != null ? jsDate.toISOString() : null,
|
||||
deserializer: (json: any, done) => {
|
||||
if (json === null) {
|
||||
return done(null, null);
|
||||
}
|
||||
try {
|
||||
done(null, new Date(json));
|
||||
} catch (e) {
|
||||
done(e, undefined);
|
||||
}
|
||||
}
|
||||
};
|
||||
export const date: PropSchema = custom(
|
||||
(jsDate: Date|null) => jsDate != null ? jsDate.toISOString() : null,
|
||||
(json: any, context: Context, oldValue: any,
|
||||
done: (err: any, value: any) => void) => {
|
||||
if (json === null) {
|
||||
return done(null, null);
|
||||
}
|
||||
try {
|
||||
done(null, new Date(json));
|
||||
} catch (e) {
|
||||
done(e, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
export const dateOfYear: ModelSchema<s.DateOfYear> = {
|
||||
factory: () => new s.DateOfYear(),
|
||||
props: {
|
||||
year: primitive(),
|
||||
month: primitive(), // this only works if it is represented as a # from 0-12
|
||||
month:
|
||||
primitive(), // this only works if it is represented as a # from 0-12
|
||||
day: primitive()
|
||||
}
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { primitive, PropSchema } from "serializr";
|
||||
import {primitive, PropSchema} from 'serializr';
|
||||
|
||||
function invariant(cond: boolean, message?: string) {
|
||||
if (!cond) {
|
||||
throw new Error("[serializr] " + (message || "Illegal ServerState"));
|
||||
throw new Error('[serializr] ' + (message || 'Illegal ServerState'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,14 +11,11 @@ function isPropSchema(thing: any) {
|
||||
}
|
||||
|
||||
function isAliasedPropSchema(propSchema: any) {
|
||||
return typeof propSchema === "object" && !!propSchema.jsonname;
|
||||
return typeof propSchema === 'object' && !!propSchema.jsonname;
|
||||
}
|
||||
|
||||
function parallel(
|
||||
ar: any[],
|
||||
processor: (item: any, done: any) => void,
|
||||
cb: any
|
||||
) {
|
||||
ar: any[], processor: (item: any, done: any) => void, cb: any) {
|
||||
if (ar.length === 0) {
|
||||
return void cb(null, []);
|
||||
}
|
||||
@ -43,17 +40,15 @@ function parallel(
|
||||
|
||||
export default function list(propSchema: PropSchema): PropSchema {
|
||||
propSchema = propSchema || primitive();
|
||||
invariant(isPropSchema(propSchema), "expected prop schema as first argument");
|
||||
invariant(isPropSchema(propSchema), 'expected prop schema as first argument');
|
||||
invariant(
|
||||
!isAliasedPropSchema(propSchema),
|
||||
"provided prop is aliased, please put aliases first"
|
||||
);
|
||||
!isAliasedPropSchema(propSchema),
|
||||
'provided prop is aliased, please put aliases first');
|
||||
return {
|
||||
serializer(ar) {
|
||||
invariant(
|
||||
ar && typeof ar.length === "number" && typeof ar.map === "function",
|
||||
"expected array (like) object"
|
||||
);
|
||||
ar && typeof ar.length === 'number' && typeof ar.map === 'function',
|
||||
'expected array (like) object');
|
||||
return ar.map(propSchema.serializer);
|
||||
},
|
||||
deserializer(jsonArray, done, context) {
|
||||
@ -62,14 +57,15 @@ export default function list(propSchema: PropSchema): PropSchema {
|
||||
return void done(null, []);
|
||||
}
|
||||
if (!Array.isArray(jsonArray)) {
|
||||
return void done("[serializr] expected JSON array", null);
|
||||
return void done('[serializr] expected JSON array', null);
|
||||
}
|
||||
parallel(
|
||||
jsonArray,
|
||||
(item: any, itemDone: (err: any, targetPropertyValue: any) => void) =>
|
||||
propSchema.deserializer(item, itemDone, context, undefined),
|
||||
done
|
||||
);
|
||||
}
|
||||
jsonArray,
|
||||
(item: any, itemDone: (err: any, targetPropertyValue: any) => void) =>
|
||||
propSchema.deserializer(item, itemDone, context, undefined),
|
||||
done);
|
||||
},
|
||||
beforeDeserialize: () => {},
|
||||
afterDeserialize: () => {},
|
||||
};
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ export const updateProgram: ModelSchema<
|
||||
serializer: data => data,
|
||||
deserializer: (json, done) => {
|
||||
done(null, json);
|
||||
}
|
||||
},
|
||||
beforeDeserialize: () => {},
|
||||
afterDeserialize: () => {},
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -148,11 +148,5 @@
|
||||
"webpack-cli": "^3.1.0",
|
||||
"webpack-dashboard": "^2.0.0",
|
||||
"webpack-dev-server": "^3.1.7"
|
||||
},
|
||||
"resolutions": {
|
||||
"**/@types/react": "16.7.13",
|
||||
"**/@types/react-dom": "16.0.11",
|
||||
"**/react": "16.6.3",
|
||||
"**/react-dom": "16.6.3"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user