Skip to content

Commit

Permalink
restore default export for easier migration (CJS is only impacted con…
Browse files Browse the repository at this point in the history
…sumer now)
  • Loading branch information
planttheidea committed Sep 28, 2022
1 parent 09b3f3e commit 6ac7c4d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

**Breaking changes**

- `copy` is now a named export instead of a default export
- Exports are now always named, so if using CJS the `.default` suffix is required, e.g. `require('fast-copy').default`
- `copy.strict` is no longer available; it is now available as the explicit `copyStrict` named import
- Options have been removed
- `isStrict` has been replaced with importing `copyStrict`
- `realm` has been removed, as `instanceof` is no longer used internally
- `isStrict` option has been replaced with importing the separate `copyStrict` method
- `realm` has been removed entirely, as `instanceof` is no longer used internally

## 2.1.7

Expand Down
2 changes: 1 addition & 1 deletion DEV_ONLY/App.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cloneDeep from 'lodash/cloneDeep';

import { copy } from '../src';
import copy from '../src';

// import '../benchmarks';

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ console.log(deepEqual(copiedObject, object)); // true
Deeply copy the object passed.

```ts
import { copy } from 'fast-copy';
import copy from 'fast-copy';

const copied = copy({ foo: 'bar' });
```
Expand Down
2 changes: 1 addition & 1 deletion __tests__/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import crypto from 'crypto';
import React from 'react';

import { copy, copyStrict } from '../src';
import copy, { copyStrict } from '../src';

type PlainObject = {
[key: string]: any;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const packages = {
clone: require('clone'),
deepclone: require('deepclone'),
'fast-clone': require('fast-clone'),
'fast-copy': require('../dist/cjs/index.cjs').copy,
'fast-copy': require('../dist/cjs/index.cjs').default,
'fast-copy (strict)': require('../dist/cjs/index.cjs').copyStrict,
// deactivated while it cannot build on linux
// 'fast-deepclone': require('fast-deepclone'),
Expand Down
4 changes: 3 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const copy: <Value>(value: Value) => Value;
declare const copy: <Value>(value: Value) => Value;

export const copyStrict: <Value>(value: Value) => Value;
export default copy;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const copierLoose = createCopier(false);
/**
* Copy an value deeply as much as possible.
*/
export function copy<Value>(value: Value): Value {
export default function copy<Value>(value: Value): Value {
return copierLoose(value, createCache());
}

Expand Down

0 comments on commit 6ac7c4d

Please sign in to comment.