@dineroregnskab/eslint-plugin-custom-rules 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@aashutoshrathi/word-wrap/LICENSE +21 -0
- package/node_modules/@aashutoshrathi/word-wrap/README.md +182 -0
- package/node_modules/@aashutoshrathi/word-wrap/index.d.ts +50 -0
- package/node_modules/@aashutoshrathi/word-wrap/index.js +52 -0
- package/node_modules/@aashutoshrathi/word-wrap/package.json +81 -0
- package/node_modules/@angular-eslint/bundled-angular-compiler/README.md +1 -0
- package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.d.ts +5 -0
- package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.js +32004 -0
- package/node_modules/@angular-eslint/bundled-angular-compiler/package.json +19 -0
- package/node_modules/@angular-eslint/template-parser/LICENSE +21 -0
- package/node_modules/@angular-eslint/template-parser/README.md +1 -0
- package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.d.ts +6 -0
- package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.js +69 -0
- package/node_modules/@angular-eslint/template-parser/dist/index.d.ts +44 -0
- package/node_modules/@angular-eslint/template-parser/dist/index.js +219 -0
- package/node_modules/@angular-eslint/template-parser/package.json +28 -0
- package/node_modules/@eslint/eslintrc/LICENSE +19 -0
- package/node_modules/@eslint/eslintrc/README.md +115 -0
- package/node_modules/@eslint/eslintrc/conf/config-schema.js +79 -0
- package/node_modules/@eslint/eslintrc/conf/environments.js +215 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +1104 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +4333 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -0
- package/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +532 -0
- package/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +523 -0
- package/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +115 -0
- package/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +145 -0
- package/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +238 -0
- package/node_modules/@eslint/eslintrc/lib/config-array/index.js +19 -0
- package/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +225 -0
- package/node_modules/@eslint/eslintrc/lib/config-array-factory.js +1149 -0
- package/node_modules/@eslint/eslintrc/lib/flat-compat.js +318 -0
- package/node_modules/@eslint/eslintrc/lib/index-universal.js +29 -0
- package/node_modules/@eslint/eslintrc/lib/index.js +56 -0
- package/node_modules/@eslint/eslintrc/lib/shared/ajv.js +191 -0
- package/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +135 -0
- package/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +325 -0
- package/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +63 -0
- package/node_modules/@eslint/eslintrc/lib/shared/naming.js +96 -0
- package/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +42 -0
- package/node_modules/@eslint/eslintrc/lib/shared/types.js +149 -0
- package/node_modules/@eslint/eslintrc/package.json +82 -0
- package/node_modules/@eslint/eslintrc/universal.js +9 -0
- package/node_modules/@eslint/js/LICENSE +19 -0
- package/node_modules/@eslint/js/README.md +57 -0
- package/node_modules/@eslint/js/package.json +31 -0
- package/node_modules/@eslint/js/src/configs/eslint-all.js +211 -0
- package/node_modules/@eslint/js/src/configs/eslint-recommended.js +76 -0
- package/node_modules/@eslint/js/src/index.js +17 -0
- package/node_modules/@eslint-community/eslint-utils/LICENSE +21 -0
- package/node_modules/@eslint-community/eslint-utils/README.md +37 -0
- package/node_modules/@eslint-community/eslint-utils/index.js +2068 -0
- package/node_modules/@eslint-community/eslint-utils/index.js.map +1 -0
- package/node_modules/@eslint-community/eslint-utils/index.mjs +2027 -0
- package/node_modules/@eslint-community/eslint-utils/index.mjs.map +1 -0
- package/node_modules/@eslint-community/eslint-utils/package.json +73 -0
- package/node_modules/@eslint-community/regexpp/LICENSE +21 -0
- package/node_modules/@eslint-community/regexpp/README.md +177 -0
- package/node_modules/@eslint-community/regexpp/index.d.ts +1065 -0
- package/node_modules/@eslint-community/regexpp/index.js +2747 -0
- package/node_modules/@eslint-community/regexpp/index.js.map +1 -0
- package/node_modules/@eslint-community/regexpp/index.mjs +2737 -0
- package/node_modules/@eslint-community/regexpp/index.mjs.map +1 -0
- package/node_modules/@eslint-community/regexpp/package.json +93 -0
- package/node_modules/@humanwhocodes/config-array/LICENSE +201 -0
- package/node_modules/@humanwhocodes/config-array/README.md +342 -0
- package/node_modules/@humanwhocodes/config-array/api.js +1061 -0
- package/node_modules/@humanwhocodes/config-array/package.json +61 -0
- package/node_modules/@humanwhocodes/module-importer/CHANGELOG.md +15 -0
- package/node_modules/@humanwhocodes/module-importer/LICENSE +201 -0
- package/node_modules/@humanwhocodes/module-importer/README.md +80 -0
- package/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs +22 -0
- package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts +27 -0
- package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.ts +2 -0
- package/node_modules/@humanwhocodes/module-importer/dist/module-importer.js +18 -0
- package/node_modules/@humanwhocodes/module-importer/package.json +65 -0
- package/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs +81 -0
- package/node_modules/@humanwhocodes/module-importer/src/module-importer.js +22 -0
- package/node_modules/@humanwhocodes/object-schema/.eslintrc.js +29 -0
- package/node_modules/@humanwhocodes/object-schema/.github/workflows/nodejs-test.yml +27 -0
- package/node_modules/@humanwhocodes/object-schema/.github/workflows/release-please.yml +39 -0
- package/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +26 -0
- package/node_modules/@humanwhocodes/object-schema/LICENSE +29 -0
- package/node_modules/@humanwhocodes/object-schema/README.md +234 -0
- package/node_modules/@humanwhocodes/object-schema/package.json +33 -0
- package/node_modules/@humanwhocodes/object-schema/src/index.js +7 -0
- package/node_modules/@humanwhocodes/object-schema/src/merge-strategy.js +53 -0
- package/node_modules/@humanwhocodes/object-schema/src/object-schema.js +301 -0
- package/node_modules/@humanwhocodes/object-schema/src/validation-strategy.js +102 -0
- package/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +66 -0
- package/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +659 -0
- package/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +186 -0
- package/node_modules/@nodelib/fs.scandir/LICENSE +21 -0
- package/node_modules/@nodelib/fs.scandir/README.md +171 -0
- package/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +19 -0
- package/node_modules/@nodelib/fs.scandir/out/constants.d.ts +4 -0
- package/node_modules/@nodelib/fs.scandir/out/constants.js +17 -0
- package/node_modules/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/node_modules/@nodelib/fs.scandir/out/index.js +26 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/async.js +104 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +1 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/common.js +13 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +5 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/sync.js +54 -0
- package/node_modules/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/settings.js +24 -0
- package/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/fs.js +19 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/index.js +5 -0
- package/node_modules/@nodelib/fs.scandir/package.json +44 -0
- package/node_modules/@nodelib/fs.stat/LICENSE +21 -0
- package/node_modules/@nodelib/fs.stat/README.md +126 -0
- package/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/node_modules/@nodelib/fs.stat/out/adapters/fs.js +17 -0
- package/node_modules/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/node_modules/@nodelib/fs.stat/out/index.js +26 -0
- package/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/node_modules/@nodelib/fs.stat/out/providers/async.js +36 -0
- package/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +3 -0
- package/node_modules/@nodelib/fs.stat/out/providers/sync.js +23 -0
- package/node_modules/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/node_modules/@nodelib/fs.stat/out/settings.js +16 -0
- package/node_modules/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/node_modules/@nodelib/fs.stat/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.stat/package.json +37 -0
- package/node_modules/@nodelib/fs.walk/LICENSE +21 -0
- package/node_modules/@nodelib/fs.walk/README.md +215 -0
- package/node_modules/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/node_modules/@nodelib/fs.walk/out/index.js +34 -0
- package/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/node_modules/@nodelib/fs.walk/out/providers/async.js +30 -0
- package/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +4 -0
- package/node_modules/@nodelib/fs.walk/out/providers/index.js +9 -0
- package/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +12 -0
- package/node_modules/@nodelib/fs.walk/out/providers/stream.js +34 -0
- package/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +10 -0
- package/node_modules/@nodelib/fs.walk/out/providers/sync.js +14 -0
- package/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/node_modules/@nodelib/fs.walk/out/readers/async.js +97 -0
- package/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +7 -0
- package/node_modules/@nodelib/fs.walk/out/readers/common.js +31 -0
- package/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/node_modules/@nodelib/fs.walk/out/readers/reader.js +11 -0
- package/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +15 -0
- package/node_modules/@nodelib/fs.walk/out/readers/sync.js +59 -0
- package/node_modules/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/node_modules/@nodelib/fs.walk/out/settings.js +26 -0
- package/node_modules/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/node_modules/@nodelib/fs.walk/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.walk/package.json +44 -0
- package/node_modules/@ungap/structured-clone/.github/workflows/node.js.yml +31 -0
- package/node_modules/@ungap/structured-clone/LICENSE +15 -0
- package/node_modules/@ungap/structured-clone/README.md +95 -0
- package/node_modules/@ungap/structured-clone/cjs/deserialize.js +78 -0
- package/node_modules/@ungap/structured-clone/cjs/index.js +27 -0
- package/node_modules/@ungap/structured-clone/cjs/json.js +24 -0
- package/node_modules/@ungap/structured-clone/cjs/package.json +1 -0
- package/node_modules/@ungap/structured-clone/cjs/serialize.js +160 -0
- package/node_modules/@ungap/structured-clone/cjs/types.js +22 -0
- package/node_modules/@ungap/structured-clone/esm/deserialize.js +79 -0
- package/node_modules/@ungap/structured-clone/esm/index.js +25 -0
- package/node_modules/@ungap/structured-clone/esm/json.js +21 -0
- package/node_modules/@ungap/structured-clone/esm/serialize.js +161 -0
- package/node_modules/@ungap/structured-clone/esm/types.js +11 -0
- package/node_modules/@ungap/structured-clone/package.json +53 -0
- package/node_modules/@ungap/structured-clone/structured-json.js +1 -0
- package/package.json +1 -1
- package/rules/dayjs-with-timezone.js +29 -0
- package/rules/reducers-should-always-return.js +20 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as fsScandir from '@nodelib/fs.scandir';
|
|
2
|
+
import type { Entry, Errno } from './types';
|
|
3
|
+
export declare type FilterFunction<T> = (value: T) => boolean;
|
|
4
|
+
export declare type DeepFilterFunction = FilterFunction<Entry>;
|
|
5
|
+
export declare type EntryFilterFunction = FilterFunction<Entry>;
|
|
6
|
+
export declare type ErrorFilterFunction = FilterFunction<Errno>;
|
|
7
|
+
export interface Options {
|
|
8
|
+
basePath?: string;
|
|
9
|
+
concurrency?: number;
|
|
10
|
+
deepFilter?: DeepFilterFunction;
|
|
11
|
+
entryFilter?: EntryFilterFunction;
|
|
12
|
+
errorFilter?: ErrorFilterFunction;
|
|
13
|
+
followSymbolicLinks?: boolean;
|
|
14
|
+
fs?: Partial<fsScandir.FileSystemAdapter>;
|
|
15
|
+
pathSegmentSeparator?: string;
|
|
16
|
+
stats?: boolean;
|
|
17
|
+
throwErrorOnBrokenSymbolicLink?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export default class Settings {
|
|
20
|
+
private readonly _options;
|
|
21
|
+
readonly basePath?: string;
|
|
22
|
+
readonly concurrency: number;
|
|
23
|
+
readonly deepFilter: DeepFilterFunction | null;
|
|
24
|
+
readonly entryFilter: EntryFilterFunction | null;
|
|
25
|
+
readonly errorFilter: ErrorFilterFunction | null;
|
|
26
|
+
readonly pathSegmentSeparator: string;
|
|
27
|
+
readonly fsScandirSettings: fsScandir.Settings;
|
|
28
|
+
constructor(_options?: Options);
|
|
29
|
+
private _getValue;
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fsScandir = require("@nodelib/fs.scandir");
|
|
5
|
+
class Settings {
|
|
6
|
+
constructor(_options = {}) {
|
|
7
|
+
this._options = _options;
|
|
8
|
+
this.basePath = this._getValue(this._options.basePath, undefined);
|
|
9
|
+
this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY);
|
|
10
|
+
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
11
|
+
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
12
|
+
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
13
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep);
|
|
14
|
+
this.fsScandirSettings = new fsScandir.Settings({
|
|
15
|
+
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
16
|
+
fs: this._options.fs,
|
|
17
|
+
pathSegmentSeparator: this._options.pathSegmentSeparator,
|
|
18
|
+
stats: this._options.stats,
|
|
19
|
+
throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
_getValue(option, value) {
|
|
23
|
+
return option !== null && option !== void 0 ? option : value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = Settings;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nodelib/fs.walk",
|
|
3
|
+
"version": "1.2.8",
|
|
4
|
+
"description": "A library for efficiently walking a directory recursively",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"NodeLib",
|
|
9
|
+
"fs",
|
|
10
|
+
"FileSystem",
|
|
11
|
+
"file system",
|
|
12
|
+
"walk",
|
|
13
|
+
"scanner",
|
|
14
|
+
"crawler"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">= 8"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"out/**",
|
|
21
|
+
"!out/**/*.map",
|
|
22
|
+
"!out/**/*.spec.*",
|
|
23
|
+
"!out/**/tests/**"
|
|
24
|
+
],
|
|
25
|
+
"main": "out/index.js",
|
|
26
|
+
"typings": "out/index.d.ts",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"clean": "rimraf {tsconfig.tsbuildinfo,out}",
|
|
29
|
+
"lint": "eslint \"src/**/*.ts\" --cache",
|
|
30
|
+
"compile": "tsc -b .",
|
|
31
|
+
"compile:watch": "tsc -p . --watch --sourceMap",
|
|
32
|
+
"test": "mocha \"out/**/*.spec.js\" -s 0",
|
|
33
|
+
"build": "npm run clean && npm run compile && npm run lint && npm test",
|
|
34
|
+
"watch": "npm run clean && npm run compile:watch"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@nodelib/fs.scandir": "2.1.5",
|
|
38
|
+
"fastq": "^1.6.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@nodelib/fs.macchiato": "1.0.4"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "1e5bad48565da2b06b8600e744324ea240bf49d8"
|
|
44
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: build
|
|
5
|
+
|
|
6
|
+
on: [push, pull_request]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [16]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v2
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v2
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
cache: 'npm'
|
|
24
|
+
- run: npm ci
|
|
25
|
+
- run: npm run build --if-present
|
|
26
|
+
- run: npm test
|
|
27
|
+
- run: npm run coverage --if-present
|
|
28
|
+
- name: Coveralls
|
|
29
|
+
uses: coverallsapp/github-action@master
|
|
30
|
+
with:
|
|
31
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021, Andrea Giammarchi, @WebReflection
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
14
|
+
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# structuredClone polyfill
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ungap/structured-clone) [](https://github.com/ungap/structured-clone/actions) [](https://coveralls.io/github/ungap/structured-clone?branch=main)
|
|
4
|
+
|
|
5
|
+
An env agnostic serializer and deserializer with recursion ability and types beyond *JSON* from the *HTML* standard itself.
|
|
6
|
+
|
|
7
|
+
* [Supported Types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types)
|
|
8
|
+
* *not supported yet*: Blob, File, FileList, ImageBitmap, ImageData, and ArrayBuffer, but typed arrays are supported without major issues, but u/int8, u/int16, and u/int32 are the only safely suppored (right now).
|
|
9
|
+
* *not possible to implement*: the `{transfer: []}` option can be passed but it's completely ignored.
|
|
10
|
+
* [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone)
|
|
11
|
+
* [Serializer](https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal)
|
|
12
|
+
* [Deserializer](https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize)
|
|
13
|
+
|
|
14
|
+
Serialized values can be safely stringified as *JSON* too, and deserialization resurrect all values, even recursive, or more complex than what *JSON* allows.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Examples
|
|
18
|
+
|
|
19
|
+
Check the [100% test coverage](./test/index.js) to know even more.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// as default export
|
|
23
|
+
import structuredClone from '@ungap/structured-clone';
|
|
24
|
+
const cloned = structuredClone({any: 'serializable'});
|
|
25
|
+
|
|
26
|
+
// as independent serializer/deserializer
|
|
27
|
+
import {serialize, deserialize} from '@ungap/structured-clone';
|
|
28
|
+
|
|
29
|
+
// the result can be stringified as JSON without issues
|
|
30
|
+
// even if there is recursive data, bigint values,
|
|
31
|
+
// typed arrays, and so on
|
|
32
|
+
const serialized = serialize({any: 'serializable'});
|
|
33
|
+
|
|
34
|
+
// the result will be a replica of the original object
|
|
35
|
+
const deserialized = deserialize(serialized);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Global Polyfill
|
|
39
|
+
Note: Only monkey patch the global if needed. This polyfill works just fine as an explicit import: `import structuredClone from "@ungap/structured-clone"`
|
|
40
|
+
```js
|
|
41
|
+
// Attach the polyfill as a Global function
|
|
42
|
+
import structuredClone from "@ungap/structured-clone";
|
|
43
|
+
if (!("structuredClone" in globalThis)) {
|
|
44
|
+
globalThis.structuredClone = structuredClone;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Or don't monkey patch
|
|
48
|
+
import structuredClone from "@ungap/structured-clone"
|
|
49
|
+
// Just use it in the file
|
|
50
|
+
structuredClone()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Note**: Do not attach this module's default export directly to the global scope, whithout a conditional guard to detect a native implementation. In environments where there is a native global implementation of `structuredClone()` already, assignment to the global object will result in an infinite loop when `globalThis.structuredClone()` is called. See the example above for a safe way to provide the polyfill globally in your project.
|
|
54
|
+
|
|
55
|
+
### Extra Features
|
|
56
|
+
|
|
57
|
+
There is no middle-ground between the structured clone algorithm and JSON:
|
|
58
|
+
|
|
59
|
+
* JSON is more relaxed about incompatible values: it just ignores these
|
|
60
|
+
* Structured clone is inflexible regarding incompatible values, yet it makes specialized instances impossible to reconstruct, plus it doesn't offer any helper, such as `toJSON()`, to make serialization possible, or better, with specific cases
|
|
61
|
+
|
|
62
|
+
This module specialized `serialize` export offers, within the optional extra argument, a **lossy** property to avoid throwing when incompatible types are found down the road (function, symbol, ...), so that it is possible to send with less worrying about thrown errors.
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
// as default export
|
|
66
|
+
import structuredClone from '@ungap/structured-clone';
|
|
67
|
+
const cloned = structuredClone(
|
|
68
|
+
{
|
|
69
|
+
method() {
|
|
70
|
+
// ignored, won't be cloned
|
|
71
|
+
},
|
|
72
|
+
special: Symbol('also ignored')
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
// avoid throwing
|
|
76
|
+
lossy: true,
|
|
77
|
+
// avoid throwing *and* looks for toJSON
|
|
78
|
+
json: true
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The behavior is the same found in *JSON* when it comes to *Array*, so that unsupported values will result as `null` placeholders instead.
|
|
84
|
+
|
|
85
|
+
#### toJSON
|
|
86
|
+
|
|
87
|
+
If `lossy` option is not enough, `json` will actually enforce `lossy` and also check for `toJSON` method when objects are parsed.
|
|
88
|
+
|
|
89
|
+
Alternative, the `json` exports combines all features:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import {stringify, parse} from '@ungap/structured-clone/json';
|
|
93
|
+
|
|
94
|
+
parse(stringify({any: 'serializable'}));
|
|
95
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const {
|
|
3
|
+
VOID, PRIMITIVE, ARRAY, OBJECT, DATE, REGEXP, MAP, SET, ERROR, BIGINT
|
|
4
|
+
} = require('./types.js');
|
|
5
|
+
|
|
6
|
+
const env = typeof self === 'object' ? self : globalThis;
|
|
7
|
+
|
|
8
|
+
const deserializer = ($, _) => {
|
|
9
|
+
const as = (out, index) => {
|
|
10
|
+
$.set(index, out);
|
|
11
|
+
return out;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const unpair = index => {
|
|
15
|
+
if ($.has(index))
|
|
16
|
+
return $.get(index);
|
|
17
|
+
|
|
18
|
+
const [type, value] = _[index];
|
|
19
|
+
switch (type) {
|
|
20
|
+
case PRIMITIVE:
|
|
21
|
+
case VOID:
|
|
22
|
+
return as(value, index);
|
|
23
|
+
case ARRAY: {
|
|
24
|
+
const arr = as([], index);
|
|
25
|
+
for (const index of value)
|
|
26
|
+
arr.push(unpair(index));
|
|
27
|
+
return arr;
|
|
28
|
+
}
|
|
29
|
+
case OBJECT: {
|
|
30
|
+
const object = as({}, index);
|
|
31
|
+
for (const [key, index] of value)
|
|
32
|
+
object[unpair(key)] = unpair(index);
|
|
33
|
+
return object;
|
|
34
|
+
}
|
|
35
|
+
case DATE:
|
|
36
|
+
return as(new Date(value), index);
|
|
37
|
+
case REGEXP: {
|
|
38
|
+
const {source, flags} = value;
|
|
39
|
+
return as(new RegExp(source, flags), index);
|
|
40
|
+
}
|
|
41
|
+
case MAP: {
|
|
42
|
+
const map = as(new Map, index);
|
|
43
|
+
for (const [key, index] of value)
|
|
44
|
+
map.set(unpair(key), unpair(index));
|
|
45
|
+
return map;
|
|
46
|
+
}
|
|
47
|
+
case SET: {
|
|
48
|
+
const set = as(new Set, index);
|
|
49
|
+
for (const index of value)
|
|
50
|
+
set.add(unpair(index));
|
|
51
|
+
return set;
|
|
52
|
+
}
|
|
53
|
+
case ERROR: {
|
|
54
|
+
const {name, message} = value;
|
|
55
|
+
return as(new env[name](message), index);
|
|
56
|
+
}
|
|
57
|
+
case BIGINT:
|
|
58
|
+
return as(BigInt(value), index);
|
|
59
|
+
case 'BigInt':
|
|
60
|
+
return as(Object(BigInt(value)), index);
|
|
61
|
+
}
|
|
62
|
+
return as(new env[type](value), index);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return unpair;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @typedef {Array<string,any>} Record a type representation
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns a deserialized value from a serialized array of Records.
|
|
74
|
+
* @param {Record[]} serialized a previously serialized value.
|
|
75
|
+
* @returns {any}
|
|
76
|
+
*/
|
|
77
|
+
const deserialize = serialized => deserializer(new Map, serialized)(0);
|
|
78
|
+
exports.deserialize = deserialize;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const {deserialize} = require('./deserialize.js');
|
|
3
|
+
const {serialize} = require('./serialize.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Array<string,any>} Record a type representation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns an array of serialized Records.
|
|
11
|
+
* @param {any} any a serializable value.
|
|
12
|
+
* @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with
|
|
13
|
+
* a transfer option (ignored when polyfilled) and/or non standard fields that
|
|
14
|
+
* fallback to the polyfill if present.
|
|
15
|
+
* @returns {Record[]}
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, '__esModule', {value: true}).default = typeof structuredClone === "function" ?
|
|
18
|
+
/* c8 ignore start */
|
|
19
|
+
(any, options) => (
|
|
20
|
+
options && ('json' in options || 'lossy' in options) ?
|
|
21
|
+
deserialize(serialize(any, options)) : structuredClone(any)
|
|
22
|
+
) :
|
|
23
|
+
(any, options) => deserialize(serialize(any, options));
|
|
24
|
+
/* c8 ignore stop */
|
|
25
|
+
|
|
26
|
+
exports.deserialize = deserialize;
|
|
27
|
+
exports.serialize = serialize;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/*! (c) Andrea Giammarchi - ISC */
|
|
3
|
+
|
|
4
|
+
const {deserialize} = require('./deserialize.js');
|
|
5
|
+
const {serialize} = require('./serialize.js');
|
|
6
|
+
|
|
7
|
+
const {parse: $parse, stringify: $stringify} = JSON;
|
|
8
|
+
const options = {json: true, lossy: true};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Revive a previously stringified structured clone.
|
|
12
|
+
* @param {string} str previously stringified data as string.
|
|
13
|
+
* @returns {any} whatever was previously stringified as clone.
|
|
14
|
+
*/
|
|
15
|
+
const parse = str => deserialize($parse(str));
|
|
16
|
+
exports.parse = parse;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Represent a structured clone value as string.
|
|
20
|
+
* @param {any} any some clone-able value to stringify.
|
|
21
|
+
* @returns {string} the value stringified.
|
|
22
|
+
*/
|
|
23
|
+
const stringify = any => $stringify(serialize(any, options));
|
|
24
|
+
exports.stringify = stringify;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const {
|
|
3
|
+
VOID, PRIMITIVE, ARRAY, OBJECT, DATE, REGEXP, MAP, SET, ERROR, BIGINT
|
|
4
|
+
} = require('./types.js');
|
|
5
|
+
|
|
6
|
+
const EMPTY = '';
|
|
7
|
+
|
|
8
|
+
const {toString} = {};
|
|
9
|
+
const {keys} = Object;
|
|
10
|
+
|
|
11
|
+
const typeOf = value => {
|
|
12
|
+
const type = typeof value;
|
|
13
|
+
if (type !== 'object' || !value)
|
|
14
|
+
return [PRIMITIVE, type];
|
|
15
|
+
|
|
16
|
+
const asString = toString.call(value).slice(8, -1);
|
|
17
|
+
switch (asString) {
|
|
18
|
+
case 'Array':
|
|
19
|
+
return [ARRAY, EMPTY];
|
|
20
|
+
case 'Object':
|
|
21
|
+
return [OBJECT, EMPTY];
|
|
22
|
+
case 'Date':
|
|
23
|
+
return [DATE, EMPTY];
|
|
24
|
+
case 'RegExp':
|
|
25
|
+
return [REGEXP, EMPTY];
|
|
26
|
+
case 'Map':
|
|
27
|
+
return [MAP, EMPTY];
|
|
28
|
+
case 'Set':
|
|
29
|
+
return [SET, EMPTY];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (asString.includes('Array'))
|
|
33
|
+
return [ARRAY, asString];
|
|
34
|
+
|
|
35
|
+
if (asString.includes('Error'))
|
|
36
|
+
return [ERROR, asString];
|
|
37
|
+
|
|
38
|
+
return [OBJECT, asString];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const shouldSkip = ([TYPE, type]) => (
|
|
42
|
+
TYPE === PRIMITIVE &&
|
|
43
|
+
(type === 'function' || type === 'symbol')
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const serializer = (strict, json, $, _) => {
|
|
47
|
+
|
|
48
|
+
const as = (out, value) => {
|
|
49
|
+
const index = _.push(out) - 1;
|
|
50
|
+
$.set(value, index);
|
|
51
|
+
return index;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const pair = value => {
|
|
55
|
+
if ($.has(value))
|
|
56
|
+
return $.get(value);
|
|
57
|
+
|
|
58
|
+
let [TYPE, type] = typeOf(value);
|
|
59
|
+
switch (TYPE) {
|
|
60
|
+
case PRIMITIVE: {
|
|
61
|
+
let entry = value;
|
|
62
|
+
switch (type) {
|
|
63
|
+
case 'bigint':
|
|
64
|
+
TYPE = BIGINT;
|
|
65
|
+
entry = value.toString();
|
|
66
|
+
break;
|
|
67
|
+
case 'function':
|
|
68
|
+
case 'symbol':
|
|
69
|
+
if (strict)
|
|
70
|
+
throw new TypeError('unable to serialize ' + type);
|
|
71
|
+
entry = null;
|
|
72
|
+
break;
|
|
73
|
+
case 'undefined':
|
|
74
|
+
return as([VOID], value);
|
|
75
|
+
}
|
|
76
|
+
return as([TYPE, entry], value);
|
|
77
|
+
}
|
|
78
|
+
case ARRAY: {
|
|
79
|
+
if (type)
|
|
80
|
+
return as([type, [...value]], value);
|
|
81
|
+
|
|
82
|
+
const arr = [];
|
|
83
|
+
const index = as([TYPE, arr], value);
|
|
84
|
+
for (const entry of value)
|
|
85
|
+
arr.push(pair(entry));
|
|
86
|
+
return index;
|
|
87
|
+
}
|
|
88
|
+
case OBJECT: {
|
|
89
|
+
if (type) {
|
|
90
|
+
switch (type) {
|
|
91
|
+
case 'BigInt':
|
|
92
|
+
return as([type, value.toString()], value);
|
|
93
|
+
case 'Boolean':
|
|
94
|
+
case 'Number':
|
|
95
|
+
case 'String':
|
|
96
|
+
return as([type, value.valueOf()], value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (json && ('toJSON' in value))
|
|
101
|
+
return pair(value.toJSON());
|
|
102
|
+
|
|
103
|
+
const entries = [];
|
|
104
|
+
const index = as([TYPE, entries], value);
|
|
105
|
+
for (const key of keys(value)) {
|
|
106
|
+
if (strict || !shouldSkip(typeOf(value[key])))
|
|
107
|
+
entries.push([pair(key), pair(value[key])]);
|
|
108
|
+
}
|
|
109
|
+
return index;
|
|
110
|
+
}
|
|
111
|
+
case DATE:
|
|
112
|
+
return as([TYPE, value.toISOString()], value);
|
|
113
|
+
case REGEXP: {
|
|
114
|
+
const {source, flags} = value;
|
|
115
|
+
return as([TYPE, {source, flags}], value);
|
|
116
|
+
}
|
|
117
|
+
case MAP: {
|
|
118
|
+
const entries = [];
|
|
119
|
+
const index = as([TYPE, entries], value);
|
|
120
|
+
for (const [key, entry] of value) {
|
|
121
|
+
if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
|
|
122
|
+
entries.push([pair(key), pair(entry)]);
|
|
123
|
+
}
|
|
124
|
+
return index;
|
|
125
|
+
}
|
|
126
|
+
case SET: {
|
|
127
|
+
const entries = [];
|
|
128
|
+
const index = as([TYPE, entries], value);
|
|
129
|
+
for (const entry of value) {
|
|
130
|
+
if (strict || !shouldSkip(typeOf(entry)))
|
|
131
|
+
entries.push(pair(entry));
|
|
132
|
+
}
|
|
133
|
+
return index;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const {message} = value;
|
|
138
|
+
return as([TYPE, {name: type, message}], value);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return pair;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @typedef {Array<string,any>} Record a type representation
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns an array of serialized Records.
|
|
150
|
+
* @param {any} value a serializable value.
|
|
151
|
+
* @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that,
|
|
152
|
+
* if `true`, will not throw errors on incompatible types, and behave more
|
|
153
|
+
* like JSON stringify would behave. Symbol and Function will be discarded.
|
|
154
|
+
* @returns {Record[]}
|
|
155
|
+
*/
|
|
156
|
+
const serialize = (value, {json, lossy} = {}) => {
|
|
157
|
+
const _ = [];
|
|
158
|
+
return serializer(!(json || lossy), !!json, new Map, _)(value), _;
|
|
159
|
+
};
|
|
160
|
+
exports.serialize = serialize;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const VOID = -1;
|
|
3
|
+
exports.VOID = VOID;
|
|
4
|
+
const PRIMITIVE = 0;
|
|
5
|
+
exports.PRIMITIVE = PRIMITIVE;
|
|
6
|
+
const ARRAY = 1;
|
|
7
|
+
exports.ARRAY = ARRAY;
|
|
8
|
+
const OBJECT = 2;
|
|
9
|
+
exports.OBJECT = OBJECT;
|
|
10
|
+
const DATE = 3;
|
|
11
|
+
exports.DATE = DATE;
|
|
12
|
+
const REGEXP = 4;
|
|
13
|
+
exports.REGEXP = REGEXP;
|
|
14
|
+
const MAP = 5;
|
|
15
|
+
exports.MAP = MAP;
|
|
16
|
+
const SET = 6;
|
|
17
|
+
exports.SET = SET;
|
|
18
|
+
const ERROR = 7;
|
|
19
|
+
exports.ERROR = ERROR;
|
|
20
|
+
const BIGINT = 8;
|
|
21
|
+
exports.BIGINT = BIGINT;
|
|
22
|
+
// export const SYMBOL = 9;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VOID, PRIMITIVE,
|
|
3
|
+
ARRAY, OBJECT,
|
|
4
|
+
DATE, REGEXP, MAP, SET,
|
|
5
|
+
ERROR, BIGINT
|
|
6
|
+
} from './types.js';
|
|
7
|
+
|
|
8
|
+
const env = typeof self === 'object' ? self : globalThis;
|
|
9
|
+
|
|
10
|
+
const deserializer = ($, _) => {
|
|
11
|
+
const as = (out, index) => {
|
|
12
|
+
$.set(index, out);
|
|
13
|
+
return out;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const unpair = index => {
|
|
17
|
+
if ($.has(index))
|
|
18
|
+
return $.get(index);
|
|
19
|
+
|
|
20
|
+
const [type, value] = _[index];
|
|
21
|
+
switch (type) {
|
|
22
|
+
case PRIMITIVE:
|
|
23
|
+
case VOID:
|
|
24
|
+
return as(value, index);
|
|
25
|
+
case ARRAY: {
|
|
26
|
+
const arr = as([], index);
|
|
27
|
+
for (const index of value)
|
|
28
|
+
arr.push(unpair(index));
|
|
29
|
+
return arr;
|
|
30
|
+
}
|
|
31
|
+
case OBJECT: {
|
|
32
|
+
const object = as({}, index);
|
|
33
|
+
for (const [key, index] of value)
|
|
34
|
+
object[unpair(key)] = unpair(index);
|
|
35
|
+
return object;
|
|
36
|
+
}
|
|
37
|
+
case DATE:
|
|
38
|
+
return as(new Date(value), index);
|
|
39
|
+
case REGEXP: {
|
|
40
|
+
const {source, flags} = value;
|
|
41
|
+
return as(new RegExp(source, flags), index);
|
|
42
|
+
}
|
|
43
|
+
case MAP: {
|
|
44
|
+
const map = as(new Map, index);
|
|
45
|
+
for (const [key, index] of value)
|
|
46
|
+
map.set(unpair(key), unpair(index));
|
|
47
|
+
return map;
|
|
48
|
+
}
|
|
49
|
+
case SET: {
|
|
50
|
+
const set = as(new Set, index);
|
|
51
|
+
for (const index of value)
|
|
52
|
+
set.add(unpair(index));
|
|
53
|
+
return set;
|
|
54
|
+
}
|
|
55
|
+
case ERROR: {
|
|
56
|
+
const {name, message} = value;
|
|
57
|
+
return as(new env[name](message), index);
|
|
58
|
+
}
|
|
59
|
+
case BIGINT:
|
|
60
|
+
return as(BigInt(value), index);
|
|
61
|
+
case 'BigInt':
|
|
62
|
+
return as(Object(BigInt(value)), index);
|
|
63
|
+
}
|
|
64
|
+
return as(new env[type](value), index);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return unpair;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {Array<string,any>} Record a type representation
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns a deserialized value from a serialized array of Records.
|
|
76
|
+
* @param {Record[]} serialized a previously serialized value.
|
|
77
|
+
* @returns {any}
|
|
78
|
+
*/
|
|
79
|
+
export const deserialize = serialized => deserializer(new Map, serialized)(0);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {deserialize} from './deserialize.js';
|
|
2
|
+
import {serialize} from './serialize.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Array<string,any>} Record a type representation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns an array of serialized Records.
|
|
10
|
+
* @param {any} any a serializable value.
|
|
11
|
+
* @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with
|
|
12
|
+
* a transfer option (ignored when polyfilled) and/or non standard fields that
|
|
13
|
+
* fallback to the polyfill if present.
|
|
14
|
+
* @returns {Record[]}
|
|
15
|
+
*/
|
|
16
|
+
export default typeof structuredClone === "function" ?
|
|
17
|
+
/* c8 ignore start */
|
|
18
|
+
(any, options) => (
|
|
19
|
+
options && ('json' in options || 'lossy' in options) ?
|
|
20
|
+
deserialize(serialize(any, options)) : structuredClone(any)
|
|
21
|
+
) :
|
|
22
|
+
(any, options) => deserialize(serialize(any, options));
|
|
23
|
+
/* c8 ignore stop */
|
|
24
|
+
|
|
25
|
+
export {deserialize, serialize};
|