@effect/data
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -72,2 +72,18 @@ /** | ||
}>(tag: A["_tag"]) => Case.Constructor<A, "_tag">; | ||
/** | ||
* Provides a Tagged constructor for a Case Class. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
export declare const TaggedClass: <Key extends string>(tag: Key) => <A extends Record<string, any>>() => new (args: Omit<A, keyof Equal.Equal | "_tag">) => Readonly<A> & Equal.Equal & { | ||
readonly _tag: Key; | ||
}; | ||
/** | ||
* Provides a constructor for a Case Class. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
export declare const Class: <A extends Record<string, any>>() => new (args: Omit<A, keyof Equal.Equal>) => Data<A>; | ||
//# sourceMappingURL=Data.d.ts.map |
35
Data.js
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.unsafeStruct = exports.unsafeArray = exports.tuple = exports.tagged = exports.struct = exports.case = exports.array = void 0; | ||
exports.unsafeStruct = exports.unsafeArray = exports.tuple = exports.tagged = exports.struct = exports.case = exports.array = exports.TaggedClass = exports.Class = void 0; | ||
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal")); | ||
@@ -96,3 +96,36 @@ var Hash = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Hash")); | ||
}); | ||
/** | ||
* Provides a Tagged constructor for a Case Class. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
exports.tagged = tagged; | ||
const TaggedClass = tag => () => { | ||
class Base { | ||
constructor(args) { | ||
this._tag = tag; | ||
Object.assign(this, args); | ||
unsafeStruct(this); | ||
} | ||
} | ||
return Base; | ||
}; | ||
/** | ||
* Provides a constructor for a Case Class. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
exports.TaggedClass = TaggedClass; | ||
const Class = () => { | ||
class Base { | ||
constructor(args) { | ||
Object.assign(this, args); | ||
unsafeStruct(this); | ||
} | ||
} | ||
return Base; | ||
}; | ||
exports.Class = Class; | ||
//# sourceMappingURL=Data.js.map |
{ | ||
"name": "@effect/data", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -128,1 +128,37 @@ /** | ||
(args) => struct({ _tag: tag, ...args }) | ||
/** | ||
* Provides a Tagged constructor for a Case Class. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
export const TaggedClass = <Key extends string>( | ||
tag: Key | ||
) => | ||
<A extends Record<string, any>>() => { | ||
class Base { | ||
readonly _tag = tag | ||
constructor(args: Omit<A, "_tag" | keyof Equal.Equal>) { | ||
Object.assign(this, args) | ||
unsafeStruct(this) | ||
} | ||
} | ||
return Base as unknown as { new(args: Omit<A, "_tag" | keyof Equal.Equal>): Data<A> & { readonly _tag: Key } } | ||
} | ||
/** | ||
* Provides a constructor for a Case Class. | ||
* | ||
* @since 1.0.0 | ||
* @category constructors | ||
*/ | ||
export const Class = <A extends Record<string, any>>() => { | ||
class Base { | ||
constructor(args: Omit<A, keyof Equal.Equal>) { | ||
Object.assign(this, args) | ||
unsafeStruct(this) | ||
} | ||
} | ||
return Base as unknown as { new(args: Omit<A, keyof Equal.Equal>): Data<A> } | ||
} |
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
1589251
33575