deno.land / x / feathers@v5.0.0-pre.29 / _commons / mod.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// DO NOT MODIFY - generated from packages/commons/src/index.ts
// Removes all leading and trailing slashes from a pathexport function stripSlashes (name: string) { return name.replace(/^(\/+)|(\/+)$/g, '');}
export type KeyValueCallback<T> = (value: any, key: string) => T;
// A set of lodash-y utility functions that use ES6export const _ = { each (obj: any, callback: KeyValueCallback<void>) { if (obj && typeof obj.forEach === 'function') { obj.forEach(callback); } else if (_.isObject(obj)) { Object.keys(obj).forEach(key => callback(obj[key], key)); } },
some (value: any, callback: KeyValueCallback<boolean>) { return Object.keys(value) .map(key => [ value[key], key ]) .some(([val, key]) => callback(val, key)); },
every (value: any, callback: KeyValueCallback<boolean>) { return Object.keys(value) .map(key => [ value[key], key ]) .every(([val, key]) => callback(val, key)); },
keys (obj: any) { return Object.keys(obj); },
values (obj: any) { return _.keys(obj).map(key => obj[key]); },
isMatch (obj: any, item: any) { return _.keys(item).every(key => obj[key] === item[key]); },
isEmpty (obj: any) { return _.keys(obj).length === 0; },
isObject (item: any) { return (typeof item === 'object' && !Array.isArray(item) && item !== null); },
isObjectOrArray (value: any) { return typeof value === 'object' && value !== null; },
extend (first: any, ...rest: any[]) { return Object.assign(first, ...rest); },
omit (obj: any, ...keys: string[]) { const result = _.extend({}, obj); keys.forEach(key => delete result[key]); return result; },
pick (source: any, ...keys: string[]) { return keys.reduce((result: { [key: string]: any }, key) => { if (source[key] !== undefined) { result[key] = source[key]; }
return result; }, {}); },
// Recursively merge the source object into the target object merge (target: any, source: any) { if (_.isObject(target) && _.isObject(source)) { Object.keys(source).forEach(key => { if (_.isObject(source[key])) { if (!target[key]) { Object.assign(target, { [key]: {} }); }
_.merge(target[key], source[key]); } else { Object.assign(target, { [key]: source[key] }); } }); } return target; }};
// Duck-checks if an object looks like a promiseexport function isPromise (result: any) { return _.isObject(result) && typeof result.then === 'function';}
export function createSymbol (name: string) { return typeof Symbol !== 'undefined' ? Symbol(name) : name;}
export * from './debug.ts';
feathers

Version Info

Tagged at
a year ago

External Dependencies

No external dependencies 🎉