dexie-cloud-common
Advanced tools
Comparing version 1.0.23 to 1.0.24
export declare function assert(b: boolean): asserts b is true; | ||
export declare function hasOwn(obj: any, prop: any): boolean; | ||
declare type SetByKeyPathTarget = { | ||
@@ -3,0 +4,0 @@ [keyPath: string]: SetByKeyPathTarget; |
@@ -6,2 +6,6 @@ import { randomFillSync } from "universal-imports"; | ||
} | ||
const _hasOwn = {}.hasOwnProperty; | ||
export function hasOwn(obj, prop) { | ||
return _hasOwn.call(obj, prop); | ||
} | ||
export function setByKeyPath(obj, keyPath, value) { | ||
@@ -39,4 +43,4 @@ if (!obj || keyPath === undefined) | ||
//@ts-ignore: even if currentKeyPath would be numeric string and obj would be array - it works. | ||
if (!innerObj) | ||
innerObj = obj[currentKeyPath] = {}; | ||
if (!innerObj || !hasOwn(obj, currentKeyPath)) | ||
innerObj = (obj[currentKeyPath] = {}); | ||
setByKeyPath(innerObj, remainingKeyPath, value); | ||
@@ -60,3 +64,8 @@ } | ||
} | ||
export const randomString = typeof self === 'undefined' ? (bytes) => { | ||
export const randomString = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes) => { | ||
// Web | ||
const buf = new Uint8Array(bytes); | ||
crypto.getRandomValues(buf); | ||
return btoa(String.fromCharCode.apply(null, buf)); | ||
} : typeof Buffer !== 'undefined' ? (bytes) => { | ||
// Node | ||
@@ -66,7 +75,2 @@ const buf = Buffer.alloc(bytes); | ||
return buf.toString("base64"); | ||
} : (bytes) => { | ||
// Web | ||
const buf = new Uint8Array(bytes); | ||
crypto.getRandomValues(buf); | ||
return btoa(String.fromCharCode.apply(null, buf)); | ||
}; | ||
} : () => { throw new Error("No implementation of randomString was found"); }; |
{ | ||
"name": "dexie-cloud-common", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"packageManager": "^pnpm@7.9.5", | ||
"description": "Library for shared code between dexie-cloud-addon, dexie-cloud (CLI) and dexie-cloud-server", | ||
@@ -17,4 +18,7 @@ "type": "module", | ||
"dependencies": { | ||
"universal-imports": "^1.0.1" | ||
"universal-imports": "^1.0.4" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.7.14" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62912
679
1
Updateduniversal-imports@^1.0.4