@opendesign/octopus-common
Advanced tools
Comparing version 3.0.0-experimental-989655a5b-20230117 to 3.0.0-experimental-npmjs-ci-36c43824
@@ -0,1 +1,2 @@ | ||
import type { GetPromiseValue } from './utility-types'; | ||
export declare function JSONFromTypedArray(typedArray: Uint8Array): unknown; | ||
@@ -11,4 +12,15 @@ export declare function deepInspect(value: unknown): string; | ||
}>(entities: T[]): Exclude<ReturnType<T['convert']>, null>[]; | ||
declare type ConvertedLayer<T, U extends { | ||
convert: () => Promise<T>; | ||
}> = Exclude<GetPromiseValue<ReturnType<U['convert']>>, null>; | ||
export declare function getConvertedAsync<T, U extends { | ||
convert: () => Promise<T>; | ||
}>(entities: U[]): Promise<ConvertedLayer<T, U>[]>; | ||
export declare function traverseAndFind<T>(node: Record<string, unknown>, cb: Function): T[]; | ||
export declare function keys<T extends Record<string | number | symbol, unknown>>(obj: T): (keyof T)[]; | ||
export declare function push<T, U>(arr: (T | U)[], ...values: U[]): (T | U)[]; | ||
/** language-sensitive string compare function for array sort */ | ||
export declare const compareStrings: (a: string, b: string) => number; | ||
/** factory for function which creates unique id */ | ||
export declare function uniqueIdFactory(startingCounter: number, prefix?: string): () => string; | ||
export {}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.push = exports.keys = exports.traverseAndFind = exports.getConverted = exports.getPresentProps = exports.getMapped = exports.isObject = exports.deepInspect = exports.JSONFromTypedArray = void 0; | ||
exports.uniqueIdFactory = exports.compareStrings = exports.push = exports.keys = exports.traverseAndFind = exports.getConvertedAsync = exports.getConverted = exports.getPresentProps = exports.getMapped = exports.isObject = exports.deepInspect = exports.JSONFromTypedArray = void 0; | ||
const util_1 = __importDefault(require("util")); | ||
@@ -35,11 +35,10 @@ const isObjectLike_1 = __importDefault(require("lodash/isObjectLike")); | ||
function getConverted(entities) { | ||
return entities | ||
.map((entity) => { | ||
return entity.convert(); | ||
}) | ||
.filter((converted) => { | ||
return converted; | ||
}); | ||
return entities.map((entity) => entity.convert()).filter((converted) => Boolean(converted)); | ||
} | ||
exports.getConverted = getConverted; | ||
async function getConvertedAsync(entities) { | ||
const converted = await Promise.all(entities.map((entity) => entity.convert())); | ||
return converted.filter((converted) => Boolean(converted)); | ||
} | ||
exports.getConvertedAsync = getConvertedAsync; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
@@ -70,1 +69,14 @@ function _traverseAndFindRecursive(node, cb) { | ||
exports.push = push; | ||
/** language-sensitive string compare function for array sort */ | ||
exports.compareStrings = (() => { | ||
const collator = new Intl.Collator('en-US'); | ||
return (a, b) => collator.compare(a, b); | ||
})(); | ||
/** factory for function which creates unique id */ | ||
function uniqueIdFactory(startingCounter, prefix) { | ||
return () => { | ||
startingCounter = startingCounter + 1; | ||
return prefix ? `${prefix}-${String(startingCounter)}` : String(startingCounter); | ||
}; | ||
} | ||
exports.uniqueIdFactory = uniqueIdFactory; |
@@ -15,8 +15,4 @@ "use strict"; | ||
exports.hashOf = hashOf; | ||
const compare = (() => { | ||
const collator = new Intl.Collator('en-US'); | ||
return (a, b) => collator.compare(a, b); | ||
})(); | ||
function hashOfObjectSeed(seed) { | ||
return hashOf(seed.slice().sort((a, b) => compare(String(a[0]), String(b[0])))); | ||
return hashOf(seed.slice().sort((a, b) => (0, common_1.compareStrings)(String(a[0]), String(b[0])))); | ||
} | ||
@@ -23,0 +19,0 @@ exports.hashOfObjectSeed = hashOfObjectSeed; |
{ | ||
"name": "@opendesign/octopus-common", | ||
"version": "3.0.0-experimental-989655a5b-20230117", | ||
"version": "3.0.0-experimental-npmjs-ci-36c43824", | ||
"description": "General utility functions for Octopus 3 common cases.", | ||
@@ -17,3 +17,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@opendesign/octopus-ts": "3.0.0-alpha.38", | ||
"@opendesign/octopus-ts": "3.0.1", | ||
"@types/lodash": "^4.14.178", | ||
@@ -37,2 +37,2 @@ "@types/uuid": "^8.3.1", | ||
] | ||
} | ||
} |
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
56202
47
1235
+ Added@opendesign/octopus-ts@3.0.1(transitive)
- Removed@opendesign/octopus-ts@3.0.0-alpha.38(transitive)
Updated@opendesign/octopus-ts@3.0.1