@meteor-it/utils
Advanced tools
Comparing version 1.3.27 to 1.3.29
@@ -16,3 +16,2 @@ /// <reference types="node" /> | ||
/** | ||
* @deprecated Extremally slow on Proxy/getters | ||
* @param x | ||
@@ -78,9 +77,3 @@ * @param y | ||
*/ | ||
export declare function asyncEach<T, R>(iterable: T[], cb: (v: T) => Promise<R>): R[]; | ||
/** | ||
* Convert callback function to async | ||
* @deprecated Existst in node utils | ||
* @param cbFunction Function to convert | ||
*/ | ||
export declare function cb2promise(cbFunction: any): (...d: any[]) => Promise<any>; | ||
export declare function asyncEach<T, R>(iterable: T[], cb: (v: T) => Promise<R>): Promise<R[]>; | ||
export declare function hashCode(s: string): number; | ||
@@ -109,6 +102,23 @@ export declare function djb2Code(str: string): number; | ||
*/ | ||
export declare function isNodeEnvironment(): any; | ||
export declare function isNodeEnvironment(): boolean; | ||
/** | ||
* Check if running in browser | ||
*/ | ||
export declare function isBrowserEnvironment(): any; | ||
export declare function isBrowserEnvironment(): boolean; | ||
export declare function collectCallbacks<T>(cbProvider: (collector: (t: T) => void) => Promise<void>): Promise<T[]>; | ||
export declare function repeatBeforeSucceed<V>(fn: () => Promise<V>, maxRepeats: number, repeatIn: number, timeMultiplier?: number, maxTime?: number): Promise<V>; | ||
export interface Listener<T> { | ||
(event: T): any; | ||
} | ||
export interface Disposable { | ||
dispose(): void; | ||
} | ||
export declare class TypedEvent<T> { | ||
private listeners; | ||
private listenersOncer; | ||
on(listener: Listener<T>): Disposable; | ||
once(listener: Listener<T>): void; | ||
off(listener: Listener<T>): void; | ||
emit(event: T): void; | ||
pipe(te: TypedEvent<T>): Disposable; | ||
} |
98
index.js
@@ -50,3 +50,2 @@ "use strict"; | ||
/** | ||
* @deprecated Extremally slow on Proxy/getters | ||
* @param x | ||
@@ -66,3 +65,3 @@ * @param y | ||
if (x instanceof RegExp) { | ||
return x === y; | ||
return x.source === y.source && x.source === y.source; | ||
} | ||
@@ -72,2 +71,18 @@ if (x === y || x.valueOf() === y.valueOf()) { | ||
} | ||
if (x instanceof Map) { | ||
if (x.size !== y.size) | ||
return false; | ||
if (!objectEquals([...x.keys()].sort(), [...y.keys()].sort())) | ||
return false; | ||
if (!objectEquals([...x.values()].sort(), [...y.values()].sort())) | ||
return false; | ||
return true; | ||
} | ||
if (x instanceof Set) { | ||
if (x.size !== y.size) | ||
return false; | ||
if (!objectEquals([...x.values()].sort(), [...y.values()].sort())) | ||
return false; | ||
return true; | ||
} | ||
if (Array.isArray(x) && x.length !== y.length) { | ||
@@ -210,20 +225,2 @@ return false; | ||
// noinspection JSUnusedGlobalSymbols | ||
/** | ||
* Convert callback function to async | ||
* @deprecated Existst in node utils | ||
* @param cbFunction Function to convert | ||
*/ | ||
function cb2promise(cbFunction) { | ||
return (...args) => { | ||
return new Promise((res, rej) => { | ||
cbFunction(...args, (err, result) => { | ||
if (err) | ||
return rej(err); | ||
res(result); | ||
}); | ||
}); | ||
}; | ||
} | ||
exports.cb2promise = cb2promise; | ||
// noinspection JSUnusedGlobalSymbols | ||
function hashCode(s) { | ||
@@ -372,3 +369,62 @@ let hash = 0; | ||
exports.isBrowserEnvironment = isBrowserEnvironment; | ||
async function collectCallbacks(cbProvider) { | ||
const output = []; | ||
const collector = (v) => output.push(v); | ||
await cbProvider(collector); | ||
return output; | ||
} | ||
exports.collectCallbacks = collectCallbacks; | ||
async function repeatBeforeSucceed(fn, maxRepeats, repeatIn, timeMultiplier = 1, maxTime) { | ||
let repeat = 0; | ||
if (timeMultiplier < 1) | ||
throw new Error(`timeMultiplier (= ${timeMultiplier}) < 1 makes no sense`); | ||
while (true) { | ||
try { | ||
return await fn(); | ||
} | ||
catch (e) { | ||
if (repeat >= maxRepeats) | ||
throw e; | ||
if (repeat !== 0 && timeMultiplier != 1) { | ||
repeatIn = Math.min(repeatIn * timeMultiplier, maxTime ?? Infinity); | ||
} | ||
await sleep(repeatIn); | ||
} | ||
repeat++; | ||
} | ||
} | ||
exports.repeatBeforeSucceed = repeatBeforeSucceed; | ||
class TypedEvent { | ||
constructor() { | ||
this.listeners = []; | ||
this.listenersOncer = []; | ||
} | ||
on(listener) { | ||
this.listeners.push(listener); | ||
return { | ||
dispose: () => this.off(listener) | ||
}; | ||
} | ||
once(listener) { | ||
this.listenersOncer.push(listener); | ||
} | ||
off(listener) { | ||
var callbackIndex = this.listeners.indexOf(listener); | ||
if (callbackIndex > -1) | ||
this.listeners.splice(callbackIndex, 1); | ||
} | ||
emit(event) { | ||
this.listeners.forEach((listener) => listener(event)); | ||
if (this.listenersOncer.length > 0) { | ||
const toCall = this.listenersOncer; | ||
this.listenersOncer = []; | ||
toCall.forEach((listener) => listener(event)); | ||
} | ||
} | ||
pipe(te) { | ||
return this.on((e) => te.emit(e)); | ||
} | ||
} | ||
exports.TypedEvent = TypedEvent; | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInhwcmVzcy9ub2RlX21vZHVsZXMvQG1ldGVvci1pdC91dGlscy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLG1DQUFrQztBQUVsQyxxQ0FBcUM7QUFDckMsU0FBZ0IsZ0JBQWdCLENBQUMsTUFBYyxFQUFFLE9BQU8sR0FBRyxFQUFFO0lBQ3pELE9BQU8sSUFBSSxXQUFXLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxDQUFDO0FBQzVDLENBQUM7QUFGRCw0Q0FFQztBQUVELHFDQUFxQztBQUNyQyxTQUFnQixrQkFBa0IsQ0FBQyxNQUFnQixFQUFFLFVBQWtCLENBQUM7SUFDcEUsT0FBTyxJQUFJLE9BQU8sQ0FBQyxDQUFDLEdBQUcsRUFBRSxHQUFHLEVBQUUsRUFBRTtRQUM1QixNQUFNLElBQUksR0FBUSxFQUFFLENBQUM7UUFDckIsSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDO1FBQ2IsTUFBTSxDQUFDLEVBQUUsQ0FBQyxNQUFNLEVBQUUsQ0FB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lc3VsdFxuICovXG5leHBvcnQgZnVuY3Rpb24gZmxhdHRlbihhcnJheTogYW55W10sIHJlc3VsdDogYW55W10gPSBbXSk6IGFueVtdIHtcbiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFycmF5Lmxlbmd0aDsgaSsrKSB7XG4gICAgICAgIGNvbnN0IHZhbHVlID0gYXJyYXlbaV07XG5cbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICBmbGF0dGVuKHZhbHVlLCByZXN1bHQpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmVzdWx0LnB1c2godmFsdWUpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIHJlc3VsdDtcbn1cblxuLyoqXG4gKiBAZGVwcmVjYXRlZFxuICogQHBhcmFtIGFycmF5XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiByZW1vdmVEdXBsaWNhdGVzPFQ+KGFycmF5OiBUW10pOiBUW10ge1xuICAgIHJldHVybiBBcnJheS5mcm9tKG5ldyBTZXQoYXJyYXkpKTtcbn1cblxuLyoqXG4gKiBAZGVwcmVjYXRlZFxuICogQHBhcmFtIGFycmF5MVxuICogQHBhcmFtIGFycmF5MlxuICovXG5leHBvcnQgZnVuY3Rpb24gbWl4KGFycmF5MTogYW55W10gfCBPYmplY3QsIGFycmF5MjogYW55W10gfCBPYmplY3QpOiBhbnkge1xuICAgIGxldCBvdXQ6IGFueTtcbiAgICBpZiAoYXJyYXkxIGluc3RhbmNlb2YgQXJyYXkpIHtcbiAgICAgICAgb3V0ID0gW107XG4gICAgICAgIGZvciAobGV0IGluZGV4IGluIGFycmF5MSkge1xuICAgICAgICAgICAgb3V0LnB1c2goW2FycmF5MVtpbmRleF0sIChhcnJheTIgYXMgYW55KVtpbmRleF1dKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gb3V0O1xuICAgIH0gZWxzZSB7XG4gICAgICAgIG91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gc3RyLnN1YnN0cigwLCAxKS50b1VwcGVyQ2FzZSgpICsgc3RyLnN1YnN0cigxKTtcbn1cblxuLyoqXG4gKiBAcGFyYW0geFxuICogQHBhcmFtIHlcbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIG9iamVjdEVxdWFscyh4OiBhbnksIHk6IGFueSk6IGJvb2xlYW4ge1xuICAgIGlmICh4ID09PSBudWxsIHx8IHggPT09IHVuZGVmaW5lZCB8fCB5ID09PSBudWxsIHx8IHkgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICByZXR1cm4geCA9PT0geTtcbiAgICB9XG4gICAgaWYgKHguY29uc3RydWN0b3IgIT09IHkuY29uc3RydWN0b3IpIHtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgICBpZiAoeCBpbnN0YW5jZW9mIEZ1bmN0aW9uKSB7XG4gICAgICAgIHJldHVybiB4ID09PSB5O1xuICAgIH1cbiAgICBpZiAoeCBpbnN0YW5jZW9mIFJlZ0V4cCkge1xuICAgICAgICByZXR1cm4geC5zb3VyY2UgPT09IHkuc291cmNlICYmIHguc291cmNlID09PSB5LnNvdXJjZTtcbiAgICB9XG4gICAgaWYgKHggPT09IHkgfHwgeC52YWx1ZU9mKCkgPT09IHkudmFsdWVPZigpKSB7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICBpZiAoeCBpbnN0YW5jZW9mIE1hcCkge1xuICAgICAgICBpZiAoeC5zaXplICE9PSB5LnNpemUpXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIGlmICghb2JqZWN0RXF1YWxzKFsuLi54LmtleXMoKV0uc29ydCgpLCBbLi4ueS5rZXlzKCldLnNvcnQoKSkpXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIGlmICghb2JqZWN0RXF1YWxzKFsuLi54LnZhbHVlcygpXS5zb3J0KCksIFsuLi55LnZhbHVlcygpXS5zb3J0KCkpKVxuICAgICAgICA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GVjdG9yKTtcbiAgICByZXR1cm4gb3V0cHV0O1xufVxuXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gcmVwZWF0QmVmb3JlU3VjY2VlZDxWPihmbjogKCkgPT4gUHJvbWlzZTxWPiwgbWF4UmVwZWF0czogbnVtYmVyLCByZXBlYXRJbjogbnVtYmVyLCB0aW1lTXVsdGlwbGllcjogbnVtYmVyID0gMSwgbWF4VGltZT86IG51bWJlcik6IFByb21pc2U8Vj4ge1xuICAgIGxldCByZXBlYXQgPSAwO1xuICAgIGlmICh0aW1lTXVsdGlwbGllciA8IDEpIHRocm93IG5ldyBFcnJvcihgdGltZU11bHRpcGxpZXIgKD0gJHt0aW1lTXVsdGlwbGllcn0pIDwgMSBtYWtlcyBubyBzZW5zZWApO1xuICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICByZXR1cm4gYXdhaXQgZm4oKTtcbiAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgaWYgKHJlcGVhdCA+PSBtYXhSZXBlYXRzKVxuICAgICAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgICAgICBpZiAocmVwZWF0ICE9PSAwICYmIHRpbWVNdWx0aXBsaWVyICE9IDEpIHtcbiAgICAgICAgICAgICAgICByZXBlYXRJbiA9IE1hdGgubWluKHJlcGVhdEluICogdGltZU11bHRpcGxpZXIsIG1heFRpbWUgPz8gSW5maW5pdHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYXdhaXQgc2xlZXAocmVwZWF0SW4pO1xuICAgICAgICB9XG4gICAgICAgIHJlcGVhdCsrO1xuICAgIH1cbn1cblxuZXhwb3J0IGludGVyZmFjZSBMaXN0ZW5lcjxUPiB7XG4gICAgKGV2ZW50OiBUKTogYW55O1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIERpc3Bvc2FibGUge1xuICAgIGRpc3Bvc2UoKTogdm9pZDtcbn1cblxuZXhwb3J0IGNsYXNzI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mVudCkpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHBpcGUodGU6IFR5cGVkRXZlbnQ8VD4pOiBEaXNwb3NhYmxlIHtcbiAgICAgICAgcmV0dXJuIHRoaXMub24oKGUpID0+IHRlLmVtaXQoZSkpO1xuICAgIH1cbn1cbiJdfQ== |
110
index.ts
@@ -57,3 +57,2 @@ import { Readable } from 'stream'; | ||
/** | ||
* @deprecated Extremally slow on Proxy/getters | ||
* @param x | ||
@@ -73,3 +72,3 @@ * @param y | ||
if (x instanceof RegExp) { | ||
return x === y; | ||
return x.source === y.source && x.source === y.source; | ||
} | ||
@@ -79,2 +78,18 @@ if (x === y || x.valueOf() === y.valueOf()) { | ||
} | ||
if (x instanceof Map) { | ||
if (x.size !== y.size) | ||
return false; | ||
if (!objectEquals([...x.keys()].sort(), [...y.keys()].sort())) | ||
return false; | ||
if (!objectEquals([...x.values()].sort(), [...y.values()].sort())) | ||
return false; | ||
return true; | ||
} | ||
if (x instanceof Set) { | ||
if (x.size !== y.size) | ||
return false; | ||
if (!objectEquals([...x.values()].sort(), [...y.values()].sort())) | ||
return false; | ||
return true; | ||
} | ||
if (Array.isArray(x) && x.length !== y.length) { | ||
@@ -216,3 +231,3 @@ return false; | ||
*/ | ||
export function asyncEach<T, R>(iterable: T[], cb: (v: T) => Promise<R>): R[] { | ||
export function asyncEach<T, R>(iterable: T[], cb: (v: T) => Promise<R>): Promise<R[]> { | ||
let waitings: any = []; | ||
@@ -222,23 +237,6 @@ iterable.forEach(iter => { | ||
}); | ||
return Promise.all(waitings) as any; | ||
return Promise.all(waitings); | ||
} | ||
// noinspection JSUnusedGlobalSymbols | ||
/** | ||
* Convert callback function to async | ||
* @deprecated Existst in node utils | ||
* @param cbFunction Function to convert | ||
*/ | ||
export function cb2promise(cbFunction: any): (...d: any[]) => Promise<any> { | ||
return (...args) => { | ||
return new Promise((res, rej) => { | ||
cbFunction(...args, (err: Error, result: any) => { | ||
if (err) return rej(err); | ||
res(result); | ||
}); | ||
}); | ||
}; | ||
} | ||
// noinspection JSUnusedGlobalSymbols | ||
export function hashCode(s: string) { | ||
@@ -320,5 +318,5 @@ let hash = 0; | ||
/** | ||
* Calls __non_webpack_require__ or plain require to work around webpack, | ||
* Calls __non_webpack_require__ or plain require to work around webpack, | ||
* and make still possible to use this in non-webpack code | ||
* @param module | ||
* @param module | ||
*/ | ||
@@ -378,1 +376,67 @@ export function externalRequire(module: string): any { | ||
} | ||
export async function collectCallbacks<T>(cbProvider: (collector: (t: T) => void) => Promise<void>): Promise<T[]> { | ||
const output: T[] = []; | ||
const collector = (v: T) => output.push(v); | ||
await cbProvider(collector); | ||
return output; | ||
} | ||
export async function repeatBeforeSucceed<V>(fn: () => Promise<V>, maxRepeats: number, repeatIn: number, timeMultiplier: number = 1, maxTime?: number): Promise<V> { | ||
let repeat = 0; | ||
if (timeMultiplier < 1) throw new Error(`timeMultiplier (= ${timeMultiplier}) < 1 makes no sense`); | ||
while (true) { | ||
try { | ||
return await fn(); | ||
} catch (e) { | ||
if (repeat >= maxRepeats) | ||
throw e; | ||
if (repeat !== 0 && timeMultiplier != 1) { | ||
repeatIn = Math.min(repeatIn * timeMultiplier, maxTime ?? Infinity); | ||
} | ||
await sleep(repeatIn); | ||
} | ||
repeat++; | ||
} | ||
} | ||
export interface Listener<T> { | ||
(event: T): any; | ||
} | ||
export interface Disposable { | ||
dispose(): void; | ||
} | ||
export class TypedEvent<T> { | ||
private listeners: Listener<T>[] = []; | ||
private listenersOncer: Listener<T>[] = []; | ||
on(listener: Listener<T>): Disposable { | ||
this.listeners.push(listener); | ||
return { | ||
dispose: () => this.off(listener) | ||
}; | ||
} | ||
once(listener: Listener<T>): void { | ||
this.listenersOncer.push(listener); | ||
} | ||
off(listener: Listener<T>) { | ||
var callbackIndex = this.listeners.indexOf(listener); | ||
if (callbackIndex > -1) this.listeners.splice(callbackIndex, 1); | ||
} | ||
emit(event: T) { | ||
this.listeners.forEach((listener) => listener(event)); | ||
if (this.listenersOncer.length > 0) { | ||
const toCall = this.listenersOncer; | ||
this.listenersOncer = []; | ||
toCall.forEach((listener) => listener(event)); | ||
} | ||
} | ||
pipe(te: TypedEvent<T>): Disposable { | ||
return this.on((e) => te.emit(e)); | ||
} | ||
} |
{ | ||
"name": "@meteor-it/utils", | ||
"version": "1.3.27", | ||
"version": "1.3.29", | ||
"description": "Many useful utils", | ||
@@ -17,3 +17,3 @@ "module": "index.mjs", | ||
}, | ||
"gitHead": "7b240cacfacfe9f46c45796028c518753cc6f6b1" | ||
"gitHead": "45ae37da49e836f0d90dc0a0a395e500fc2f6f1b" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102718
1588