Socket
Socket
Sign inDemoInstall

@effect/data

Package Overview
Dependencies
Maintainers
3
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/data - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

6

Data.d.ts

@@ -78,5 +78,5 @@ /**

*/
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;
};
export declare const TaggedClass: <Key extends string>(tag: Key) => <A extends Record<string, any>>() => new (args: Omit<A, keyof Equal.Equal>) => Data<A & {
_tag: Key;
}>;
/**

@@ -83,0 +83,0 @@ * Provides a constructor for a Case Class.

@@ -105,7 +105,6 @@ "use strict";

const TaggedClass = tag => () => {
class Base {
constructor(args) {
class Base extends Class() {
constructor() {
super(...arguments);
this._tag = tag;
Object.assign(this, args);
unsafeStruct(this);
}

@@ -126,4 +125,19 @@ }

Object.assign(this, args);
unsafeStruct(this);
}
[Hash.symbol]() {
return Hash.structure(this);
}
[Equal.symbol](that) {
const selfKeys = Object.keys(this);
const thatKeys = Object.keys(that);
if (selfKeys.length !== thatKeys.length) {
return false;
}
for (const key of selfKeys) {
if (!(key in that && Equal.equals(this[key], that[key]))) {
return false;
}
}
return true;
}
}

@@ -130,0 +144,0 @@ return Base;

{
"name": "@effect/data",
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -139,11 +139,7 @@ /**

) =>
<A extends Record<string, any>>() => {
class Base {
<A extends Record<string, any>>(): new(args: Omit<A, keyof Equal.Equal>) => Data<A & { _tag: Key }> => {
class Base extends (Class<A>() as any) {
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 } }
return Base as any
}

@@ -157,10 +153,26 @@

*/
export const Class = <A extends Record<string, any>>() => {
export const Class = <A extends Record<string, any>>(): new(args: Omit<A, keyof Equal.Equal>) => Data<A> => {
class Base {
constructor(args: Omit<A, keyof Equal.Equal>) {
Object.assign(this, args)
unsafeStruct(this)
}
[Hash.symbol](this: Equal.Equal) {
return Hash.structure(this)
}
[Equal.symbol](this: Equal.Equal, that: Equal.Equal) {
const selfKeys = Object.keys(this)
const thatKeys = Object.keys(that as object)
if (selfKeys.length !== thatKeys.length) {
return false
}
for (const key of selfKeys) {
if (!(key in (that as object) && Equal.equals(this[key], (that as object)[key]))) {
return false
}
}
return true
}
}
return Base as unknown as { new(args: Omit<A, keyof Equal.Equal>): Data<A> }
return Base as any
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc