@xylabs/object
Advanced tools
Comparing version 3.0.24 to 3.0.25
@@ -10,2 +10,3 @@ import { Logger } from '@xylabs/logger'; | ||
static defaultLogger?: Logger; | ||
static readonly uniqueName: string; | ||
constructor(params: TParams); | ||
@@ -12,0 +13,0 @@ protected get logger(): Logger | undefined; |
@@ -7,2 +7,3 @@ export * from './AnyObject'; | ||
export * from './EmptyObject'; | ||
export * from './globallyUnique'; | ||
export * from './isObject'; | ||
@@ -9,0 +10,0 @@ export * from './IsObjectFactory'; |
@@ -73,2 +73,19 @@ // src/AsTypeFactory.ts | ||
// src/globallyUnique.ts | ||
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` | ||
); | ||
} | ||
} | ||
return uniqueName; | ||
}; | ||
// src/Base.ts | ||
@@ -81,2 +98,3 @@ var Base = class _Base { | ||
static defaultLogger; | ||
static uniqueName = globallyUnique(this.name, this, "xyo"); | ||
get logger() { | ||
@@ -200,2 +218,3 @@ return this.params?.logger ?? _Base.defaultLogger; | ||
asAnyObject, | ||
globallyUnique, | ||
isJsonArray, | ||
@@ -202,0 +221,0 @@ isJsonObject, |
@@ -10,2 +10,3 @@ import { Logger } from '@xylabs/logger'; | ||
static defaultLogger?: Logger; | ||
static readonly uniqueName: string; | ||
constructor(params: TParams); | ||
@@ -12,0 +13,0 @@ protected get logger(): Logger | undefined; |
@@ -7,2 +7,3 @@ export * from './AnyObject'; | ||
export * from './EmptyObject'; | ||
export * from './globallyUnique'; | ||
export * from './isObject'; | ||
@@ -9,0 +10,0 @@ export * from './IsObjectFactory'; |
@@ -73,2 +73,19 @@ // src/AsTypeFactory.ts | ||
// src/globallyUnique.ts | ||
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` | ||
); | ||
} | ||
} | ||
return uniqueName; | ||
}; | ||
// src/Base.ts | ||
@@ -82,2 +99,3 @@ var Base = class _Base { | ||
static defaultLogger; | ||
static uniqueName = globallyUnique(this.name, this, "xyo"); | ||
get logger() { | ||
@@ -202,2 +220,3 @@ var _a; | ||
asAnyObject, | ||
globallyUnique, | ||
isJsonArray, | ||
@@ -204,0 +223,0 @@ isJsonObject, |
@@ -14,5 +14,5 @@ { | ||
"dependencies": { | ||
"@xylabs/assert": "^3.0.24", | ||
"@xylabs/logger": "^3.0.24", | ||
"@xylabs/promise": "^3.0.24" | ||
"@xylabs/assert": "^3.0.25", | ||
"@xylabs/logger": "^3.0.25", | ||
"@xylabs/promise": "^3.0.25" | ||
}, | ||
@@ -62,4 +62,4 @@ "devDependencies": { | ||
"sideEffects": false, | ||
"version": "3.0.24", | ||
"version": "3.0.25", | ||
"type": "module" | ||
} |
import { Logger } from '@xylabs/logger' | ||
import { EmptyObject } from './EmptyObject' | ||
import { globallyUnique } from './globallyUnique' | ||
@@ -14,2 +15,3 @@ export type BaseParamsFields = { | ||
static defaultLogger?: Logger | ||
static readonly uniqueName = globallyUnique(this.name, this, 'xyo') | ||
@@ -16,0 +18,0 @@ constructor(readonly params: TParams) { |
@@ -7,2 +7,3 @@ export * from './AnyObject' | ||
export * from './EmptyObject' | ||
export * from './globallyUnique' | ||
export * from './isObject' | ||
@@ -9,0 +10,0 @@ export * from './IsObjectFactory' |
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
225245
259
1472
Updated@xylabs/assert@^3.0.25
Updated@xylabs/logger@^3.0.25
Updated@xylabs/promise@^3.0.25