Skip to content

Commit

Permalink
add a structuredClone example
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 15, 2021
1 parent c124e00 commit cafdde7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
17 changes: 11 additions & 6 deletions README.md
Expand Up @@ -30,27 +30,30 @@ The maintainers of `core-js` and thousands of other packages are working with Ti

---

[*Example of usage*](https://is.gd/yHurcF):
[*Example of usage*](https://is.gd/FdIG6n):
```js
import 'core-js'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

*You can load only required features*:
```js
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/structured-clone'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand All @@ -60,11 +63,13 @@ import from from 'core-js-pure/actual/array/from';
import findLast from 'core-js-pure/actual/array/find-last';
import Set from 'core-js-pure/actual/set';
import Promise from 'core-js-pure/actual/promise';
import structuredClone from 'core-js-pure/actual/structured-clone';
import queueMicrotask from 'core-js-pure/actual/queue-microtask';

from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
findLast([1, 2, 3, 4], it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand Down
17 changes: 11 additions & 6 deletions packages/core-js-bundle/README.md
Expand Up @@ -22,27 +22,30 @@

---

[*Example of usage*](https://is.gd/yHurcF):
[*Example of usage*](https://is.gd/FdIG6n):
```js
import 'core-js'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

*You can load only required features*:
```js
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/structured-clone'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand All @@ -52,11 +55,13 @@ import from from 'core-js-pure/actual/array/from';
import findLast from 'core-js-pure/actual/array/find-last';
import Set from 'core-js-pure/actual/set';
import Promise from 'core-js-pure/actual/promise';
import structuredClone from 'core-js-pure/actual/structured-clone';
import queueMicrotask from 'core-js-pure/actual/queue-microtask';

from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
findLast([1, 2, 3, 4], it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand Down
17 changes: 11 additions & 6 deletions packages/core-js-pure/README.md
Expand Up @@ -22,27 +22,30 @@

---

[*Example of usage*](https://is.gd/yHurcF):
[*Example of usage*](https://is.gd/FdIG6n):
```js
import 'core-js'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

*You can load only required features*:
```js
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/structured-clone'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand All @@ -52,11 +55,13 @@ import from from 'core-js-pure/actual/array/from';
import findLast from 'core-js-pure/actual/array/find-last';
import Set from 'core-js-pure/actual/set';
import Promise from 'core-js-pure/actual/promise';
import structuredClone from 'core-js-pure/actual/structured-clone';
import queueMicrotask from 'core-js-pure/actual/queue-microtask';

from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
findLast([1, 2, 3, 4], it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand Down
17 changes: 11 additions & 6 deletions packages/core-js/README.md
Expand Up @@ -22,27 +22,30 @@

---

[*Example of usage*](https://is.gd/yHurcF):
[*Example of usage*](https://is.gd/FdIG6n):
```js
import 'core-js'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

*You can load only required features*:
```js
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/find-last'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/structured-clone'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4].findLast(it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand All @@ -52,11 +55,13 @@ import from from 'core-js-pure/actual/array/from';
import findLast from 'core-js-pure/actual/array/find-last';
import Set from 'core-js-pure/actual/set';
import Promise from 'core-js-pure/actual/promise';
import structuredClone from 'core-js-pure/actual/structured-clone';
import queueMicrotask from 'core-js-pure/actual/queue-microtask';

from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
findLast([1, 2, 3, 4], it => it % 2); // => 3
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
```

Expand Down

0 comments on commit cafdde7

Please sign in to comment.