New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

value-enhancer

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

value-enhancer - npm Package Compare versions

Comparing version 5.1.1 to 5.1.2

dist/chunk-FXWLBBPT.mjs

12

dist/collections.d.ts

@@ -233,2 +233,8 @@ import { R as ReadonlyVal } from './typings-2bae36c2.js';

* A callback function that will be called when an entry is deleted.
*
* Entries are considered deleted from the map when:
* - `map.delete()` or `map.batchDelete()` entries.
* - `map.set()`, `map.batchSet()` or `map.replace()` causing old entries being deleted.
* - `map.clear()` is called.
* - `map.dispose()` is called.
*/

@@ -299,2 +305,8 @@ onDeleted?: (value: TValue, key: TKey) => void;

* A callback function that will be called when an entry is deleted.
*
* Entries are considered deleted from the set when:
* - `set.delete()` or `set.batchDelete()` entries.
* - `set.add()`, `set.batchAdd()` or `set.replace()` causing old entries being deleted.
* - `set.clear()` is called.
* - `set.dispose()` is called.
*/

@@ -301,0 +313,0 @@ onDeleted?: (value: TValue) => void;

56

dist/collections.js
'use strict';
var chunkL3WKSUSX_js = require('./chunk-L3WKSUSX.js');
var chunkLU5CXO64_js = require('./chunk-LU5CXO64.js');

@@ -8,3 +8,3 @@ // src/collections/list.ts

