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

immutable-lens

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-lens - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

lib/AbstractLens.d.ts
import { FieldUpdates, FieldValues, Lens, NotAnArray, Update } from './Lens';
export declare abstract class AbstractLens<T, Target> implements Lens<T, Target> {
readonly abstract path: string;
abstract focusOn<K extends keyof Target>(this: Lens<T, Target & NotAnArray>, key: K): Lens<T, Target[K]>;

@@ -7,3 +8,2 @@ abstract focusIndex<Item>(this: Lens<T, Item[]>, index: number): Lens<T, Item | undefined>;

abstract setValue(newValue: Target): Update<T>;
abstract getPath(): string;
abstract defaultTo<SafeTarget>(this: Lens<T, SafeTarget | undefined>, value: SafeTarget): Lens<T, SafeTarget>;

@@ -10,0 +10,0 @@ abstract throwIfUndefined<SafeTarget extends Target>(this: Lens<T, SafeTarget | undefined>): Lens<T, SafeTarget>;

@@ -7,2 +7,3 @@ import { Lens, NotAnArray, Update } from './Lens';

constructor(parentLens: Lens<T, Target | undefined>, defaultValue: Target);
readonly path: string;
focusOn<K extends keyof Target>(this: Lens<T, Target & NotAnArray>, key: K): Lens<T, Target[K]>;

@@ -12,5 +13,4 @@ focusIndex<Item>(this: Lens<T, Item[]>, index: number): Lens<T, Item | undefined>;

setValue(newValue: Target): Update<T>;
getPath(): string;
defaultTo<SafeTarget>(this: DefaultValueLens<T, SafeTarget | undefined>, value: SafeTarget): Lens<T, SafeTarget>;
throwIfUndefined<SafeTarget extends Target>(this: Lens<T, SafeTarget | undefined>): Lens<T, SafeTarget>;
}

@@ -25,2 +25,9 @@ "use strict";

}
Object.defineProperty(DefaultValueLens.prototype, "path", {
get: function () {
return this.parentLens.path + '?.defaultTo(' + JSON.stringify(this.defaultValue) + ')';
},
enumerable: true,
configurable: true
});
DefaultValueLens.prototype.focusOn = function (key) {

@@ -42,5 +49,2 @@ return new KeyFocusedLens_1.KeyFocusedLens(this, key);

};
DefaultValueLens.prototype.getPath = function () {
return this.parentLens.getPath() + '?.defaultTo(' + JSON.stringify(this.defaultValue) + ')';
};
DefaultValueLens.prototype.defaultTo = function (value) {

@@ -47,0 +51,0 @@ return new DefaultValueLens(this.parentLens, value);

@@ -7,2 +7,3 @@ import { FieldUpdates, FieldValues, Lens, Update } from './Lens';

constructor(parentLens: Lens<T, Item[]>, index: number);
readonly path: string;
focusOn<K extends keyof Item>(key: K): Lens<T, Item[K]>;

@@ -14,5 +15,4 @@ focusIndex<Item>(index: number): Lens<T, Item | undefined>;

updateFields(fields: FieldUpdates<Item>): Update<T>;
getPath(): string;
defaultTo<SafeTarget>(this: Lens<T, SafeTarget | undefined>, value: SafeTarget): Lens<T, SafeTarget>;
throwIfUndefined<SafeTarget>(this: Lens<T, SafeTarget | undefined>): Lens<T, SafeTarget>;
}

@@ -24,2 +24,9 @@ "use strict";

}
Object.defineProperty(IndexFocusedLens.prototype, "path", {
get: function () {
return this.parentLens.path + ("[" + this.index + "]");
},
enumerable: true,
configurable: true
});
IndexFocusedLens.prototype.focusOn = function (key) {

@@ -51,5 +58,2 @@ throw Error('Can NOT focus on a property of a possibly undefined value');

};
IndexFocusedLens.prototype.getPath = function () {
return this.parentLens.getPath() + ("[" + this.index + "]");
};
IndexFocusedLens.prototype.defaultTo = function (value) {

@@ -56,0 +60,0 @@ return new DefaultValueLens_1.DefaultValueLens(this, value);

@@ -7,2 +7,3 @@ import { Lens, NotAnArray, Update } from './Lens';

constructor(parentLens: Lens<T, ParentTarget>, key: K);
readonly path: string;
focusOn<K extends keyof Target>(this: Lens<T, Target & NotAnArray>, key: K): Lens<T, Target[K]>;

@@ -12,5 +13,4 @@ focusIndex<Item>(this: Lens<T, Item[]>, index: number): Lens<T, Item | undefined>;

setValue(newValue: Target): Update<T>;
getPath(): string;
defaultTo<SafeTarget>(this: Lens<T, SafeTarget | undefined>, value: SafeTarget): Lens<T, SafeTarget>;
throwIfUndefined<SafeTarget>(this: Lens<T, SafeTarget | undefined>): Lens<T, SafeTarget>;
}

