@fp-ts/data
Advanced tools
Comparing version 0.0.29 to 0.0.30
@@ -27,6 +27,12 @@ /** | ||
/** | ||
* Specifying the key will make the Tag global, meaning two tags with the same | ||
* key will map to the same instance. | ||
* | ||
* Note: this is useful for cases where live reload can happen and it is | ||
* desireable to preserve the instance across reloads. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
export declare const Tag: <Service>() => Tag<Service>; | ||
export declare const Tag: <Service>(key?: string) => Tag<Service>; | ||
declare const TypeId: unique symbol; | ||
@@ -33,0 +39,0 @@ /** |
@@ -16,6 +16,12 @@ "use strict"; | ||
/** | ||
* Specifying the key will make the Tag global, meaning two tags with the same | ||
* key will map to the same instance. | ||
* | ||
* Note: this is useful for cases where live reload can happen and it is | ||
* desireable to preserve the instance across reloads. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
const Tag = () => new C.TagImpl(); | ||
const Tag = key => new C.TagImpl(key); | ||
exports.Tag = Tag; | ||
@@ -22,0 +28,0 @@ const TypeId = C.ContextTypeId; |
@@ -25,5 +25,15 @@ "use strict"; | ||
class TagImpl { | ||
constructor() { | ||
constructor(key) { | ||
this.key = key; | ||
this._id = TagTypeId; | ||
this._S = _ => _; | ||
if (key) { | ||
if (!(TagTypeId in globalThis)) { | ||
globalThis[TagTypeId] = {}; | ||
} | ||
if (!(key in globalThis[TagTypeId])) { | ||
globalThis[TagTypeId][key] = this; | ||
} | ||
return globalThis[TagTypeId][key]; | ||
} | ||
} | ||
@@ -30,0 +40,0 @@ [Equal.symbolEqual](that) { |
{ | ||
"name": "@fp-ts/data", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
1877240
36738