constructor(items) {
const [$, set$] = chunkL3WKSUSX_js.readonlyVal(
const [$, set$] = chunkLU5CXO64_js.readonlyVal(
items ? [...items] : [],

@@ -92,3 +92,3 @@ { equal: false }

set(index, item) {
if (index >= 0 && this.array[index] !== item) {
if (index >= 0 && !chunkLU5CXO64_js.strictEqual(this.array[index], item)) {
this.array[index] = item;

@@ -102,3 +102,3 @@ this.#notify();

for (const [index, item] of entries) {
if (index >= 0 && this.array[index] !== item) {
if (index >= 0 && !chunkLU5CXO64_js.strictEqual(this.array[index], item)) {
isDirty = true;

@@ -183,3 +183,3 @@ this.array[index] = item;

}
const [$, set$] = chunkL3WKSUSX_js.readonlyVal(this, { equal: false });
const [$, set$] = chunkLU5CXO64_js.readonlyVal(this, { equal: false });
this.$ = $;

@@ -228,4 +228,5 @@ this.#notify = () => set$(this);

if (this.#onDeleted) {
for (const [key, value] of this) {
super.delete(key);
const deleted = [...this];
super.clear();
for (const [key, value] of deleted) {
this.#onDeleted(value, key);

@@ -239,6 +240,19 @@ }

}
#set(key, value) {
if (this.has(key)) {
const oldValue = this.get(key);
if (chunkLU5CXO64_js.strictEqual(oldValue, value)) {
return false;
}
super.set(key, value);
if (this.#onDeleted) {
this.#onDeleted(oldValue, key);
}
} else {
super.set(key, value);
}
return true;
}
set(key, value) {
const isDirty = !this.has(key) || this.get(key) !== value;
super.set(key, value);
if (isDirty) {
if (this.#set(key, value)) {
this.#notify();

@@ -251,4 +265,3 @@ }

for (const [key, value] of entries) {
isDirty = isDirty || !this.has(key) || this.get(key) !== value;
super.set(key, value);
isDirty = this.#set(key, value) || isDirty;
}

@@ -270,3 +283,3 @@ if (isDirty) {

}
if (isDirty || oldMap.size !== this.size) {
if (isDirty || deleted.size > 0) {
if (this.#onDeleted) {

@@ -306,3 +319,3 @@ for (const [key, value] of deleted) {

}
const [$, set$] = chunkL3WKSUSX_js.readonlyVal(this, { equal: false });
const [$, set$] = chunkLU5CXO64_js.readonlyVal(this, { equal: false });
this.$ = $;

@@ -344,4 +357,5 @@ this.#notify = () => set$(this);

if (this.#onDeleted) {
for (const value of this) {
super.delete(value);
const deleted = [...this];
super.clear();
for (const value of deleted) {
this.#onDeleted(value);

@@ -356,7 +370,7 @@ }

add(value) {
const isDirty = !this.has(value);
if (this.has(value)) {
return this;
}
super.add(value);
if (isDirty) {
this.#notify();
}
this.#notify();
return this;

@@ -383,3 +397,3 @@ }

for (const item of items) {
isDirty = deleted.delete(item) || isDirty;
isDirty = !deleted.delete(item) || isDirty;
super.add(item);

@@ -386,0 +400,0 @@ }

'use strict';
var chunkL3WKSUSX_js = require('./chunk-L3WKSUSX.js');
var chunkLU5CXO64_js = require('./chunk-LU5CXO64.js');
// src/from.ts
var FromImpl = class extends chunkL3WKSUSX_js.ReadonlyValImpl {
var FromImpl = class extends chunkLU5CXO64_js.ReadonlyValImpl {
constructor(getValue, listen, config) {
let currentValue = chunkL3WKSUSX_js.INIT_VALUE;
let currentValue = chunkLU5CXO64_js.INIT_VALUE;
let dirty = false;
let notified = false;
const get = () => {
if (currentValue === chunkL3WKSUSX_js.INIT_VALUE || subs.s <= 0) {
if (currentValue === chunkLU5CXO64_js.INIT_VALUE || subs.s <= 0) {
currentValue = getValue();

@@ -33,3 +33,3 @@ subs.w(config, currentValue);

};
const subs = new chunkL3WKSUSX_js.Subscribers(get, (subs2) => {
const subs = new chunkLU5CXO64_js.Subscribers(get, (subs2) => {
const disposer = listen(notify);

@@ -51,3 +51,3 @@ currentValue = getValue();

// src/combine.ts
function combine(valInputs, transform = chunkL3WKSUSX_js.identity, config) {
function combine(valInputs, transform = chunkLU5CXO64_js.identity, config) {
let cachedValue;

@@ -57,6 +57,6 @@ let cachedSrcVersions;

() => {
const versions = valInputs.map(chunkL3WKSUSX_js.getValVersion);
if (!cachedSrcVersions || !chunkL3WKSUSX_js.arrayShallowEqual(versions, cachedSrcVersions)) {
const versions = valInputs.map(chunkLU5CXO64_js.getValVersion);
if (!cachedSrcVersions || !chunkLU5CXO64_js.arrayShallowEqual(versions, cachedSrcVersions)) {
cachedSrcVersions = versions;
cachedValue = transform(chunkL3WKSUSX_js.getValues(valInputs));
cachedValue = transform(chunkLU5CXO64_js.getValues(valInputs));
}

@@ -67,3 +67,3 @@ return cachedValue;

const disposers = valInputs.map((val2) => val2.$valCompute(notify));
return () => disposers.forEach(chunkL3WKSUSX_js.invoke);
return () => disposers.forEach(chunkLU5CXO64_js.invoke);
},

@@ -75,9 +75,9 @@ config

// src/derive.ts
function derive(val2, transform = chunkL3WKSUSX_js.identity, config) {
function derive(val2, transform = chunkLU5CXO64_js.identity, config) {
let cachedValue;
let cachedSrcVersion = chunkL3WKSUSX_js.INIT_VALUE;
let cachedSrcVersion = chunkLU5CXO64_js.INIT_VALUE;
return from(
() => {
const version = val2.$version;
if (!chunkL3WKSUSX_js.strictEqual(version, cachedSrcVersion)) {
if (!chunkLU5CXO64_js.strictEqual(version, cachedSrcVersion)) {
cachedSrcVersion = version;

@@ -94,6 +94,6 @@ cachedValue = transform(val2.value);

// src/flatten-from.ts
var FlattenFromImpl = class extends chunkL3WKSUSX_js.ReadonlyValImpl {
var FlattenFromImpl = class extends chunkLU5CXO64_js.ReadonlyValImpl {
constructor(getValue, listen, config) {
const initialEqual = config?.equal;
let currentValue = chunkL3WKSUSX_js.INIT_VALUE;
let currentValue = chunkLU5CXO64_js.INIT_VALUE;
let dirty = false;

@@ -111,3 +111,3 @@ let notified = false;

const get = () => {
if (currentValue === chunkL3WKSUSX_js.INIT_VALUE || subs.s <= 0) {
if (currentValue === chunkLU5CXO64_js.INIT_VALUE || subs.s <= 0) {
currentValue = computeValue();

@@ -128,8 +128,8 @@ subs.w(config, currentValue);

const maybeVal = getValue();
if (maybeVal !== innerMaybeVal) {
if (!chunkLU5CXO64_js.strictEqual(maybeVal, innerMaybeVal)) {
innerMaybeVal = maybeVal;
innerVal = chunkL3WKSUSX_js.isVal(maybeVal) ? maybeVal : null;
innerVal = chunkLU5CXO64_js.isVal(maybeVal) ? maybeVal : null;
innerDisposer?.();
innerDisposer = innerVal && innerVal.$valCompute(notify);
this.$equal = initialEqual || (initialEqual === false ? void 0 : innerVal ? innerVal.$equal : chunkL3WKSUSX_js.strictEqual);
this.$equal = initialEqual || (initialEqual === false ? void 0 : innerVal ? innerVal.$equal : chunkLU5CXO64_js.strictEqual);
}

@@ -144,3 +144,3 @@ };

};
const subs = new chunkL3WKSUSX_js.Subscribers(get, (subs2) => {
const subs = new chunkLU5CXO64_js.Subscribers(get, (subs2) => {
const outerDisposer = listen(() => {

@@ -169,3 +169,3 @@ updateInnerVal();

// src/flatten.ts
function flatten(val2, get = chunkL3WKSUSX_js.identity, config) {
function flatten(val2, get = chunkLU5CXO64_js.identity, config) {
return flattenFrom(

@@ -179,7 +179,7 @@ () => get(val2.value),

// src/val.ts
var ValImpl = class extends chunkL3WKSUSX_js.ReadonlyValImpl {
var ValImpl = class extends chunkLU5CXO64_js.ReadonlyValImpl {
#config;
constructor(currentValue, config) {
const get = () => currentValue;
const subs = new chunkL3WKSUSX_js.Subscribers(get);
const subs = new chunkLU5CXO64_js.Subscribers(get);
super(subs, config);

@@ -204,6 +204,6 @@ this.#config = config;

ref(writable) {
return writable ? new ValRefImpl(this, this.#config) : new chunkL3WKSUSX_js.ReadonlyValRefImpl(this, this.#config);
return writable ? new ValRefImpl(this, this.#config) : new chunkLU5CXO64_js.ReadonlyValRefImpl(this, this.#config);
}
};
var ValRefImpl = class extends chunkL3WKSUSX_js.ReadonlyValRefImpl {
var ValRefImpl = class extends chunkLU5CXO64_js.ReadonlyValRefImpl {
#source$;

@@ -225,3 +225,3 @@ #config;

ref(writable) {
return writable ? new ValRefImpl(this.#source$, this.#config) : new chunkL3WKSUSX_js.ReadonlyValRefImpl(this.#source$, this.#config);
return writable ? new ValRefImpl(this.#source$, this.#config) : new chunkLU5CXO64_js.ReadonlyValRefImpl(this.#source$, this.#config);
}

@@ -241,27 +241,27 @@ };

enumerable: true,
get: function () { return chunkL3WKSUSX_js.arrayShallowEqual; }
get: function () { return chunkLU5CXO64_js.arrayShallowEqual; }
});
Object.defineProperty(exports, 'groupVals', {
enumerable: true,
get: function () { return chunkL3WKSUSX_js.groupVals; }
get: function () { return chunkLU5CXO64_js.groupVals; }
});
Object.defineProperty(exports, 'identity', {
enumerable: true,
get: function () { return chunkL3WKSUSX_js.identity; }
get: function () { return chunkLU5CXO64_js.identity; }
});
Object.defineProperty(exports, 'isVal', {
enumerable: true,
get: function () { return chunkL3WKSUSX_js.isVal; }
get: function () { return chunkLU5CXO64_js.isVal; }
});
Object.defineProperty(exports, 'nextTick', {
enumerable: true,
get: function () { return chunkL3WKSUSX_js.nextTick; }
get: function () { return chunkLU5CXO64_js.nextTick; }
});
Object.defineProperty(exports, 'readonlyVal', {
enumerable: true,
get: function () { return chunkL3WKSUSX_js.readonlyVal; }
get: function () { return chunkLU5CXO64_js.readonlyVal; }
});
Object.defineProperty(exports, 'strictEqual', {
enumerable: true,
get: function () { return chunkL3WKSUSX_js.strictEqual; }
get: function () { return chunkLU5CXO64_js.strictEqual; }
});

@@ -268,0 +268,0 @@ exports.combine = combine;

{
"name": "value-enhancer",
"version": "5.1.1",
"version": "5.1.2",
"private": false,

@@ -44,13 +44,2 @@ "description": "A tiny library to enhance value with reactive wrapper.",

],
"scripts": {
"prepublishOnly": "pnpm run build",
"lint": "eslint --ext .ts,.tsx . && prettier --check . && tsc --noEmit",
"test": "tsc --noEmit -p ./test/tsconfig.json && jest",
"docs": "typedoc --options typedoc.json",
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --jsx react --esModuleInterop --outDir dist",
"build": "cross-env NODE_ENV=production tsup-node",
"build:min": "cross-env NODE_ENV=production MINIFY=true tsup-node && node scripts/gzip.mjs",
"build:dev": "cross-env NODE_ENV=development tsup-node src/index.ts",
"release": "standard-version"
},
"devDependencies": {

@@ -74,3 +63,13 @@ "@jest/globals": "^29.5.0",

"yoctocolors": "^1.0.0"
},
"scripts": {
"lint": "eslint --ext .ts,.tsx . && prettier --check . && tsc --noEmit",
"test": "tsc --noEmit -p ./test/tsconfig.json && jest",
"docs": "typedoc --options typedoc.json",
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --jsx react --esModuleInterop --outDir dist",
"build": "cross-env NODE_ENV=production tsup-node",
"build:min": "cross-env NODE_ENV=production MINIFY=true tsup-node && node scripts/gzip.mjs",
"build:dev": "cross-env NODE_ENV=development tsup-node src/index.ts",
"release": "standard-version"
}
}
}
import { readonlyVal } from "../readonly-val";
import type { ReadonlyVal } from "../typings";
import { strictEqual } from "../utils";

@@ -334,3 +335,3 @@ /**

public set(index: number, item: TValue): this {
if (index >= 0 && this.array[index] !== item) {
if (index >= 0 && !strictEqual(this.array[index], item)) {
(this.array as TValue[])[index] = item;

@@ -345,3 +346,3 @@ this.#notify();

for (const [index, item] of entries) {
if (index >= 0 && this.array[index] !== item) {
if (index >= 0 && !strictEqual(this.array[index], item)) {
isDirty = true;

@@ -348,0 +349,0 @@ (this.array as TValue[])[index] = item;

import { readonlyVal } from "../readonly-val";
import type { ReadonlyVal } from "../typings";
import { strictEqual } from "../utils";

@@ -65,2 +66,8 @@ /**

* A callback function that will be called when an entry is deleted.
*
* Entries are considered deleted from the map when:
* - `map.delete()` or `map.batchDelete()` entries.
* - `map.set()`, `map.batchSet()` or `map.replace()` causing old entries being deleted.
* - `map.clear()` is called.
* - `map.dispose()` is called.
*/

@@ -136,4 +143,5 @@ onDeleted?: (value: TValue, key: TKey) => void;

if (this.#onDeleted) {
for (const [key, value] of this) {
super.delete(key);
const deleted = [...this];
super.clear();
for (const [key, value] of deleted) {
this.#onDeleted(value, key);

@@ -148,6 +156,20 @@ }

#set(key: TKey, value: TValue): boolean {
if (this.has(key)) {
const oldValue = this.get(key)!;
if (strictEqual(oldValue, value)) {
return false;
}
super.set(key, value);
if (this.#onDeleted) {
this.#onDeleted(oldValue, key);
}
} else {
super.set(key, value);
}
return true;
}
public override set(key: TKey, value: TValue): this {
const isDirty = !this.has(key) || this.get(key) !== value;
super.set(key, value);
if (isDirty) {
if (this.#set(key, value)) {
this.#notify();

@@ -161,4 +183,3 @@ }

for (const [key, value] of entries) {
isDirty = isDirty || !this.has(key) || this.get(key) !== value;
super.set(key, value);
isDirty = this.#set(key, value) || isDirty;
}

@@ -184,3 +205,3 @@ if (isDirty) {

if (isDirty || oldMap.size !== this.size) {
if (isDirty || deleted.size > 0) {
if (this.#onDeleted) {

@@ -187,0 +208,0 @@ for (const [key, value] of deleted) {

@@ -64,2 +64,8 @@ import { readonlyVal } from "../readonly-val";

* A callback function that will be called when an entry is deleted.
*
* Entries are considered deleted from the set when:
* - `set.delete()` or `set.batchDelete()` entries.
* - `set.add()`, `set.batchAdd()` or `set.replace()` causing old entries being deleted.
* - `set.clear()` is called.
* - `set.dispose()` is called.
*/

@@ -128,4 +134,5 @@ onDeleted?: (value: TValue) => void;

if (this.#onDeleted) {
for (const value of this) {
super.delete(value);
const deleted = [...this];
super.clear();
for (const value of deleted) {
this.#onDeleted(value);

@@ -141,7 +148,7 @@ }

public override add(value: TValue): this {
const isDirty = !this.has(value);
if (this.has(value)) {
return this;
}
super.add(value);
if (isDirty) {
this.#notify();
}
this.#notify();
return this;

@@ -171,3 +178,3 @@ }

for (const item of items) {
isDirty = deleted.delete(item) || isDirty;
isDirty = !deleted.delete(item) || isDirty;
super.add(item);

@@ -184,2 +191,3 @@ }

}
return deleted.values();

@@ -186,0 +194,0 @@ }

@@ -57,3 +57,3 @@ import type {

const maybeVal = getValue();
if (maybeVal !== innerMaybeVal) {
if (!strictEqual(maybeVal, innerMaybeVal)) {
innerMaybeVal = maybeVal;

@@ -60,0 +60,0 @@ innerVal = isVal(maybeVal)

@@ -21,3 +21,3 @@ import type { ReadonlyVal, ValInputsValueTuple, ValVersion } from "./typings";

export const arrayShallowEqual = (arrA: any, arrB: any): boolean => {
if (arrA === arrB) {
if (strictEqual(arrA, arrB)) {
return true;

@@ -24,0 +24,0 @@ }

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