@@ -33,2 +33,9 @@ "use strict";

}
Object.defineProperty(KeyFocusedLens.prototype, "path", {
get: function () {
return this.parentLens.path + '.' + this.key;
},
enumerable: true,
configurable: true
});
KeyFocusedLens.prototype.focusOn = function (key) {

@@ -54,5 +61,2 @@ return new KeyFocusedLens(this, key);

};
KeyFocusedLens.prototype.getPath = function () {
return this.parentLens.getPath() + '.' + this.key;
};
KeyFocusedLens.prototype.defaultTo = function (value) {

@@ -59,0 +63,0 @@ return new DefaultValueLens_1.DefaultValueLens(this, value);

@@ -12,2 +12,3 @@ export interface NotAnArray {

export interface Lens<T, Target> {
readonly path: string;
focusOn<K extends keyof Target>(this: Lens<T, Target & NotAnArray>, key: K): Lens<T, Target[K]>;

@@ -21,3 +22,2 @@ focusIndex<Item>(this: Lens<T, Item[]>, index: number): Lens<T, Item | undefined>;

pipe(...updates: Update<Target>[]): Update<T>;
getPath(): string;
defaultTo<SafeTarget extends Target>(this: Lens<T, SafeTarget | undefined>, value: SafeTarget): Lens<T, SafeTarget>;

@@ -24,0 +24,0 @@ throwIfUndefined<SafeTarget extends Target>(this: Lens<T, SafeTarget | undefined>): Lens<T, SafeTarget>;

import { FieldUpdates, FieldValues, Lens, UnfocusedLens, Update } from './Lens';
export declare class RootLens<T extends object> implements UnfocusedLens<T> {
readonly path: string;
focusOn<K extends keyof T>(key: K): Lens<T, T[K]>;

@@ -11,5 +12,4 @@ focusIndex<Item>(this: Lens<T, Item[]>, index: number): Lens<T, Item | undefined>;

pipe(...updates: Update<T>[]): Update<T>;
getPath(): string;
defaultTo<SafeTarget>(value: SafeTarget): Lens<T, SafeTarget>;
throwIfUndefined<SafeTarget>(): Lens<T, SafeTarget>;
}

@@ -11,2 +11,9 @@ "use strict";

}
Object.defineProperty(RootLens.prototype, "path", {
get: function () {
return 'source';
},
enumerable: true,
configurable: true
});
RootLens.prototype.focusOn = function (key) {

@@ -40,5 +47,2 @@ return new KeyFocusedLens_1.KeyFocusedLens(this, key);

};
RootLens.prototype.getPath = function () {
return 'source';
};
// TODO Support optional types

@@ -45,0 +49,0 @@ RootLens.prototype.defaultTo = function (value) {

@@ -6,2 +6,3 @@ import { Lens, NotAnArray, Update } from './Lens';

constructor(parentLens: Lens<T, Target | undefined>);
readonly path: string;
focusOn<K extends keyof Target>(this: Lens<T, Target & NotAnArray>, key: K): Lens<T, Target[K]>;

@@ -11,5 +12,4 @@ focusIndex<Item>(this: Lens<T, Item[]>, index: number): Lens<T, Item | undefined>;

setValue(newValue: Target): Update<T>;
getPath(): string;
defaultTo<SafeTarget>(this: ThrowIfUndefinedLens<T, SafeTarget | undefined>, value: SafeTarget): Lens<T, SafeTarget>;
throwIfUndefined<SafeTarget>(this: Lens<T, SafeTarget>): Lens<T, SafeTarget>;
}

@@ -24,2 +24,9 @@ "use strict";

}
Object.defineProperty(ThrowIfUndefinedLens.prototype, "path", {
get: function () {
return this.parentLens.path + '?.throwIfUndefined';
},
enumerable: true,
configurable: true
});
ThrowIfUndefinedLens.prototype.focusOn = function (key) {

@@ -41,5 +48,2 @@ return new KeyFocusedLens_1.KeyFocusedLens(this, key);

};
ThrowIfUndefinedLens.prototype.getPath = function () {
return this.parentLens.getPath() + '?.throwIfUndefined';
};
ThrowIfUndefinedLens.prototype.defaultTo = function (value) {

@@ -46,0 +50,0 @@ return new DefaultValueLens_1.DefaultValueLens(this.parentLens, value);

{
"name": "immutable-lens",
"version": "0.0.4",
"version": "0.0.5",
"description": "Type-safe Lens API for immutable updates in complex data structures",

@@ -5,0 +5,0 @@ "keywords": [

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

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