@xylabs/object
Advanced tools
Comparing version 3.1.10 to 3.1.11
@@ -0,2 +1,3 @@ | ||
export declare const disableGloballyUnique: () => void; | ||
export declare const globallyUnique: (name: string, value: unknown, domain?: string) => string; | ||
//# sourceMappingURL=globallyUnique.d.ts.map |
@@ -77,13 +77,21 @@ // src/AsTypeFactory.ts | ||
// src/globallyUnique.ts | ||
var xyoGlobal = () => { | ||
return globalThis.xylabs = globalThis.xylabs ?? {}; | ||
}; | ||
var disableGloballyUnique = () => { | ||
xyoGlobal().uniqueDisabled = true; | ||
}; | ||
var globallyUnique = (name, value, domain = "global") => { | ||
const uniqueName = [domain, name].join(":"); | ||
const xyo = globalThis.xylabs = globalThis.xylabs ?? {}; | ||
const unique = xyo.unique = xyo.unique ?? {}; | ||
if (unique[uniqueName] === void 0) { | ||
unique[uniqueName] = value; | ||
} else { | ||
if (unique[uniqueName] !== value) { | ||
throw new Error( | ||
`Global unique item ${uniqueName} already defined. Make sure you are not importing two versions of the package that contains this item` | ||
); | ||
if (!xyoGlobal().uniqueDisabled) { | ||
const xyo = globalThis.xylabs = globalThis.xylabs ?? {}; | ||
const unique = xyo.unique = xyo.unique ?? {}; | ||
if (unique[uniqueName] === void 0) { | ||
unique[uniqueName] = value; | ||
} else { | ||
if (unique[uniqueName] !== value) { | ||
throw new Error( | ||
`Global unique item ${uniqueName} already defined. Make sure you are not importing two versions of the package that contains this item` | ||
); | ||
} | ||
} | ||
@@ -329,2 +337,3 @@ } | ||
asAnyObject, | ||
disableGloballyUnique, | ||
globallyUnique, | ||
@@ -331,0 +340,0 @@ isJsonArray, |
@@ -0,2 +1,3 @@ | ||
export declare const disableGloballyUnique: () => void; | ||
export declare const globallyUnique: (name: string, value: unknown, domain?: string) => string; | ||
//# sourceMappingURL=globallyUnique.d.ts.map |
@@ -77,13 +77,21 @@ // src/AsTypeFactory.ts | ||
// src/globallyUnique.ts | ||
var xyoGlobal = () => { | ||
return globalThis.xylabs = globalThis.xylabs ?? {}; | ||
}; | ||
var disableGloballyUnique = () => { | ||
xyoGlobal().uniqueDisabled = true; | ||
}; | ||
var globallyUnique = (name, value, domain = "global") => { | ||
const uniqueName = [domain, name].join(":"); | ||
const xyo = globalThis.xylabs = globalThis.xylabs ?? {}; | ||
const unique = xyo.unique = xyo.unique ?? {}; | ||
if (unique[uniqueName] === void 0) { | ||
unique[uniqueName] = value; | ||
} else { | ||
if (unique[uniqueName] !== value) { | ||
throw new Error( | ||
`Global unique item ${uniqueName} already defined. Make sure you are not importing two versions of the package that contains this item` | ||
); | ||
if (!xyoGlobal().uniqueDisabled) { | ||
const xyo = globalThis.xylabs = globalThis.xylabs ?? {}; | ||
const unique = xyo.unique = xyo.unique ?? {}; | ||
if (unique[uniqueName] === void 0) { | ||
unique[uniqueName] = value; | ||
} else { | ||
if (unique[uniqueName] !== value) { | ||
throw new Error( | ||
`Global unique item ${uniqueName} already defined. Make sure you are not importing two versions of the package that contains this item` | ||
); | ||
} | ||
} | ||
@@ -334,2 +342,3 @@ } | ||
asAnyObject, | ||
disableGloballyUnique, | ||
globallyUnique, | ||
@@ -336,0 +345,0 @@ isJsonArray, |
@@ -14,5 +14,5 @@ { | ||
"dependencies": { | ||
"@xylabs/assert": "^3.1.10", | ||
"@xylabs/logger": "^3.1.10", | ||
"@xylabs/promise": "^3.1.10" | ||
"@xylabs/assert": "^3.1.11", | ||
"@xylabs/logger": "^3.1.11", | ||
"@xylabs/promise": "^3.1.11" | ||
}, | ||
@@ -62,4 +62,4 @@ "devDependencies": { | ||
"sideEffects": false, | ||
"version": "3.1.10", | ||
"version": "3.1.11", | ||
"type": "module" | ||
} |
interface XylabsGlobalThis { | ||
xylabs: { | ||
unique: Record<string, unknown> | ||
uniqueDisabled?: boolean | ||
} | ||
} | ||
const xyoGlobal = () => { | ||
return ((globalThis as unknown as XylabsGlobalThis).xylabs = (globalThis as unknown as XylabsGlobalThis).xylabs ?? {}) | ||
} | ||
export const disableGloballyUnique = () => { | ||
xyoGlobal().uniqueDisabled = true | ||
} | ||
export const globallyUnique = (name: string, value: unknown, domain = 'global') => { | ||
const uniqueName = [domain, name].join(':') | ||
const xyo = ((globalThis as unknown as XylabsGlobalThis).xylabs = (globalThis as unknown as XylabsGlobalThis).xylabs ?? {}) | ||
const unique = (xyo.unique = xyo.unique ?? {}) | ||
if (unique[uniqueName] === undefined) { | ||
unique[uniqueName] = value | ||
} else { | ||
if (unique[uniqueName] !== value) { | ||
throw new Error( | ||
`Global unique item ${uniqueName} already defined. Make sure you are not importing two versions of the package that contains this item`, | ||
) | ||
if (!xyoGlobal().uniqueDisabled) { | ||
const xyo = ((globalThis as unknown as XylabsGlobalThis).xylabs = (globalThis as unknown as XylabsGlobalThis).xylabs ?? {}) | ||
const unique = (xyo.unique = xyo.unique ?? {}) | ||
if (unique[uniqueName] === undefined) { | ||
unique[uniqueName] = value | ||
} else { | ||
if (unique[uniqueName] !== value) { | ||
throw new Error( | ||
`Global unique item ${uniqueName} already defined. Make sure you are not importing two versions of the package that contains this item`, | ||
) | ||
} | ||
} | ||
@@ -19,0 +30,0 @@ } |
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
292781
2142
Updated@xylabs/assert@^3.1.11
Updated@xylabs/logger@^3.1.11
Updated@xylabs/promise@^3.1.11