Comparing version 0.2.93 to 0.2.94
@@ -29,2 +29,5 @@ export function create(): { | ||
}): number; | ||
export function size(obj: { | ||
[x: string]: any; | ||
}): number; | ||
export function some(obj: { | ||
@@ -31,0 +34,0 @@ [x: string]: any; |
@@ -18,2 +18,3 @@ export function create<T>(f: (arg0: PromiseResolve<T>, arg1: (arg0: Error) => void) => any): Promise<T>; | ||
export function until(timeout: number, check: () => boolean, intervalResolution?: number | undefined): Promise<void>; | ||
export function untilAsync(check: () => Promise<boolean> | boolean, timeout?: number, intervalResolution?: number): Promise<void>; | ||
export function wait(timeout: number): Promise<undefined>; | ||
@@ -20,0 +21,0 @@ export function isPromise(p: any): boolean; |
@@ -135,5 +135,5 @@ /** | ||
/* c8 ignore start */ | ||
export const supportsColor = !hasParam('no-colors') && | ||
export const supportsColor = !hasParam('--no-colors') && | ||
(!isNode || process.stdout.isTTY || forceColor) && ( | ||
!isNode || hasParam('color') || forceColor || | ||
!isNode || hasParam('--color') || forceColor || | ||
getVariable('COLORTERM') !== null || | ||
@@ -140,0 +140,0 @@ (getVariable('TERM') || '').includes('color') |
@@ -29,2 +29,5 @@ export function create(): { | ||
}): number; | ||
export function size(obj: { | ||
[x: string]: any; | ||
}): number; | ||
export function some(obj: { | ||
@@ -31,0 +34,0 @@ [x: string]: any; |
@@ -50,2 +50,3 @@ /** | ||
/** | ||
* @deprecated use object.size instead | ||
* @param {Object<string,any>} obj | ||
@@ -58,2 +59,8 @@ * @return {number} | ||
* @param {Object<string,any>} obj | ||
* @return {number} | ||
*/ | ||
export const size = obj => keys(obj).length | ||
/** | ||
* @param {Object<string,any>} obj | ||
* @param {function(any,string):boolean} f | ||
@@ -110,2 +117,2 @@ * @return {boolean} | ||
*/ | ||
export const equalFlat = (a, b) => a === b || (length(a) === length(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && b[key] === val)) | ||
export const equalFlat = (a, b) => a === b || (size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && b[key] === val)) |
{ | ||
"name": "lib0", | ||
"version": "0.2.93", | ||
"version": "0.2.94", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -18,2 +18,3 @@ export function create<T>(f: (arg0: PromiseResolve<T>, arg1: (arg0: Error) => void) => any): Promise<T>; | ||
export function until(timeout: number, check: () => boolean, intervalResolution?: number | undefined): Promise<void>; | ||
export function untilAsync(check: () => Promise<boolean> | boolean, timeout?: number, intervalResolution?: number): Promise<void>; | ||
export function wait(timeout: number): Promise<undefined>; | ||
@@ -20,0 +21,0 @@ export function isPromise(p: any): boolean; |
@@ -59,2 +59,3 @@ /** | ||
* @todo Next version, reorder parameters: check, [timeout, [intervalResolution]] | ||
* @deprecated use untilAsync instead | ||
* | ||
@@ -85,6 +86,23 @@ * @param {number} timeout | ||
/** | ||
* @param {()=>Promise<boolean>|boolean} check | ||
* @param {number} timeout | ||
* @param {number} intervalResolution | ||
* @return {Promise<void>} | ||
*/ | ||
export const untilAsync = async (check, timeout = 0, intervalResolution = 10) => { | ||
const startTime = time.getUnixTime() | ||
const noTimeout = timeout <= 0 | ||
// eslint-disable-next-line no-unmodified-loop-condition | ||
while (noTimeout || time.getUnixTime() - startTime <= timeout) { | ||
if (await check()) return | ||
await wait(intervalResolution) | ||
} | ||
throw new Error('Timeout') | ||
} | ||
/** | ||
* @param {number} timeout | ||
* @return {Promise<undefined>} | ||
*/ | ||
export const wait = timeout => create((resolve, reject) => setTimeout(resolve, timeout)) | ||
export const wait = timeout => create((resolve, _reject) => setTimeout(resolve, timeout)) | ||
@@ -91,0 +109,0 @@ /** |
@@ -13,2 +13,3 @@ import { runTests } from './testing.js' | ||
import * as indexeddb from './indexeddb.test.js' | ||
import * as indexeddbV2 from './indexeddbV2.test.js' | ||
import * as prng from './prng.test.js' | ||
@@ -27,2 +28,3 @@ import * as log from 'lib0/logging' | ||
import * as observable from './observable.test.js' | ||
import * as pledge from './pledge.test.js' | ||
import * as math from './math.test.js' | ||
@@ -60,2 +62,3 @@ import * as number from './number.test.js' | ||
indexeddb, | ||
indexeddbV2, | ||
prng, | ||
@@ -73,2 +76,3 @@ statistics, | ||
observable, | ||
pledge, | ||
math, | ||
@@ -75,0 +79,0 @@ number, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1895713
716
24818