Skip to content

Commit

Permalink
Fix class support
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaack committed Dec 26, 2017
1 parent 06707dc commit 8329f69
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 93 deletions.
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A statically-typed immutable update helper library.

* Statically-typed
* Support class state
* Using constructor to create new instance
* Class can define a `clone` method to customize shallow clone.

## install

Expand Down Expand Up @@ -99,39 +101,39 @@ state.user instanceof User // true!

```sh
Start Suit: Set 1 key
immutable x 463,347 ops/sec ±17.83% (38 runs sampled)
seamless-immutable x 43,151 ops/sec ±16.57% (43 runs sampled)
timm x 399,784 ops/sec ±10.87% (43 runs sampled)
monolite x 85,844 ops/sec ±13.53% (47 runs sampled)
mutator x 104,687 ops/sec ±24.44% (47 runs sampled)
Fastest is immutable
immutable x 932,328 ops/sec ±14.93% (46 runs sampled)
seamless-immutable x 67,021 ops/sec ±16.99% (44 runs sampled)
timm x 881,627 ops/sec ±17.53% (62 runs sampled)
monolite x 151,347 ops/sec ±13.51% (46 runs sampled)
mutator x 219,049 ops/sec ±5.03% (71 runs sampled)
Fastest is immutable,timm


Start Suit: Set 2 key
immutable x 384,360 ops/sec ±21.31% (27 runs sampled)
seamless-immutable x 16,637 ops/sec ±9.56% (50 runs sampled)
timm x 321,120 ops/sec ±11.68% (40 runs sampled)
monolite x 54,933 ops/sec ±12.02% (49 runs sampled)
mutator x 85,824 ops/sec ±8.92% (58 runs sampled)
Fastest is immutable
immutable x 732,474 ops/sec ±9.49% (57 runs sampled)
seamless-immutable x 28,802 ops/sec ±12.65% (53 runs sampled)
timm x 715,487 ops/sec ±9.31% (55 runs sampled)
monolite x 97,454 ops/sec ±12.41% (55 runs sampled)
mutator x 147,161 ops/sec ±16.37% (53 runs sampled)
Fastest is immutable,timm


Start Suit: Set 5 key
immutable x 178,582 ops/sec ±19.49% (40 runs sampled)
seamless-immutable x 9,104 ops/sec ±12.88% (44 runs sampled)
timm x 183,485 ops/sec ±11.72% (51 runs sampled)
monolite x 34,557 ops/sec ±11.83% (45 runs sampled)
mutator x 47,307 ops/sec ±12.90% (51 runs sampled)
Fastest is timm,immutable
immutable x 374,647 ops/sec ±13.05% (55 runs sampled)
seamless-immutable x 19,725 ops/sec ±8.40% (62 runs sampled)
timm x 217,508 ops/sec ±9.00% (43 runs sampled)
monolite x 80,403 ops/sec ±6.32% (69 runs sampled)
mutator x 111,625 ops/sec ±4.92% (65 runs sampled)
Fastest is immutable


Start Suit: Set 10 key
immutable x 119,701 ops/sec ±13.85% (48 runs sampled)
seamless-immutable x 5,727 ops/sec ±10.60% (46 runs sampled)
timm x 115,028 ops/sec ±15.41% (51 runs sampled)
monolite x 23,343 ops/sec ±15.45% (56 runs sampled)
mutator x 32,228 ops/sec ±9.58% (57 runs sampled)
Fastest is immutable,timm
immutable x 257,998 ops/sec ±4.59% (69 runs sampled)
seamless-immutable x 11,238 ops/sec ±10.45% (59 runs sampled)
timm x 219,370 ops/sec ±8.29% (59 runs sampled)
monolite x 32,778 ops/sec ±7.16% (48 runs sampled)
mutator x 54,496 ops/sec ±8.72% (60 runs sampled)
Fastest is immutable
```

## License
Expand Down
2 changes: 2 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export declare function setCacheSize(maxSize?: number): void;
/**
* Set a deep child
*
* @param record The object to update, it can be a plain object or a class instance
* @param accessor A lambda function to get the key path, support dot, [''], [""], [1], **do not** support dynamic variable, function call, e.g.
* @param value The new value to set, if it is ignored it will be set to undefined.
Expand All @@ -22,6 +23,7 @@ export declare function unsetIn<T, V>(record: T, accessor: ((obj: T) => V | unde
export declare function updateIn<T, V>(record: T, accessor: ((obj: T) => V) | string[], updator?: (v: V) => V): T;
declare const _default: {
setIn: <T, V>(record: T, accessor: string[] | ((obj: T) => V), value?: V | undefined) => T;
unsetIn: <T, V>(record: T, accessor: string[] | ((obj: T) => V | undefined)) => T;
updateIn: <T, V>(record: T, accessor: string[] | ((obj: T) => V), updator?: ((v: V) => V) | undefined) => T;
};
export default _default;
36 changes: 29 additions & 7 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/quicklru.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export declare function assign(obj1: any, obj2: any): any;
export default class QuickLRU {
maxSize: number;
cache: {};
Expand Down
10 changes: 2 additions & 8 deletions lib/quicklru.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/quicklru.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8329f69

Please sign in to comment.