immutable-lens
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -1,2 +0,2 @@ | ||
import { FieldLenses, FieldsUpdater, FieldUpdaters, FieldValues, Lens, NotAnArray, Updater } from './Lens'; | ||
import { FieldLenses, FieldsUpdater, FieldUpdaters, FieldValues, Lens, Updater } from './Lens'; | ||
export declare enum LensType { | ||
@@ -19,3 +19,3 @@ ROOT = 0, | ||
read(source: Source): Target; | ||
focusOn<K extends keyof Target>(this: Lens<Source, Target & NotAnArray>, key: K): Lens<Source, Target[K]>; | ||
private focusOn<K>(this, key); | ||
focus<NewTarget>(get: (value: Target) => NewTarget, set: (newValue: NewTarget) => Updater<Target>): Lens<Source, NewTarget>; | ||
@@ -29,6 +29,6 @@ focusPath(...keys: any[]): any; | ||
update(updater: Updater<Target>): Updater<Source>; | ||
setFieldValues(newValues: FieldValues<Target>): Updater<Source>; | ||
setFields(newValues: FieldValues<Target>): Updater<Source>; | ||
updateFields(updaters: FieldUpdaters<Target>): Updater<Source>; | ||
updateFieldValues(fieldsUpdater: FieldsUpdater<Target>): Updater<Source>; | ||
updatePartial(fieldsUpdater: FieldsUpdater<Target>): Updater<Source>; | ||
pipe(...updaters: Updater<Target>[]): Updater<Source>; | ||
} |
@@ -32,2 +32,3 @@ "use strict"; | ||
////////// | ||
// TODO Remove | ||
ImmutableLens.prototype.focusOn = function (key) { | ||
@@ -44,2 +45,3 @@ var _this = this; | ||
}; | ||
// TODO Better implementation | ||
ImmutableLens.prototype.focusPath = function () { | ||
@@ -91,3 +93,3 @@ var keys = []; | ||
if (lens === undefined) { | ||
throw Error("Property \"" + key + "\" does not exist in recomposed Lens target: { " + Object.keys(fieldLenses).join(', ') + " } (path: " + _this.path + ")"); | ||
throw Error("Property \"" + key + "\" does not exist in recomposed Lens { " + Object.keys(fieldLenses).join(', ') + " }"); | ||
} | ||
@@ -124,3 +126,3 @@ return lens.setValue(fieldValue); | ||
}; | ||
ImmutableLens.prototype.setFieldValues = function (newValues) { | ||
ImmutableLens.prototype.setFields = function (newValues) { | ||
var _this = this; | ||
@@ -149,3 +151,3 @@ var updater = function (source) { | ||
}; | ||
ImmutableLens.prototype.updateFieldValues = function (fieldsUpdater) { | ||
ImmutableLens.prototype.updatePartial = function (fieldsUpdater) { | ||
var _this = this; | ||
@@ -152,0 +154,0 @@ var updater = function (source) { |
@@ -20,3 +20,4 @@ export interface NotAnArray { | ||
focus<NewTarget>(get: (value: Target) => NewTarget, set: (newValue: NewTarget) => Updater<Target>): Lens<Source, NewTarget>; | ||
focusOn<K extends keyof Target>(this: Lens<Source, Target & NotAnArray>, key: K): Lens<Source, Target[K]>; | ||
focusIndex<Item>(this: Lens<Source, Item[]>, index: number): Lens<Source, Item | undefined>; | ||
recompose<Composition>(this: Lens<Source, Target & object & NotAnArray>, fields: FieldLenses<Target, Composition>): Lens<Source, Composition>; | ||
focusPath<K extends keyof Target>(this: Lens<Source, Target & NotAnArray>, key: K): Lens<Source, Target[K]>; | ||
@@ -29,10 +30,8 @@ focusPath<K1 extends keyof Target, K2 extends keyof Target[K1]>(key1: K1, key2: K2): Lens<Source, Target[K1][K2]>; | ||
focusPath<K1 extends keyof Target, K2 extends keyof Target[K1], K3 extends keyof Target[K1][K2], K4 extends keyof Target[K1][K2][K3], K5 extends keyof Target[K1][K2][K3][K4], K6 extends keyof Target[K1][K2][K3][K4][K5], K7 extends keyof Target[K1][K2][K3][K4][K5][K6]>(key1: K1, key2: K2, key3: K3, key4: K4, key5: K5, key6: K6, key7: K7): Lens<Source, Target[K1][K2][K3][K4][K5][K6][K7]>; | ||
focusIndex<Item>(this: Lens<Source, Item[]>, index: number): Lens<Source, Item | undefined>; | ||
recompose<Composition>(this: Lens<Source, Target & object & NotAnArray>, fields: FieldLenses<Target, Composition>): Lens<Source, Composition>; | ||
read(source: Source): Target; | ||
setValue(newValue: Target): Updater<Source>; | ||
update(updater: Updater<Target>): Updater<Source>; | ||
setFieldValues(this: Lens<Source, Target & NotAnArray>, newValues: FieldValues<Target>): Updater<Source>; | ||
setFields(this: Lens<Source, Target & NotAnArray>, newValues: FieldValues<Target>): Updater<Source>; | ||
updateFields(this: Lens<Source, Target & NotAnArray>, updaters: FieldUpdaters<Target>): Updater<Source>; | ||
updateFieldValues(this: Lens<Source, Target & NotAnArray>, fieldsUpdater: FieldsUpdater<Target>): Updater<Source>; | ||
updatePartial(this: Lens<Source, Target & NotAnArray>, fieldsUpdater: FieldsUpdater<Target>): Updater<Source>; | ||
pipe(...updaters: Updater<Target>[]): Updater<Source>; | ||
@@ -39,0 +38,0 @@ defaultTo<SafeTarget extends Target>(this: Lens<Source, SafeTarget | undefined>, value: SafeTarget): Lens<Source, SafeTarget>; |
{ | ||
"name": "immutable-lens", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "Type-safe Lens API for immutable updates in complex data structures", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
"glob-promise": "^3.3.0", | ||
"mocha": "^3.5.3", | ||
"mocha": "^4.0.1", | ||
"ramda": "^0.25.0", | ||
@@ -47,0 +47,0 @@ "shx": "^0.2.2", |
Sorry, the diff of this file is not supported yet
383
36666