Skip to content

feat(set-map): introduce MutativeMap to optimize for common scenarios (lots of data, little change) #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,9 @@ dist
.tern-port

benchmark.csv

# IntelliJ
/.idea

# MacOS Finder files
.DS_Store
Binary file modified benchmark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
// eslint-disable-next-line no-var
declare var __DEV__: boolean;

export {} // "This does not work without at least one export (or import) keyword. This turns this file into an ES module, which is necessary for this to work. You can export any of the statements or add an empty export {}."

declare global {
/**
* Allow __DEV__ to be used in the code, which is replaced via rollup-plugin-replace in the build process.
* WARNING: if directly executing scripts like the benchmarks via tsx or ts-node, this global variable needs to be set at the start.
* See https://stackoverflow.com/questions/59459312/using-globalthis-in-typescript.
*/
// eslint-disable-next-line no-var
// noinspection ES6ConvertVarToLetConst
var __DEV__: boolean;
}
27 changes: 27 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type {Config} from 'jest';

const config: Config = {
"preset": "ts-jest",
"coveragePathIgnorePatterns": [
"<rootDir>/test/"
],
"transform": {
"\\.[jt]sx?$": [
"ts-jest",
{
"tsconfig": {
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": false,
"noUnusedLocals": false,
"noUnusedParameters": false
}
}
]
},
"globals": {
"__DEV__": true
},
prettierPath: require.resolve('prettier-2'),
};

export default config;
35 changes: 10 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
"benchmark:object": "NODE_ENV='production' ts-node test/performance/benchmark-object.ts",
"benchmark:array": "NODE_ENV='production' ts-node test/performance/benchmark-array.ts",
"benchmark:class": "NODE_ENV='production' ts-node test/performance/benchmark-class.ts",
"benchmark:map": "NODE_ENV='production' ts-node test/benchmark/map.ts",
"benchmark:map-batch": "NODE_ENV='production' ts-node test/benchmark/map-batch.ts",
"performance:read-only": "yarn build && NODE_ENV='production' ts-node test/performance/read-draft/index.ts",
"performance:immer": "cd test/__immer_performance_tests__ && NODE_ENV='production' ts-node add-data.ts && NODE_ENV='production' ts-node todo.ts && NODE_ENV='production' ts-node incremental.ts",
"performance:basic": "cd test/performance && NODE_ENV='production' ts-node index.ts",
"performance:set-map": "cd test/performance && NODE_ENV='production' ts-node set-map.ts",
"performance:mutative-set-map": "cd test/performance && NODE_ENV='production' ts-node mutative-set-map.ts",
"performance:big-object": "cd test/performance && NODE_ENV='production' ts-node big-object.ts",
"performance:sample": "cd test/performance && NODE_ENV='production' ts-node sample.ts",
"performance:array-object": "cd test/performance && NODE_ENV='production' ts-node array-object.ts",
"performance": "yarn build && yarn performance:immer && yarn performance:basic && yarn performance:set-map && yarn performance:big-object && yarn performance:sample && yarn performance:array-object",
"performance": "yarn build && yarn performance:immer && yarn performance:basic && yarn performance:set-map && yarn performance:mutative-set-map && yarn performance:big-object && yarn performance:sample && yarn performance:array-object",
"build": "yarn clean && rollup --config --bundleConfigAsCjs",
"build:doc": "rimraf docs && typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts --readme none",
"commit": "yarn git-cz",
Expand Down Expand Up @@ -85,7 +88,7 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.1",
"@size-limit/esbuild": "^11.1.6",
Expand Down Expand Up @@ -117,12 +120,15 @@
"lodash": "^4.17.21",
"lodash.clonedeep": "^4.5.0",
"prettier": "^3.3.3",
"prettier-2": "npm:prettier@^2",
"pretty-format": "^29.7.0",
"quickchart-js": "^3.1.2",
"redux": "^5.0.1",
"rimraf": "^3.0.2",
"rollup": "^4.9.0",
"rollup": "^4.28.1",
"seamless-immutable": "^7.1.4",
"size-limit": "^11.1.6",
"superjson": "^2.2.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
Expand All @@ -136,26 +142,5 @@
"path": "cz-conventional-changelog"
}
},
"jest": {
"preset": "ts-jest",
"coveragePathIgnorePatterns": [
"<rootDir>/test/"
],
"transform": {
"\\.[jt]sx?$": [
"ts-jest",
{
"tsconfig": {
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": false,
"noUnusedLocals": false,
"noUnusedParameters": false
}
}
]
},
"globals": {
"__DEV__": true
}
}
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
}
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default [
declarationDir: 'dist',
}),
replace({
__DEV__: 'false',
"__DEV__": 'false',
preventAssignment: true,
}),
],
Expand Down Expand Up @@ -76,7 +76,7 @@ export default [
declarationDir: 'dist',
}),
replace({
__DEV__: 'true',
"__DEV__": 'true',
preventAssignment: true,
}),
{
Expand Down
Loading