@emulsify/cli 2.0.0 → 2.1.0
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/README.md +131 -12
- package/dist/handlers/componentInstall.js +65 -4
- package/dist/index.js +2 -0
- package/dist/node_modules/.package-lock.json +6 -216
- package/dist/node_modules/@types/node/README.md +1 -1
- package/dist/node_modules/@types/node/http2.d.ts +1 -0
- package/dist/node_modules/@types/node/package.json +2 -2
- package/dist/package-lock.json +61 -42
- package/dist/package.json +5 -6
- package/dist/schemas/emulsifyProjectConfig.json +80 -0
- package/dist/util/fs/executeScript.js +9 -4
- package/dist/util/fs/loadJsonFile.js +14 -4
- package/dist/util/fs/safeResolveWithin.js +22 -0
- package/dist/util/getRepositoryLatestTag.js +96 -13
- package/dist/util/project/buildComponentDependencyList.js +35 -10
- package/dist/util/project/generateComponent.js +52 -23
- package/dist/util/project/getEmulsifyConfig.js +35 -1
- package/dist/util/project/installComponentFromCache.js +3 -2
- package/dist/util/project/installGeneralAssetsFromCache.js +4 -2
- package/dist/util/system/getAvailableSystems.js +0 -5
- package/package.json +5 -6
- package/dist/node_modules/@babel/code-frame/LICENSE +0 -22
- package/dist/node_modules/@babel/code-frame/README.md +0 -19
- package/dist/node_modules/@babel/code-frame/lib/index.js +0 -217
- package/dist/node_modules/@babel/code-frame/lib/index.js.map +0 -1
- package/dist/node_modules/@babel/code-frame/package.json +0 -32
- package/dist/node_modules/@babel/helper-validator-identifier/LICENSE +0 -22
- package/dist/node_modules/@babel/helper-validator-identifier/README.md +0 -19
- package/dist/node_modules/@babel/helper-validator-identifier/lib/identifier.js +0 -70
- package/dist/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +0 -1
- package/dist/node_modules/@babel/helper-validator-identifier/lib/index.js +0 -57
- package/dist/node_modules/@babel/helper-validator-identifier/lib/index.js.map +0 -1
- package/dist/node_modules/@babel/helper-validator-identifier/lib/keyword.js +0 -35
- package/dist/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +0 -1
- package/dist/node_modules/@babel/helper-validator-identifier/package.json +0 -31
- package/dist/node_modules/@types/progress/LICENSE +0 -21
- package/dist/node_modules/@types/progress/README.md +0 -15
- package/dist/node_modules/@types/progress/index.d.ts +0 -143
- package/dist/node_modules/@types/progress/package.json +0 -27
- package/dist/node_modules/argparse/CHANGELOG.md +0 -216
- package/dist/node_modules/argparse/LICENSE +0 -254
- package/dist/node_modules/argparse/README.md +0 -84
- package/dist/node_modules/argparse/argparse.js +0 -3707
- package/dist/node_modules/argparse/lib/sub.js +0 -67
- package/dist/node_modules/argparse/lib/textwrap.js +0 -440
- package/dist/node_modules/argparse/package.json +0 -31
- package/dist/node_modules/callsites/index.d.ts +0 -96
- package/dist/node_modules/callsites/index.js +0 -13
- package/dist/node_modules/callsites/license +0 -9
- package/dist/node_modules/callsites/package.json +0 -39
- package/dist/node_modules/callsites/readme.md +0 -48
- package/dist/node_modules/cosmiconfig/LICENSE +0 -22
- package/dist/node_modules/cosmiconfig/README.md +0 -782
- package/dist/node_modules/cosmiconfig/dist/Explorer.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/Explorer.js +0 -174
- package/dist/node_modules/cosmiconfig/dist/ExplorerBase.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/ExplorerBase.js +0 -126
- package/dist/node_modules/cosmiconfig/dist/ExplorerSync.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/ExplorerSync.js +0 -188
- package/dist/node_modules/cosmiconfig/dist/defaults.d.ts +0 -25
- package/dist/node_modules/cosmiconfig/dist/defaults.js +0 -105
- package/dist/node_modules/cosmiconfig/dist/index.d.ts +0 -6
- package/dist/node_modules/cosmiconfig/dist/index.js +0 -148
- package/dist/node_modules/cosmiconfig/dist/loaders.d.ts +0 -8
- package/dist/node_modules/cosmiconfig/dist/loaders.js +0 -150
- package/dist/node_modules/cosmiconfig/dist/merge.d.ts +0 -9
- package/dist/node_modules/cosmiconfig/dist/merge.js +0 -44
- package/dist/node_modules/cosmiconfig/dist/types.d.ts +0 -98
- package/dist/node_modules/cosmiconfig/dist/types.js +0 -3
- package/dist/node_modules/cosmiconfig/dist/util.d.ts +0 -2
- package/dist/node_modules/cosmiconfig/dist/util.js +0 -108
- package/dist/node_modules/cosmiconfig/package.json +0 -103
- package/dist/node_modules/env-paths/index.d.ts +0 -101
- package/dist/node_modules/env-paths/index.js +0 -74
- package/dist/node_modules/env-paths/license +0 -9
- package/dist/node_modules/env-paths/package.json +0 -45
- package/dist/node_modules/env-paths/readme.md +0 -115
- package/dist/node_modules/error-ex/LICENSE +0 -21
- package/dist/node_modules/error-ex/README.md +0 -144
- package/dist/node_modules/error-ex/index.js +0 -141
- package/dist/node_modules/error-ex/package.json +0 -46
- package/dist/node_modules/import-fresh/index.d.ts +0 -30
- package/dist/node_modules/import-fresh/index.js +0 -34
- package/dist/node_modules/import-fresh/license +0 -9
- package/dist/node_modules/import-fresh/node_modules/resolve-from/index.js +0 -47
- package/dist/node_modules/import-fresh/node_modules/resolve-from/license +0 -9
- package/dist/node_modules/import-fresh/node_modules/resolve-from/package.json +0 -34
- package/dist/node_modules/import-fresh/node_modules/resolve-from/readme.md +0 -72
- package/dist/node_modules/import-fresh/package.json +0 -48
- package/dist/node_modules/import-fresh/readme.md +0 -54
- package/dist/node_modules/is-arrayish/.editorconfig +0 -18
- package/dist/node_modules/is-arrayish/.istanbul.yml +0 -4
- package/dist/node_modules/is-arrayish/.travis.yml +0 -17
- package/dist/node_modules/is-arrayish/LICENSE +0 -21
- package/dist/node_modules/is-arrayish/README.md +0 -16
- package/dist/node_modules/is-arrayish/index.js +0 -10
- package/dist/node_modules/is-arrayish/package.json +0 -34
- package/dist/node_modules/js-tokens/CHANGELOG.md +0 -151
- package/dist/node_modules/js-tokens/LICENSE +0 -21
- package/dist/node_modules/js-tokens/README.md +0 -240
- package/dist/node_modules/js-tokens/index.js +0 -23
- package/dist/node_modules/js-tokens/package.json +0 -30
- package/dist/node_modules/js-yaml/LICENSE +0 -21
- package/dist/node_modules/js-yaml/README.md +0 -231
- package/dist/node_modules/js-yaml/bin/js-yaml.js +0 -117
- package/dist/node_modules/js-yaml/dist/js-yaml.js +0 -2404
- package/dist/node_modules/js-yaml/dist/js-yaml.js.map +0 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.min.js +0 -33
- package/dist/node_modules/js-yaml/dist/js-yaml.min.js.map +0 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs +0 -2382
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs.map +0 -1
- package/dist/node_modules/js-yaml/index.js +0 -44
- package/dist/node_modules/js-yaml/lib/common.js +0 -50
- package/dist/node_modules/js-yaml/lib/dumper.js +0 -937
- package/dist/node_modules/js-yaml/lib/exception.js +0 -51
- package/dist/node_modules/js-yaml/lib/index_vite_proxy.tmp.mjs +0 -37
- package/dist/node_modules/js-yaml/lib/loader.js +0 -1794
- package/dist/node_modules/js-yaml/lib/schema/core.js +0 -9
- package/dist/node_modules/js-yaml/lib/schema/default.js +0 -20
- package/dist/node_modules/js-yaml/lib/schema/failsafe.js +0 -14
- package/dist/node_modules/js-yaml/lib/schema/json.js +0 -17
- package/dist/node_modules/js-yaml/lib/schema.js +0 -109
- package/dist/node_modules/js-yaml/lib/snippet.js +0 -96
- package/dist/node_modules/js-yaml/lib/type/binary.js +0 -122
- package/dist/node_modules/js-yaml/lib/type/bool.js +0 -35
- package/dist/node_modules/js-yaml/lib/type/float.js +0 -99
- package/dist/node_modules/js-yaml/lib/type/int.js +0 -142
- package/dist/node_modules/js-yaml/lib/type/map.js +0 -8
- package/dist/node_modules/js-yaml/lib/type/merge.js +0 -12
- package/dist/node_modules/js-yaml/lib/type/null.js +0 -35
- package/dist/node_modules/js-yaml/lib/type/omap.js +0 -45
- package/dist/node_modules/js-yaml/lib/type/pairs.js +0 -50
- package/dist/node_modules/js-yaml/lib/type/seq.js +0 -8
- package/dist/node_modules/js-yaml/lib/type/set.js +0 -29
- package/dist/node_modules/js-yaml/lib/type/str.js +0 -8
- package/dist/node_modules/js-yaml/lib/type/timestamp.js +0 -88
- package/dist/node_modules/js-yaml/lib/type.js +0 -66
- package/dist/node_modules/js-yaml/package.json +0 -77
- package/dist/node_modules/json-parse-even-better-errors/CHANGELOG.md +0 -50
- package/dist/node_modules/json-parse-even-better-errors/LICENSE.md +0 -25
- package/dist/node_modules/json-parse-even-better-errors/README.md +0 -96
- package/dist/node_modules/json-parse-even-better-errors/index.js +0 -121
- package/dist/node_modules/json-parse-even-better-errors/package.json +0 -33
- package/dist/node_modules/lines-and-columns/LICENSE +0 -21
- package/dist/node_modules/lines-and-columns/README.md +0 -33
- package/dist/node_modules/lines-and-columns/build/index.d.ts +0 -13
- package/dist/node_modules/lines-and-columns/build/index.js +0 -62
- package/dist/node_modules/lines-and-columns/package.json +0 -49
- package/dist/node_modules/parent-module/index.js +0 -37
- package/dist/node_modules/parent-module/license +0 -9
- package/dist/node_modules/parent-module/package.json +0 -46
- package/dist/node_modules/parent-module/readme.md +0 -67
- package/dist/node_modules/parse-json/index.js +0 -54
- package/dist/node_modules/parse-json/license +0 -9
- package/dist/node_modules/parse-json/package.json +0 -45
- package/dist/node_modules/parse-json/readme.md +0 -119
- package/dist/node_modules/picocolors/LICENSE +0 -15
- package/dist/node_modules/picocolors/README.md +0 -21
- package/dist/node_modules/picocolors/package.json +0 -25
- package/dist/node_modules/picocolors/picocolors.browser.js +0 -4
- package/dist/node_modules/picocolors/picocolors.d.ts +0 -5
- package/dist/node_modules/picocolors/picocolors.js +0 -75
- package/dist/node_modules/picocolors/types.d.ts +0 -51
- package/dist/node_modules/typescript/LICENSE.txt +0 -55
- package/dist/node_modules/typescript/README.md +0 -50
- package/dist/node_modules/typescript/SECURITY.md +0 -39
- package/dist/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/dist/node_modules/typescript/bin/tsc +0 -2
- package/dist/node_modules/typescript/bin/tsserver +0 -2
- package/dist/node_modules/typescript/lib/_tsc.js +0 -134465
- package/dist/node_modules/typescript/lib/_tsserver.js +0 -659
- package/dist/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/dist/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/lib.d.ts +0 -20
- package/dist/node_modules/typescript/lib/lib.decorators.d.ts +0 -382
- package/dist/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -20
- package/dist/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/lib.dom.d.ts +0 -45125
- package/dist/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -150
- package/dist/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -595
- package/dist/node_modules/typescript/lib/lib.es2015.d.ts +0 -26
- package/dist/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -75
- package/dist/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -603
- package/dist/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -79
- package/dist/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -126
- package/dist/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -142
- package/dist/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -44
- package/dist/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -324
- package/dist/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -114
- package/dist/node_modules/typescript/lib/lib.es2016.d.ts +0 -19
- package/dist/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -29
- package/dist/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -19
- package/dist/node_modules/typescript/lib/lib.es2017.d.ts +0 -24
- package/dist/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -29
- package/dist/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -42
- package/dist/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -47
- package/dist/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -133
- package/dist/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -43
- package/dist/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -51
- package/dist/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -75
- package/dist/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -51
- package/dist/node_modules/typescript/lib/lib.es2018.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -81
- package/dist/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -28
- package/dist/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -35
- package/dist/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -77
- package/dist/node_modules/typescript/lib/lib.es2019.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -31
- package/dist/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -35
- package/dist/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -763
- package/dist/node_modules/typescript/lib/lib.es2020.d.ts +0 -25
- package/dist/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -40
- package/dist/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -472
- package/dist/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -26
- package/dist/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -45
- package/dist/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -97
- package/dist/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -42
- package/dist/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -39
- package/dist/node_modules/typescript/lib/lib.es2021.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -164
- package/dist/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -46
- package/dist/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -31
- package/dist/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -76
- package/dist/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -119
- package/dist/node_modules/typescript/lib/lib.es2022.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -73
- package/dist/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -143
- package/dist/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -24
- package/dist/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -37
- package/dist/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -922
- package/dist/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -19
- package/dist/node_modules/typescript/lib/lib.es2023.d.ts +0 -20
- package/dist/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -62
- package/dist/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -63
- package/dist/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.es2024.d.ts +0 -24
- package/dist/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -33
- package/dist/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -66
- package/dist/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.es2025.collection.d.ts +0 -94
- package/dist/node_modules/typescript/lib/lib.es2025.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.es2025.float16.d.ts +0 -443
- package/dist/node_modules/typescript/lib/lib.es2025.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.es2025.intl.d.ts +0 -200
- package/dist/node_modules/typescript/lib/lib.es2025.iterator.d.ts +0 -146
- package/dist/node_modules/typescript/lib/lib.es2025.promise.d.ts +0 -32
- package/dist/node_modules/typescript/lib/lib.es2025.regexp.d.ts +0 -30
- package/dist/node_modules/typescript/lib/lib.es5.d.ts +0 -4599
- package/dist/node_modules/typescript/lib/lib.es6.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -33
- package/dist/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -47
- package/dist/node_modules/typescript/lib/lib.esnext.d.ts +0 -27
- package/dist/node_modules/typescript/lib/lib.esnext.date.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -26
- package/dist/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -191
- package/dist/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -22
- package/dist/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -107
- package/dist/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -23
- package/dist/node_modules/typescript/lib/lib.esnext.temporal.d.ts +0 -485
- package/dist/node_modules/typescript/lib/lib.esnext.typedarrays.d.ts +0 -90
- package/dist/node_modules/typescript/lib/lib.scripthost.d.ts +0 -320
- package/dist/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/lib.webworker.d.ts +0 -15606
- package/dist/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -21
- package/dist/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -18
- package/dist/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/tsc.js +0 -8
- package/dist/node_modules/typescript/lib/tsserver.js +0 -8
- package/dist/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/dist/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/dist/node_modules/typescript/lib/typesMap.json +0 -497
- package/dist/node_modules/typescript/lib/typescript.d.ts +0 -11448
- package/dist/node_modules/typescript/lib/typescript.js +0 -201039
- package/dist/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/dist/node_modules/typescript/lib/watchGuard.js +0 -53
- package/dist/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2129
- package/dist/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2125
- package/dist/node_modules/typescript/package.json +0 -118
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Type = require('../type')
|
|
4
|
-
|
|
5
|
-
function resolveYamlNull (data) {
|
|
6
|
-
if (data === null) return true
|
|
7
|
-
|
|
8
|
-
const max = data.length
|
|
9
|
-
|
|
10
|
-
return (max === 1 && data === '~') ||
|
|
11
|
-
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'))
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function constructYamlNull () {
|
|
15
|
-
return null
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function isNull (object) {
|
|
19
|
-
return object === null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = new Type('tag:yaml.org,2002:null', {
|
|
23
|
-
kind: 'scalar',
|
|
24
|
-
resolve: resolveYamlNull,
|
|
25
|
-
construct: constructYamlNull,
|
|
26
|
-
predicate: isNull,
|
|
27
|
-
represent: {
|
|
28
|
-
canonical: function () { return '~' },
|
|
29
|
-
lowercase: function () { return 'null' },
|
|
30
|
-
uppercase: function () { return 'NULL' },
|
|
31
|
-
camelcase: function () { return 'Null' },
|
|
32
|
-
empty: function () { return '' }
|
|
33
|
-
},
|
|
34
|
-
defaultStyle: 'lowercase'
|
|
35
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Type = require('../type')
|
|
4
|
-
|
|
5
|
-
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
6
|
-
const _toString = Object.prototype.toString
|
|
7
|
-
|
|
8
|
-
function resolveYamlOmap (data) {
|
|
9
|
-
if (data === null) return true
|
|
10
|
-
|
|
11
|
-
const objectKeys = []
|
|
12
|
-
const object = data
|
|
13
|
-
|
|
14
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
15
|
-
const pair = object[index]
|
|
16
|
-
let pairHasKey = false
|
|
17
|
-
|
|
18
|
-
if (_toString.call(pair) !== '[object Object]') return false
|
|
19
|
-
|
|
20
|
-
let pairKey
|
|
21
|
-
for (pairKey in pair) {
|
|
22
|
-
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
23
|
-
if (!pairHasKey) pairHasKey = true
|
|
24
|
-
else return false
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!pairHasKey) return false
|
|
29
|
-
|
|
30
|
-
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey)
|
|
31
|
-
else return false
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return true
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function constructYamlOmap (data) {
|
|
38
|
-
return data !== null ? data : []
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = new Type('tag:yaml.org,2002:omap', {
|
|
42
|
-
kind: 'sequence',
|
|
43
|
-
resolve: resolveYamlOmap,
|
|
44
|
-
construct: constructYamlOmap
|
|
45
|
-
})
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Type = require('../type')
|
|
4
|
-
|
|
5
|
-
const _toString = Object.prototype.toString
|
|
6
|
-
|
|
7
|
-
function resolveYamlPairs (data) {
|
|
8
|
-
if (data === null) return true
|
|
9
|
-
|
|
10
|
-
const object = data
|
|
11
|
-
|
|
12
|
-
const result = new Array(object.length)
|
|
13
|
-
|
|
14
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
15
|
-
const pair = object[index]
|
|
16
|
-
|
|
17
|
-
if (_toString.call(pair) !== '[object Object]') return false
|
|
18
|
-
|
|
19
|
-
const keys = Object.keys(pair)
|
|
20
|
-
|
|
21
|
-
if (keys.length !== 1) return false
|
|
22
|
-
|
|
23
|
-
result[index] = [keys[0], pair[keys[0]]]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return true
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function constructYamlPairs (data) {
|
|
30
|
-
if (data === null) return []
|
|
31
|
-
|
|
32
|
-
const object = data
|
|
33
|
-
const result = new Array(object.length)
|
|
34
|
-
|
|
35
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
36
|
-
const pair = object[index]
|
|
37
|
-
|
|
38
|
-
const keys = Object.keys(pair)
|
|
39
|
-
|
|
40
|
-
result[index] = [keys[0], pair[keys[0]]]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return result
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
|
47
|
-
kind: 'sequence',
|
|
48
|
-
resolve: resolveYamlPairs,
|
|
49
|
-
construct: constructYamlPairs
|
|
50
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Type = require('../type')
|
|
4
|
-
|
|
5
|
-
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
6
|
-
|
|
7
|
-
function resolveYamlSet (data) {
|
|
8
|
-
if (data === null) return true
|
|
9
|
-
|
|
10
|
-
const object = data
|
|
11
|
-
|
|
12
|
-
for (const key in object) {
|
|
13
|
-
if (_hasOwnProperty.call(object, key)) {
|
|
14
|
-
if (object[key] !== null) return false
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return true
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function constructYamlSet (data) {
|
|
22
|
-
return data !== null ? data : {}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = new Type('tag:yaml.org,2002:set', {
|
|
26
|
-
kind: 'mapping',
|
|
27
|
-
resolve: resolveYamlSet,
|
|
28
|
-
construct: constructYamlSet
|
|
29
|
-
})
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Type = require('../type')
|
|
4
|
-
|
|
5
|
-
const YAML_DATE_REGEXP = new RegExp(
|
|
6
|
-
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
7
|
-
'-([0-9][0-9])' + // [2] month
|
|
8
|
-
'-([0-9][0-9])$') // [3] day
|
|
9
|
-
|
|
10
|
-
const YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
11
|
-
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
12
|
-
'-([0-9][0-9]?)' + // [2] month
|
|
13
|
-
'-([0-9][0-9]?)' + // [3] day
|
|
14
|
-
'(?:[Tt]|[ \\t]+)' + // ...
|
|
15
|
-
'([0-9][0-9]?)' + // [4] hour
|
|
16
|
-
':([0-9][0-9])' + // [5] minute
|
|
17
|
-
':([0-9][0-9])' + // [6] second
|
|
18
|
-
'(?:\\.([0-9]*))?' + // [7] fraction
|
|
19
|
-
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tzHour
|
|
20
|
-
'(?::([0-9][0-9]))?))?$') // [11] tzMinute
|
|
21
|
-
|
|
22
|
-
function resolveYamlTimestamp (data) {
|
|
23
|
-
if (data === null) return false
|
|
24
|
-
if (YAML_DATE_REGEXP.exec(data) !== null) return true
|
|
25
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function constructYamlTimestamp (data) {
|
|
30
|
-
let fraction = 0
|
|
31
|
-
let delta = null
|
|
32
|
-
|
|
33
|
-
let match = YAML_DATE_REGEXP.exec(data)
|
|
34
|
-
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data)
|
|
35
|
-
|
|
36
|
-
if (match === null) throw new Error('Date resolve error')
|
|
37
|
-
|
|
38
|
-
// match: [1] year [2] month [3] day
|
|
39
|
-
|
|
40
|
-
const year = +(match[1])
|
|
41
|
-
const month = +(match[2]) - 1 // JS month starts with 0
|
|
42
|
-
const day = +(match[3])
|
|
43
|
-
|
|
44
|
-
if (!match[4]) { // no hour
|
|
45
|
-
return new Date(Date.UTC(year, month, day))
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// match: [4] hour [5] minute [6] second [7] fraction
|
|
49
|
-
|
|
50
|
-
const hour = +(match[4])
|
|
51
|
-
const minute = +(match[5])
|
|
52
|
-
const second = +(match[6])
|
|
53
|
-
|
|
54
|
-
if (match[7]) {
|
|
55
|
-
fraction = match[7].slice(0, 3)
|
|
56
|
-
while (fraction.length < 3) { // milli-seconds
|
|
57
|
-
fraction += '0'
|
|
58
|
-
}
|
|
59
|
-
fraction = +fraction
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// match: [8] tz [9] tz_sign [10] tzHour [11] tzMinute
|
|
63
|
-
|
|
64
|
-
if (match[9]) {
|
|
65
|
-
const tzHour = +(match[10])
|
|
66
|
-
const tzMinute = +(match[11] || 0)
|
|
67
|
-
delta = (tzHour * 60 + tzMinute) * 60000 // delta in mili-seconds
|
|
68
|
-
if (match[9] === '-') delta = -delta
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction))
|
|
72
|
-
|
|
73
|
-
if (delta) date.setTime(date.getTime() - delta)
|
|
74
|
-
|
|
75
|
-
return date
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function representYamlTimestamp (object /*, style */) {
|
|
79
|
-
return object.toISOString()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
|
83
|
-
kind: 'scalar',
|
|
84
|
-
resolve: resolveYamlTimestamp,
|
|
85
|
-
construct: constructYamlTimestamp,
|
|
86
|
-
instanceOf: Date,
|
|
87
|
-
represent: representYamlTimestamp
|
|
88
|
-
})
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const YAMLException = require('./exception')
|
|
4
|
-
|
|
5
|
-
const TYPE_CONSTRUCTOR_OPTIONS = [
|
|
6
|
-
'kind',
|
|
7
|
-
'multi',
|
|
8
|
-
'resolve',
|
|
9
|
-
'construct',
|
|
10
|
-
'instanceOf',
|
|
11
|
-
'predicate',
|
|
12
|
-
'represent',
|
|
13
|
-
'representName',
|
|
14
|
-
'defaultStyle',
|
|
15
|
-
'styleAliases'
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
const YAML_NODE_KINDS = [
|
|
19
|
-
'scalar',
|
|
20
|
-
'sequence',
|
|
21
|
-
'mapping'
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
function compileStyleAliases (map) {
|
|
25
|
-
const result = {}
|
|
26
|
-
|
|
27
|
-
if (map !== null) {
|
|
28
|
-
Object.keys(map).forEach(function (style) {
|
|
29
|
-
map[style].forEach(function (alias) {
|
|
30
|
-
result[String(alias)] = style
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return result
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function Type (tag, options) {
|
|
39
|
-
options = options || {}
|
|
40
|
-
|
|
41
|
-
Object.keys(options).forEach(function (name) {
|
|
42
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
43
|
-
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.')
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
// TODO: Add tag format check.
|
|
48
|
-
this.options = options // keep original options in case user wants to extend this type later
|
|
49
|
-
this.tag = tag
|
|
50
|
-
this.kind = options['kind'] || null
|
|
51
|
-
this.resolve = options['resolve'] || function () { return true }
|
|
52
|
-
this.construct = options['construct'] || function (data) { return data }
|
|
53
|
-
this.instanceOf = options['instanceOf'] || null
|
|
54
|
-
this.predicate = options['predicate'] || null
|
|
55
|
-
this.represent = options['represent'] || null
|
|
56
|
-
this.representName = options['representName'] || null
|
|
57
|
-
this.defaultStyle = options['defaultStyle'] || null
|
|
58
|
-
this.multi = options['multi'] || false
|
|
59
|
-
this.styleAliases = compileStyleAliases(options['styleAliases'] || null)
|
|
60
|
-
|
|
61
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
62
|
-
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.')
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = Type
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "js-yaml",
|
|
3
|
-
"version": "4.2.0",
|
|
4
|
-
"description": "YAML 1.2 parser and serializer",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"yaml",
|
|
7
|
-
"parser",
|
|
8
|
-
"serializer",
|
|
9
|
-
"pyyaml"
|
|
10
|
-
],
|
|
11
|
-
"author": "Vladimir Zapparov <dervus.grim@gmail.com>",
|
|
12
|
-
"contributors": [
|
|
13
|
-
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)",
|
|
14
|
-
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)",
|
|
15
|
-
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)"
|
|
16
|
-
],
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"repository": "nodeca/js-yaml",
|
|
19
|
-
"funding": [
|
|
20
|
-
{
|
|
21
|
-
"type": "github",
|
|
22
|
-
"url": "https://github.com/sponsors/puzrin"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"type": "github",
|
|
26
|
-
"url": "https://github.com/sponsors/nodeca"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"files": [
|
|
30
|
-
"index.js",
|
|
31
|
-
"lib/",
|
|
32
|
-
"bin/",
|
|
33
|
-
"dist/"
|
|
34
|
-
],
|
|
35
|
-
"bin": {
|
|
36
|
-
"js-yaml": "bin/js-yaml.js"
|
|
37
|
-
},
|
|
38
|
-
"module": "./dist/js-yaml.mjs",
|
|
39
|
-
"exports": {
|
|
40
|
-
".": {
|
|
41
|
-
"import": "./dist/js-yaml.mjs",
|
|
42
|
-
"require": "./index.js"
|
|
43
|
-
},
|
|
44
|
-
"./package.json": "./package.json"
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"lint": "eslint .",
|
|
48
|
-
"lint-fix": "eslint . --fix",
|
|
49
|
-
"test": "npm run lint && npm run test:core && npm run test:build",
|
|
50
|
-
"test:core": "node --test test/core/*.test.*",
|
|
51
|
-
"test:build": "npm run build && node --test test/build/*.test.*",
|
|
52
|
-
"coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test test/core/*.test.*",
|
|
53
|
-
"build": "node support/build-dist.mjs",
|
|
54
|
-
"build:demo": "npm run lint && node support/build_demo.mjs",
|
|
55
|
-
"gh-demo": "npm run build:demo && gh-pages -d demo -f",
|
|
56
|
-
"prepack": "npm test && npm run build && npm run build:demo",
|
|
57
|
-
"postpublish": "npm run gh-demo"
|
|
58
|
-
},
|
|
59
|
-
"unpkg": "dist/js-yaml.min.js",
|
|
60
|
-
"jsdelivr": "dist/js-yaml.min.js",
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"argparse": "^2.0.1"
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"c8": "^11.0.0",
|
|
66
|
-
"codemirror": "^5.65.21",
|
|
67
|
-
"eslint": "^9.39.4",
|
|
68
|
-
"fast-check": "^4.8.0",
|
|
69
|
-
"gh-pages": "^6.3.0",
|
|
70
|
-
"neostandard": "^0.13.0",
|
|
71
|
-
"tinybench": "^6.0.2",
|
|
72
|
-
"vite": "^8.0.14",
|
|
73
|
-
"vite-plugin-node-polyfills": "^0.28.0",
|
|
74
|
-
"vite-plugin-singlefile": "^2.3.3",
|
|
75
|
-
"workerpool": "^10.0.2"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
## 2.0.0
|
|
6
|
-
|
|
7
|
-
* Add custom error classes
|
|
8
|
-
|
|
9
|
-
<a name="1.0.2"></a>
|
|
10
|
-
## [1.0.2](https://github.com/npm/json-parse-even-better-errors/compare/v1.0.1...v1.0.2) (2018-03-30)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Bug Fixes
|
|
14
|
-
|
|
15
|
-
* **messages:** More friendly messages for non-string ([#1](https://github.com/npm/json-parse-even-better-errors/issues/1)) ([a476d42](https://github.com/npm/json-parse-even-better-errors/commit/a476d42))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<a name="1.0.1"></a>
|
|
20
|
-
## [1.0.1](https://github.com/npm/json-parse-even-better-errors/compare/v1.0.0...v1.0.1) (2017-08-16)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### Bug Fixes
|
|
24
|
-
|
|
25
|
-
* **license:** oops. Forgot to update license.md ([efe2958](https://github.com/npm/json-parse-even-better-errors/commit/efe2958))
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<a name="1.0.0"></a>
|
|
30
|
-
# 1.0.0 (2017-08-15)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Features
|
|
34
|
-
|
|
35
|
-
* **init:** Initial Commit ([562c977](https://github.com/npm/json-parse-even-better-errors/commit/562c977))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### BREAKING CHANGES
|
|
39
|
-
|
|
40
|
-
* **init:** This is the first commit!
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<a name="0.1.0"></a>
|
|
45
|
-
# 0.1.0 (2017-08-15)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Features
|
|
49
|
-
|
|
50
|
-
* **init:** Initial Commit ([9dd1a19](https://github.com/npm/json-parse-even-better-errors/commit/9dd1a19))
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Copyright 2017 Kat Marchán
|
|
2
|
-
Copyright npm, Inc.
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
-
copy of this software and associated documentation files (the "Software"),
|
|
6
|
-
to deal in the Software without restriction, including without limitation
|
|
7
|
-
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
-
and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
-
Software is furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in
|
|
12
|
-
all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
19
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
-
DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
This library is a fork of 'better-json-errors' by Kat Marchán, extended and
|
|
25
|
-
distributed under the terms of the MIT license above.
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# json-parse-even-better-errors
|
|
2
|
-
|
|
3
|
-
[`json-parse-even-better-errors`](https://github.com/npm/json-parse-even-better-errors)
|
|
4
|
-
is a Node.js library for getting nicer errors out of `JSON.parse()`,
|
|
5
|
-
including context and position of the parse errors.
|
|
6
|
-
|
|
7
|
-
It also preserves the newline and indentation styles of the JSON data, by
|
|
8
|
-
putting them in the object or array in the `Symbol.for('indent')` and
|
|
9
|
-
`Symbol.for('newline')` properties.
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
`$ npm install --save json-parse-even-better-errors`
|
|
14
|
-
|
|
15
|
-
## Table of Contents
|
|
16
|
-
|
|
17
|
-
* [Example](#example)
|
|
18
|
-
* [Features](#features)
|
|
19
|
-
* [Contributing](#contributing)
|
|
20
|
-
* [API](#api)
|
|
21
|
-
* [`parse`](#parse)
|
|
22
|
-
|
|
23
|
-
### Example
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
const parseJson = require('json-parse-even-better-errors')
|
|
27
|
-
|
|
28
|
-
parseJson('"foo"') // returns the string 'foo'
|
|
29
|
-
parseJson('garbage') // more useful error message
|
|
30
|
-
parseJson.noExceptions('garbage') // returns undefined
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Features
|
|
34
|
-
|
|
35
|
-
* Like JSON.parse, but the errors are better.
|
|
36
|
-
* Strips a leading byte-order-mark that you sometimes get reading files.
|
|
37
|
-
* Has a `noExceptions` method that returns undefined rather than throwing.
|
|
38
|
-
* Attaches the newline character(s) used to the `Symbol.for('newline')`
|
|
39
|
-
property on objects and arrays.
|
|
40
|
-
* Attaches the indentation character(s) used to the `Symbol.for('indent')`
|
|
41
|
-
property on objects and arrays.
|
|
42
|
-
|
|
43
|
-
## Indentation
|
|
44
|
-
|
|
45
|
-
To preserve indentation when the file is saved back to disk, use
|
|
46
|
-
`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and
|
|
47
|
-
if you want to preserve windows `\r\n` newlines, replace the `\n` chars in
|
|
48
|
-
the string with `data[Symbol.for('newline')]`.
|
|
49
|
-
|
|
50
|
-
For example:
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
const txt = await readFile('./package.json', 'utf8')
|
|
54
|
-
const data = parseJsonEvenBetterErrors(txt)
|
|
55
|
-
const indent = Symbol.for('indent')
|
|
56
|
-
const newline = Symbol.for('newline')
|
|
57
|
-
// .. do some stuff to the data ..
|
|
58
|
-
const string = JSON.stringify(data, null, data[indent]) + '\n'
|
|
59
|
-
const eolFixed = data[newline] === '\n' ? string
|
|
60
|
-
: string.replace(/\n/g, data[newline])
|
|
61
|
-
await writeFile('./package.json', eolFixed)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Indentation is determined by looking at the whitespace between the initial
|
|
65
|
-
`{` and `[` and the character that follows it. If you have lots of weird
|
|
66
|
-
inconsistent indentation, then it won't track that or give you any way to
|
|
67
|
-
preserve it. Whether this is a bug or a feature is debatable ;)
|
|
68
|
-
|
|
69
|
-
### API
|
|
70
|
-
|
|
71
|
-
#### <a name="parse"></a> `parse(txt, reviver = null, context = 20)`
|
|
72
|
-
|
|
73
|
-
Works just like `JSON.parse`, but will include a bit more information when
|
|
74
|
-
an error happens, and attaches a `Symbol.for('indent')` and
|
|
75
|
-
`Symbol.for('newline')` on objects and arrays. This throws a
|
|
76
|
-
`JSONParseError`.
|
|
77
|
-
|
|
78
|
-
#### <a name="parse"></a> `parse.noExceptions(txt, reviver = null)`
|
|
79
|
-
|
|
80
|
-
Works just like `JSON.parse`, but will return `undefined` rather than
|
|
81
|
-
throwing an error.
|
|
82
|
-
|
|
83
|
-
#### <a name="jsonparseerror"></a> `class JSONParseError(er, text, context = 20, caller = null)`
|
|
84
|
-
|
|
85
|
-
Extends the JavaScript `SyntaxError` class to parse the message and provide
|
|
86
|
-
better metadata.
|
|
87
|
-
|
|
88
|
-
Pass in the error thrown by the built-in `JSON.parse`, and the text being
|
|
89
|
-
parsed, and it'll parse out the bits needed to be helpful.
|
|
90
|
-
|
|
91
|
-
`context` defaults to 20.
|
|
92
|
-
|
|
93
|
-
Set a `caller` function to trim internal implementation details out of the
|
|
94
|
-
stack trace. When calling `parseJson`, this is set to the `parseJson`
|
|
95
|
-
function. If not set, then the constructor defaults to itself, so the
|
|
96
|
-
stack trace will point to the spot where you call `new JSONParseError`.
|