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.3.1 to 0.3.2

lib/cherryPick.d.ts.map

1

lib/cherryPick.d.ts
import { FieldLenses } from './Lens';
export declare function cherryPick<Source extends object, Composition>(source: Source, fields: FieldLenses<Source, Composition>): Composition;
//# sourceMappingURL=cherryPick.d.ts.map
import { UnfocusedLens } from './Lens';
export declare function createLens<T extends {}>(instance?: T): UnfocusedLens<T>;
//# sourceMappingURL=createLens.d.ts.map

9

lib/ImmutableLens.d.ts

@@ -8,3 +8,3 @@ import { FieldLenses, FieldsUpdater, FieldUpdaters, FieldValues, Lens, UnfocusedLens, Updater } from './Lens';

THROW_IF_UNDEFINED = 4,
RECOMPOSED = 5,
RECOMPOSED = 5
}

@@ -20,3 +20,3 @@ export declare class ImmutableLens<Source, ParentTarget, Target> implements Lens<Source, Target> {

read(source: Source): Target;
private focusOn<K>(this, key);
private focusOn;
focus<NewTarget>(get: (value: Target) => NewTarget, set: (newValue: NewTarget) => Updater<Target>): Lens<Source, NewTarget>;

@@ -31,7 +31,7 @@ focusPath(...keys: any[]): any;

setValue(): (newValue: Target) => Updater<Source>;
private setValueUpdater(value);
private setValueUpdater;
update(updater: Updater<Target>): Updater<Source>;
setFields(newValues: FieldValues<Target>): Updater<Source>;
setFields(): (newValues: FieldValues<Target>) => Updater<Source>;
private setFieldsUpdater(newValues);
private setFieldsUpdater;
updateFields(updaters: FieldUpdaters<Target>): Updater<Source>;

@@ -41,1 +41,2 @@ updatePartial(fieldsUpdater: FieldsUpdater<Target>): Updater<Source>;

}
//# sourceMappingURL=ImmutableLens.d.ts.map

@@ -36,4 +36,4 @@ "use strict";

return new ImmutableLens(this.path + '.' + key, LensType.KEY_FOCUSED, function (source) { return _this.read(source); }, function (target) { return target[key]; }, function (newValue) { return function (target) {
var _a;
return setFieldValues_1.setFieldValues(target, (_a = {}, _a[key] = newValue, _a));
var _a;
}; }, function (target) { return _this.setValue(target); });

@@ -40,0 +40,0 @@ };

@@ -5,1 +5,2 @@ export * from './Lens';

export { cherryPick } from './cherryPick';
//# sourceMappingURL=index.d.ts.map

@@ -40,1 +40,2 @@ export interface NotAnArray {

}
//# sourceMappingURL=Lens.d.ts.map
import { Updater } from './Lens';
export declare function pipeUpdaters<T>(...updaters: Array<Updater<T>>): Updater<T>;
//# sourceMappingURL=pipeUpdaters.d.ts.map
import { FieldValues } from './Lens';
export declare function setFieldValues<T>(source: T, fieldValues: FieldValues<T>): T;
//# sourceMappingURL=setFieldValues.d.ts.map
import { FieldUpdaters } from './Lens';
export declare function updateFields<T, Target>(source: T, fieldUpdaters: FieldUpdaters<Target>): T;
//# sourceMappingURL=updateFields.d.ts.map
{
"name": "immutable-lens",
"version": "0.3.1",
"version": "0.3.2",
"description": "Type-safe Lens API for immutable updates in complex data structures",

@@ -41,16 +41,16 @@ "keywords": [

"@types/chai": "^4.1.3",
"@types/mocha": "^5.2.0",
"@types/mocha": "^5.2.1",
"chai": "^4.1.2",
"chalk": "^2.4.1",
"glob-promise": "^3.4.0",
"mocha": "^5.1.1",
"prettier": "^1.12.1",
"mocha": "^5.2.0",
"prettier": "^1.13.4",
"ramda": "^0.25.0",
"shx": "^0.2.2",
"ts-node": "^6.0.3",
"ts-node": "^6.1.0",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.12.0",
"tslint-config-prettier": "^1.13.0",
"tslint-plugin-prettier": "^1.3.0",
"typescript": "^2.8.3"
"typescript": "^2.9.1"
}
}

@@ -20,5 +20,5 @@ # immutable-lens

#### Example
#### Create lens
```typescript
import {createLens} from 'lib'
import {createLens} from 'immutable-lens'

@@ -32,15 +32,13 @@ type State = {

const lens = createLens<State>()
```
////////////
// FOCUS //
//////////
const userLens = lens.focusOn('user')
const nameLens = userLens.focusOn('name')
#### Focus
```typescript
const userLens = lens.focusPath('user')
const nameLens = userLens.focusPath('name')
const ageLens = lens.focusPath('user', 'age')
```
///////////
// READ //
/////////
#### Read
```typescript
const state: State = {

@@ -55,13 +53,13 @@ user: {

nameLens.read(state) // 'Bob'
```
/////////////
// UPDATE //
///////////
#### Update
```typescript
const setNameToJohn =
// THE FOUR LINES BELOW WILL ALL HAVE THE SAME EFFECT
// THE FIVE LINES BELOW ARE ALL EQUIVALENT
nameLens.setValue('John')
nameLens.update(currentName => 'John')
userLens.setFieldValues({name: 'John'})
userLens.setFields({name: 'John'})
userLens.updateFields({name: (currentName) => 'John'})
userLens.updatePartial(user => ({name: 'John'}))

@@ -73,3 +71,3 @@ setNameToJohn(state) // {user: {name: 'John', age: 18}}

```typescript
import {createLens, pipeUpdaters} from 'lib'
import {createLens, pipeUpdaters} from 'immutable-lens'

@@ -103,3 +101,3 @@ type State = {

```typescript
import {createLens} from 'lib'
import {createLens} from 'immutable-lens'

@@ -130,3 +128,3 @@ type State = {

```typescript
import {Lens, createLens} from 'lib'
import {Lens, createLens} from 'immutable-lens'

@@ -148,5 +146,5 @@ type Person = {

#### Compose Lenses
<!-- #### Compose Lenses
```typescript
import {createLens, createComposedLens} from 'lib'
import {createLens, createComposedLens} from 'immutable-lens'

@@ -165,7 +163,2 @@ type State = {

setImproveReadmeAsFirstTodoItem({todoList: []}) // {todoList: ['Improve README']}
```
#### `getPath()`
```typescript
```
``` -->

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