Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 80e7128

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 87f79fc + feea233 commit 80e7128

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1908
-425
lines changed

.changeset/modern-paws-turn.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ AgileTs is a global State and Logic Library implemented in Typescript.
7979
It offers a reimagined API that focuses on **developer experience**
8080
and allows you to **easily** and **flexible** manage your application States.
8181
Besides [States](https://agile-ts.org/docs/core/state),
82-
AgileTs offers some other powerful APIs that make your life easier,
82+
AgileTs offers some other powerful and tree shakable APIs that make your life easier,
8383
such as [Collections](https://agile-ts.org/docs/core/collection)
8484
and [Computed States](https://agile-ts.org/docs/core/computed).
8585
The philosophy behind AgileTs is simple:

benchmark/benchmarks/react/1000fields/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ suite
8181
.add('Agile State', configTest(agileState))
8282
.add('Agile nested State', configTest(agileNestedState))
8383
.add('Pulse Collection', configTest(pulseCollection))
84-
// .add('Pulse State', configTest(pulseState))
85-
// .add('Pulse nested State', configTest(pulseNestedState))
84+
.add('Pulse State', configTest(pulseState))
85+
.add('Pulse nested State', configTest(pulseNestedState))
8686
.add('Hookstate', configTest(hookstate))
8787
.add('Jotai', configTest(jotai))
8888
.add('Mobx', configTest(mobx))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @ts-ignore
2+
import _ from 'lodash';
3+
4+
export function cloneDeep<T = any>(value: T): T {
5+
return _.cloneDeep(value);
6+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export function cloneDeep<T = any>(value: T): T {
2+
// Extra checking 'value == null' because 'typeof null === object'
3+
if (value == null || typeof value !== 'object') return value;
4+
5+
// Ignore everything that is no object or array but has the type of an object (e.g. classes)
6+
const valConstructorName = Object.getPrototypeOf(
7+
value
8+
).constructor.name.toLowerCase();
9+
if (valConstructorName !== 'object' && valConstructorName !== 'array')
10+
return value;
11+
12+
let temp;
13+
const newObject: any = Array.isArray(value) ? [] : {};
14+
for (const property in value) {
15+
temp = value[property];
16+
newObject[property] = cloneDeep(temp);
17+
}
18+
return newObject as T;
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function cloneDeep<T = any>(value: T): T {
2+
return JSON.parse(JSON.stringify(value));
3+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import Benchmark, { Suite } from 'benchmark';
2+
import {
3+
cycleLog,
4+
CycleResultInterface,
5+
endBenchmarkLog,
6+
getCycleResult,
7+
startBenchmarkLog,
8+
} from '../../benchmarkManager';
9+
10+
// Files to run the Benchmark on
11+
import * as lodash from './bench/lodash';
12+
import * as looper from './bench/looper';
13+
import * as stringify from './bench/stringify';
14+
15+
const toClone = { x1: true, x2: undefined };
16+
17+
// @ts-ignore
18+
// Benchmark.js requires an instance of itself globally
19+
window.Benchmark = Benchmark;
20+
21+
// Create new Benchmark Test Suite
22+
const suite = new Suite('clone deep');
23+
24+
const results: CycleResultInterface[] = [];
25+
26+
// Add Tests to the Benchmark Test Suite
27+
suite
28+
.add('Lodash', function () {
29+
lodash.cloneDeep(toClone);
30+
})
31+
.add('Looper', function () {
32+
looper.cloneDeep(toClone);
33+
})
34+
.add('Stringify', function () {
35+
stringify.cloneDeep(toClone);
36+
})
37+
38+
// Add Listener
39+
.on('start', function (this: any) {
40+
startBenchmarkLog(this.name);
41+
})
42+
.on('cycle', (event: any) => {
43+
const cycleResult = getCycleResult(event);
44+
cycleLog(cycleResult);
45+
results.push(cycleResult);
46+
})
47+
.on('complete', function (this: any) {
48+
endBenchmarkLog(this.name, results, this.filter('fastest').map('name'));
49+
50+
// @ts-ignore
51+
// Notify server that the Benchmark Test Suite has ended
52+
window.TEST.ended = true;
53+
})
54+
55+
// Run Benchmark Test Suite
56+
.run({ async: true });

benchmark/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"test:1000fields": "yarn test ./benchmarks/react/1000fields",
1313
"test:computed": "yarn test ./benchmarks/react/computed",
1414
"test:defineConfig": "yarn test ./benchmarks/typescript/defineConfig",
15+
"test:cloneDeep": "yarn test ./benchmarks/typescript/cloneDeep",
1516
"install:dev:agile": "yalc add @agile-ts/core @agile-ts/react & yarn install",
1617
"install:prod:agile": "yarn add @agile-ts/core @agile-ts/react & yarn install"
1718
},
@@ -21,8 +22,9 @@
2122
},
2223
"dependencies": {
2324
"@agile-ts/core": "file:.yalc/@agile-ts/core",
25+
"@agile-ts/logger": "file:.yalc/@agile-ts/logger",
2426
"@agile-ts/react": "file:.yalc/@agile-ts/react",
25-
"@hookstate/core": "^3.0.8",
27+
"@hookstate/core": "^3.0.11",
2628
"@pulsejs/core": "^4.0.0-beta.3",
2729
"@pulsejs/react": "^4.0.0-beta.3",
2830
"@reduxjs/toolkit": "^1.6.0",

benchmark/yarn.lock

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44

55
"@agile-ts/core@file:.yalc/@agile-ts/core":
6-
version "0.2.0-alpha.3"
6+
version "0.2.0-alpha.5"
7+
dependencies:
8+
"@agile-ts/utils" "^0.0.7"
9+
10+
"@agile-ts/logger@file:.yalc/@agile-ts/logger":
11+
version "0.0.7"
712
dependencies:
813
"@agile-ts/utils" "^0.0.7"
914

@@ -22,10 +27,10 @@
2227
dependencies:
2328
regenerator-runtime "^0.13.4"
2429

25-
"@hookstate/core@^3.0.8":
26-
version "3.0.8"
27-
resolved "https://registry.yarnpkg.com/@hookstate/core/-/core-3.0.8.tgz#d6838153d6d43c2f35cfca475c31248192564e62"
28-
integrity sha512-blQagGIVIbNoUiNCRrvaXqFmUe7WGMY35ok/LENfl2pcIsLBjkreYIZiaSFi83tkycwq7ZOmcQz/R1nvLKhH8w==
30+
"@hookstate/core@^3.0.11":
31+
version "3.0.11"
32+
resolved "https://registry.yarnpkg.com/@hookstate/core/-/core-3.0.11.tgz#515f2748b3741f3d7e90cbc1acff8d6ac84e5494"
33+
integrity sha512-cbI711aFWX4d8+xkLxikmLnR+f55ePHrBMWFA4gTLEoCa1+Cg0pfNw7h7zSodYMeYt8Y5A5TVSh7a5p8lBC89A==
2934

3035
"@pulsejs/core@^4.0.0-beta.3":
3136
version "4.0.0-beta.3"

examples/react/develop/fields/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true

0 commit comments

Comments
 (0)