-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
7a4d7e6
commit e5e5eb0
Showing
10 changed files
with
132 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,33 @@ | ||
declare namespace FastCopy { | ||
export type Realm = Record<string, any>; | ||
|
||
export interface Cache { | ||
_keys?: any[]; | ||
_values?: any[]; | ||
has: (value: any) => boolean; | ||
set: (key: any, value: any) => void; | ||
get: (key: any) => any; | ||
} | ||
|
||
export type Copier = <Value = any>(value: Value, cache: Cache) => Value; | ||
|
||
export type ObjectCloner = <Value>( | ||
object: Value, | ||
realm: Realm, | ||
handleCopy: Copier, | ||
cache: Cache, | ||
) => Value; | ||
|
||
export type Options = { | ||
isStrict?: boolean; | ||
realm?: Realm; | ||
}; | ||
export interface Cache { | ||
_keys?: any[]; | ||
_values?: any[]; | ||
has: (value: any) => boolean; | ||
set: (key: any, value: any) => void; | ||
get: (key: any) => any; | ||
} | ||
|
||
declare function copy<Value = any>( | ||
value: Value, | ||
options?: FastCopy.Options, | ||
): Value; | ||
export interface Copy { | ||
<Value = any>(value: Value, options?: Options): Value; | ||
|
||
declare namespace copy { | ||
function strictCopy<Value = any>( | ||
value: Value, | ||
options?: FastCopy.Options, | ||
): Value; | ||
strict<Value = any>(value: Value, options?: Options): Value; | ||
} | ||
|
||
export type InternalCopier = <Value = any>(value: Value, cache: Cache) => Value; | ||
|
||
export type ObjectCloner = <Value>( | ||
object: Value, | ||
realm: Realm, | ||
handleCopy: InternalCopier, | ||
cache: Cache | ||
) => Value; | ||
|
||
export interface Options { | ||
isStrict?: boolean; | ||
realm?: Realm; | ||
} | ||
|
||
export type Realm = Record<string, any>; | ||
|
||
declare const copy: Copy; | ||
|
||
export default copy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
module.exports = { | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
roots: ["<rootDir>"], | ||
testRegex: "/__tests__/.*\\.(ts|tsx)$", | ||
export default { | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
roots: ['<rootDir>'], | ||
testRegex: '/__tests__/.*\\.(ts|tsx)$', | ||
transform: { | ||
"\\.(ts|tsx)$": "ts-jest" | ||
'\\.(ts|tsx)$': 'ts-jest', | ||
}, | ||
verbose: true | ||
verbose: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"contributors": [ | ||
"Dariusz Rzepka <[email protected]>" | ||
], | ||
"browser": "dist/fast-copy.js", | ||
"browser": "dist/umd/index.js", | ||
"bugs": { | ||
"url": "https://github.com/planttheidea/fast-copy/issues" | ||
}, | ||
|
@@ -44,6 +44,22 @@ | |
"webpack-cli": "^4.10.0", | ||
"webpack-dev-server": "^4.11.1" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/types/index.d.ts", | ||
"default": "./dist/esm/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/types/index.d.ts", | ||
"default": "./dist/cjs/index.cjs" | ||
}, | ||
"default": { | ||
"types": "./dist/umd/types/index.d.ts", | ||
"default": "./dist/umd/index.js" | ||
} | ||
} | ||
}, | ||
"homepage": "https://github.com/planttheidea/fast-copy#readme", | ||
"keywords": [ | ||
"clone", | ||
|
@@ -52,16 +68,18 @@ | |
"fast" | ||
], | ||
"license": "MIT", | ||
"main": "dist/fast-copy.cjs.js", | ||
"module": "dist/fast-copy.esm.js", | ||
"main": "dist/cjs/index.cjs", | ||
"module": "dist/esm/index.mjs", | ||
"name": "fast-copy", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/planttheidea/fast-copy.git" | ||
}, | ||
"scripts": { | ||
"benchmark": "npm run build && node benchmark/index.js", | ||
"build": "NODE_ENV=production rollup -c", | ||
"benchmark": "npm run build:files && node benchmark/index.js", | ||
"build": "npm run build:files && npm run build:types", | ||
"build:files": "NODE_ENV=production rollup -c", | ||
"build:types": "tsc -p ./tsconfig.cjs.json && tsc -p ./tsconfig.esm.json", | ||
"clean": "rimraf dist", | ||
"dev": "NODE_ENV=development webpack-dev-server --config=webpack/webpack.config.js", | ||
"dist": "npm run clean && npm run build", | ||
|
@@ -77,6 +95,7 @@ | |
"test:watch": "npm run test -- --watch", | ||
"typecheck": "tsc src/*.ts --noEmit" | ||
}, | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"version": "2.1.7" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.declarations.json", | ||
"compilerOptions": { | ||
"declarationDir": "./dist/cjs/types", | ||
"module": "CommonJS", | ||
"outDir": "./dist/cjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"emitDeclarationOnly": true | ||
}, | ||
"include": ["src/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.declarations.json", | ||
"compilerOptions": { | ||
"declarationDir": "./dist/esm/types", | ||
"module": "ESNext", | ||
"outDir": "./dist/esm" | ||
} | ||
} |