freewind-ts-utils 0.18.2
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 +60 -0
- package/antd/CopyButton/CopyButton.d.ts +7 -0
- package/antd/CopyButton/CopyButton.js +29 -0
- package/antd/CopyButton/index.d.ts +1 -0
- package/antd/CopyButton/index.js +2 -0
- package/antd/FloatLabel/FloatLabel.css +18 -0
- package/antd/FloatLabel/FloatLabel.d.ts +8 -0
- package/antd/FloatLabel/FloatLabel.js +50 -0
- package/antd/FloatLabel/index.d.ts +1 -0
- package/antd/FloatLabel/index.js +2 -0
- package/antd/FuzzyAutoComplete/FuzzyAutoComplete.d.ts +17 -0
- package/antd/FuzzyAutoComplete/FuzzyAutoComplete.js +73 -0
- package/antd/FuzzyAutoComplete/index.d.ts +1 -0
- package/antd/FuzzyAutoComplete/index.js +2 -0
- package/antd/FuzzyPathSelect/FuzzyPathSelect.d.ts +8 -0
- package/antd/FuzzyPathSelect/FuzzyPathSelect.js +48 -0
- package/antd/FuzzyPathSelect/defaultIgnoreNames.d.ts +1 -0
- package/antd/FuzzyPathSelect/defaultIgnoreNames.js +28 -0
- package/antd/FuzzyPathSelect/index.d.ts +1 -0
- package/antd/FuzzyPathSelect/index.js +2 -0
- package/antd/FuzzyStringSelect/FuzzyStringSelect.d.ts +6 -0
- package/antd/FuzzyStringSelect/FuzzyStringSelect.js +12 -0
- package/antd/FuzzyStringSelect/index.d.ts +1 -0
- package/antd/FuzzyStringSelect/index.js +2 -0
- package/antd/HoverSwap/HoverSwap.css +3 -0
- package/antd/HoverSwap/HoverSwap.d.ts +8 -0
- package/antd/HoverSwap/HoverSwap.js +18 -0
- package/antd/HoverSwap/index.d.ts +1 -0
- package/antd/HoverSwap/index.js +2 -0
- package/antd/InputLabel/InputLabel.css +10 -0
- package/antd/InputLabel/InputLabel.d.ts +4 -0
- package/antd/InputLabel/InputLabel.js +11 -0
- package/antd/InputLabel/index.d.ts +1 -0
- package/antd/InputLabel/index.js +2 -0
- package/antd/JsonPreviewer/JsonPreviewer.css +74 -0
- package/antd/JsonPreviewer/JsonPreviewer.d.ts +11 -0
- package/antd/JsonPreviewer/JsonPreviewer.js +69 -0
- package/antd/JsonPreviewer/index.d.ts +1 -0
- package/antd/JsonPreviewer/index.js +2 -0
- package/antd/_internal/HighlightParts.d.ts +6 -0
- package/antd/_internal/HighlightParts.js +12 -0
- package/antd/index.d.ts +8 -0
- package/antd/index.js +17 -0
- package/common/SimpleType.d.ts +2 -0
- package/common/SimpleType.js +0 -0
- package/common/_internal/createObjectReferenceTracker.d.ts +5 -0
- package/common/_internal/createObjectReferenceTracker.js +11 -0
- package/common/anyToString/anyToString.d.ts +27 -0
- package/common/anyToString/anyToString.js +23 -0
- package/common/anyToString/createCircularStackTracker.d.ts +5 -0
- package/common/anyToString/createCircularStackTracker.js +14 -0
- package/common/anyToString/formatters/formatArray.d.ts +2 -0
- package/common/anyToString/formatters/formatArray.js +11 -0
- package/common/anyToString/formatters/formatArrayBufferView.d.ts +2 -0
- package/common/anyToString/formatters/formatArrayBufferView.js +14 -0
- package/common/anyToString/formatters/formatDocumentObject.d.ts +1 -0
- package/common/anyToString/formatters/formatDocumentObject.js +7 -0
- package/common/anyToString/formatters/formatElementObject.d.ts +1 -0
- package/common/anyToString/formatters/formatElementObject.js +15 -0
- package/common/anyToString/formatters/formatError.d.ts +1 -0
- package/common/anyToString/formatters/formatError.js +7 -0
- package/common/anyToString/formatters/formatFunction.d.ts +1 -0
- package/common/anyToString/formatters/formatFunction.js +6 -0
- package/common/anyToString/formatters/formatMap.d.ts +2 -0
- package/common/anyToString/formatters/formatMap.js +17 -0
- package/common/anyToString/formatters/formatObject.d.ts +2 -0
- package/common/anyToString/formatters/formatObject.js +44 -0
- package/common/anyToString/formatters/formatObjectKey.d.ts +1 -0
- package/common/anyToString/formatters/formatObjectKey.js +8 -0
- package/common/anyToString/formatters/formatRecordLike.d.ts +2 -0
- package/common/anyToString/formatters/formatRecordLike.js +39 -0
- package/common/anyToString/formatters/formatSet.d.ts +2 -0
- package/common/anyToString/formatters/formatSet.js +17 -0
- package/common/anyToString/formatters/formatString.d.ts +1 -0
- package/common/anyToString/formatters/formatString.js +8 -0
- package/common/anyToString/formatters/formatValue.d.ts +11 -0
- package/common/anyToString/formatters/formatValue.js +20 -0
- package/common/anyToString/formatters/formatWindowObject.d.ts +1 -0
- package/common/anyToString/formatters/formatWindowObject.js +6 -0
- package/common/anyToString/formatters/getConstructorName.d.ts +1 -0
- package/common/anyToString/formatters/getConstructorName.js +7 -0
- package/common/anyToString/formatters/joinBlock.d.ts +1 -0
- package/common/anyToString/formatters/joinBlock.js +9 -0
- package/common/anyToString/formatters/withCircularGuard.d.ts +2 -0
- package/common/anyToString/formatters/withCircularGuard.js +11 -0
- package/common/anyToString/index.d.ts +1 -0
- package/common/anyToString/index.js +2 -0
- package/common/assertsType.d.ts +12 -0
- package/common/assertsType.js +4 -0
- package/common/buildSequence.d.ts +6 -0
- package/common/buildSequence.js +8 -0
- package/common/deepClone.d.ts +12 -0
- package/common/deepClone.js +55 -0
- package/common/deepEqual.d.ts +12 -0
- package/common/deepEqual.js +46 -0
- package/common/deepParseJsonStrings.d.ts +1 -0
- package/common/deepParseJsonStrings.js +22 -0
- package/common/dependsOn.d.ts +12 -0
- package/common/dependsOn.js +4 -0
- package/common/doExpr.d.ts +14 -0
- package/common/doExpr.js +6 -0
- package/common/flatChildren.d.ts +1 -0
- package/common/flatChildren.js +14 -0
- package/common/formatDecimal.d.ts +12 -0
- package/common/formatDecimal.js +11 -0
- package/common/formatFriendlyTime.d.ts +1 -0
- package/common/formatFriendlyTime.js +10 -0
- package/common/formatSize.d.ts +13 -0
- package/common/formatSize.js +19 -0
- package/common/fuzzy/fuzzyMatch.d.ts +25 -0
- package/common/fuzzy/fuzzyMatch.js +19 -0
- package/common/fuzzy/fuzzyMatchPath.d.ts +23 -0
- package/common/fuzzy/fuzzyMatchPath.js +102 -0
- package/common/fuzzy/types.d.ts +10 -0
- package/common/fuzzy/types.js +0 -0
- package/common/fuzzy/utils/buildHighlightParts.d.ts +4 -0
- package/common/fuzzy/utils/buildHighlightParts.js +21 -0
- package/common/fuzzy/utils/buildHighlightRanges.d.ts +1 -0
- package/common/fuzzy/utils/buildHighlightRanges.js +20 -0
- package/common/fuzzy/utils/index.d.ts +5 -0
- package/common/fuzzy/utils/index.js +6 -0
- package/common/fuzzy/utils/normalizePathSeparators.d.ts +1 -0
- package/common/fuzzy/utils/normalizePathSeparators.js +7 -0
- package/common/fuzzy/utils/rankFuzzyCandidates.d.ts +2 -0
- package/common/fuzzy/utils/rankFuzzyCandidates.js +26 -0
- package/common/fuzzy/utils/scoreLooseFuzzyMatch.d.ts +2 -0
- package/common/fuzzy/utils/scoreLooseFuzzyMatch.js +126 -0
- package/common/getEnumerableOwnDescriptors.d.ts +1 -0
- package/common/getEnumerableOwnDescriptors.js +11 -0
- package/common/index.d.ts +49 -0
- package/common/index.js +48 -0
- package/common/isEmptyRecord.d.ts +10 -0
- package/common/isEmptyRecord.js +7 -0
- package/common/isNil.d.ts +13 -0
- package/common/isNil.js +6 -0
- package/common/isNonNil.d.ts +11 -0
- package/common/isNonNil.js +6 -0
- package/common/isRecord.d.ts +12 -0
- package/common/isRecord.js +8 -0
- package/common/jsonRecord/filterJsonRecord.d.ts +16 -0
- package/common/jsonRecord/filterJsonRecord.js +19 -0
- package/common/jsonRecord/isJsonRecord.d.ts +16 -0
- package/common/jsonRecord/isJsonRecord.js +16 -0
- package/common/jsonRecord/jsonRecordDiff.d.ts +13 -0
- package/common/jsonRecord/jsonRecordDiff.js +26 -0
- package/common/jsonRecord/mapJsonRecord.d.ts +13 -0
- package/common/jsonRecord/mapJsonRecord.js +14 -0
- package/common/jsonRecord/modifyJsonRecord.d.ts +14 -0
- package/common/jsonRecord/modifyJsonRecord.js +24 -0
- package/common/jsonRecord/walkJsonRecord.d.ts +15 -0
- package/common/jsonRecord/walkJsonRecord.js +16 -0
- package/common/onlyUnique.d.ts +10 -0
- package/common/onlyUnique.js +6 -0
- package/common/pipe.d.ts +9 -0
- package/common/pipe.js +6 -0
- package/common/pipeNonNil.d.ts +16 -0
- package/common/pipeNonNil.js +7 -0
- package/common/safeJsonStringify.d.ts +28 -0
- package/common/safeJsonStringify.js +105 -0
- package/common/simpleInt/isSimpleInt.d.ts +6 -0
- package/common/simpleInt/isSimpleInt.js +6 -0
- package/common/simpleInt/isSimpleIntInputing.d.ts +6 -0
- package/common/simpleInt/isSimpleIntInputing.js +7 -0
- package/common/simpleInt/isSimpleNumber.d.ts +10 -0
- package/common/simpleInt/isSimpleNumber.js +6 -0
- package/common/simpleInt/isSimpleNumberInputing.d.ts +6 -0
- package/common/simpleInt/isSimpleNumberInputing.js +7 -0
- package/common/simpleInt/parseSimpleInt.d.ts +6 -0
- package/common/simpleInt/parseSimpleInt.js +11 -0
- package/common/simpleInt/parseSimpleIntOrNil.d.ts +6 -0
- package/common/simpleInt/parseSimpleIntOrNil.js +9 -0
- package/common/simpleInt/parseSimpleNumber.d.ts +6 -0
- package/common/simpleInt/parseSimpleNumber.js +11 -0
- package/common/simpleInt/parseSimpleNumberOrNil.d.ts +4 -0
- package/common/simpleInt/parseSimpleNumberOrNil.js +7 -0
- package/common/tap.d.ts +9 -0
- package/common/tap.js +6 -0
- package/common/tree/buildTree.d.ts +6 -0
- package/common/tree/buildTree.js +13 -0
- package/common/tree/flatTree.d.ts +2 -0
- package/common/tree/flatTree.js +7 -0
- package/common/tree/mapTree.d.ts +2 -0
- package/common/tree/mapTree.js +11 -0
- package/common/tree/pruneTree.d.ts +2 -0
- package/common/tree/pruneTree.js +15 -0
- package/common/tree/sortTree.d.ts +2 -0
- package/common/tree/sortTree.js +11 -0
- package/common/tree/treeToArray.d.ts +2 -0
- package/common/tree/treeToArray.js +12 -0
- package/common/tree/treeToRows.d.ts +5 -0
- package/common/tree/treeToRows.js +19 -0
- package/common/tree/treeTypes.d.ts +7 -0
- package/common/tree/treeTypes.js +0 -0
- package/common/tree/walkTree.d.ts +2 -0
- package/common/tree/walkTree.js +13 -0
- package/common/truncateJsonStrings.d.ts +14 -0
- package/common/truncateJsonStrings.js +7 -0
- package/common/truncateString.d.ts +13 -0
- package/common/truncateString.js +7 -0
- package/common/tryParsePartialJson.d.ts +11 -0
- package/common/tryParsePartialJson.js +156 -0
- package/eslint-config/eslintPreset.d.ts +2 -0
- package/eslint-config/eslintPreset.js +36 -0
- package/eslint-config/index.d.ts +14 -0
- package/eslint-config/index.js +20 -0
- package/eslint-config/layers/configLayer.d.ts +2 -0
- package/eslint-config/layers/configLayer.js +16 -0
- package/eslint-config/layers/jsLayer.d.ts +2 -0
- package/eslint-config/layers/jsLayer.js +20 -0
- package/eslint-config/layers/prettierLayer.d.ts +5 -0
- package/eslint-config/layers/prettierLayer.js +5 -0
- package/eslint-config/layers/reactHookLayer.d.ts +2 -0
- package/eslint-config/layers/reactHookLayer.js +16 -0
- package/eslint-config/layers/testLayer.d.ts +2 -0
- package/eslint-config/layers/testLayer.js +46 -0
- package/eslint-config/layers/tsLayer.d.ts +2 -0
- package/eslint-config/layers/tsLayer.js +70 -0
- package/eslint-config/plugins/freewindSingleExportPlugin.d.ts +2 -0
- package/eslint-config/plugins/freewindSingleExportPlugin.js +47 -0
- package/eslint-config/utils/withRuleOverrides.d.ts +2 -0
- package/eslint-config/utils/withRuleOverrides.js +9 -0
- package/index.d.ts +1 -0
- package/index.js +49 -0
- package/node/index.d.ts +2 -0
- package/node/index.js +3 -0
- package/node/md5.d.ts +11 -0
- package/node/md5.js +7 -0
- package/node/uuid.d.ts +11 -0
- package/node/uuid.js +7 -0
- package/package.json +115 -0
- package/prettier-config/freewindPrettierPreset.d.ts +2 -0
- package/prettier-config/freewindPrettierPreset.js +4 -0
- package/prettier-config/index.d.ts +1 -0
- package/prettier-config/index.js +2 -0
- package/react/hooks/useCopyToClipboard.d.ts +10 -0
- package/react/hooks/useCopyToClipboard.js +28 -0
- package/react/hooks/useDeepCompareSelector.d.ts +23 -0
- package/react/hooks/useDeepCompareSelector.js +14 -0
- package/react/hooks/useInputEvent/_internal/ink-input/index.d.ts +2 -0
- package/react/hooks/useInputEvent/_internal/ink-input/index.js +3 -0
- package/react/hooks/useInputEvent/_internal/ink-input/input-parser.d.ts +6 -0
- package/react/hooks/useInputEvent/_internal/ink-input/input-parser.js +98 -0
- package/react/hooks/useInputEvent/_internal/ink-input/kitty-keyboard.d.ts +19 -0
- package/react/hooks/useInputEvent/_internal/ink-input/kitty-keyboard.js +13 -0
- package/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.d.ts +33 -0
- package/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.js +319 -0
- package/react/hooks/useInputEvent/formatInputEvent.d.ts +2 -0
- package/react/hooks/useInputEvent/formatInputEvent.js +25 -0
- package/react/hooks/useInputEvent/index.d.ts +4 -0
- package/react/hooks/useInputEvent/index.js +4 -0
- package/react/hooks/useInputEvent/inputEventTypes.d.ts +51 -0
- package/react/hooks/useInputEvent/inputEventTypes.js +0 -0
- package/react/hooks/useInputEvent/parseInputEvent.d.ts +4 -0
- package/react/hooks/useInputEvent/parseInputEvent.js +100 -0
- package/react/hooks/useInputEvent/useInputEvent.d.ts +7 -0
- package/react/hooks/useInputEvent/useInputEvent.js +57 -0
- package/react/hooks/useOverlayStack/_internal/overlayStackId.d.ts +2 -0
- package/react/hooks/useOverlayStack/_internal/overlayStackId.js +6 -0
- package/react/hooks/useOverlayStack/createOverlayStackItem.d.ts +2 -0
- package/react/hooks/useOverlayStack/createOverlayStackItem.js +10 -0
- package/react/hooks/useOverlayStack/index.d.ts +3 -0
- package/react/hooks/useOverlayStack/index.js +3 -0
- package/react/hooks/useOverlayStack/overlayStackTypes.d.ts +13 -0
- package/react/hooks/useOverlayStack/overlayStackTypes.js +0 -0
- package/react/hooks/useOverlayStack/useOverlayStack.d.ts +2 -0
- package/react/hooks/useOverlayStack/useOverlayStack.js +24 -0
- package/react/index.d.ts +4 -0
- package/react/index.js +10 -0
- package/react/ink-components/InkModal/InkModal.d.ts +3 -0
- package/react/ink-components/InkModal/InkModal.js +101 -0
- package/react/ink-components/InkModal/index.d.ts +4 -0
- package/react/ink-components/InkModal/index.js +4 -0
- package/react/ink-components/InkModal/types.d.ts +24 -0
- package/react/ink-components/InkModal/types.js +0 -0
- package/react/ink-components/InkModal/utils/computeInkModalBodyMaxHeight.d.ts +1 -0
- package/react/ink-components/InkModal/utils/computeInkModalBodyMaxHeight.js +4 -0
- package/react/ink-components/InkModal/utils/resolveInkModalSize.d.ts +6 -0
- package/react/ink-components/InkModal/utils/resolveInkModalSize.js +7 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelect.d.ts +22 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelect.js +94 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelectRow.d.ts +10 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelectRow.js +35 -0
- package/react/ink-components/InkMultiSelect/index.d.ts +8 -0
- package/react/ink-components/InkMultiSelect/index.js +9 -0
- package/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.d.ts +17 -0
- package/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.js +19 -0
- package/react/ink-components/InkMultiSelect/types.d.ts +20 -0
- package/react/ink-components/InkMultiSelect/types.js +18 -0
- package/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.d.ts +10 -0
- package/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.js +40 -0
- package/react/ink-components/InkMultiSelect/utils/clampListScrollOffset.d.ts +1 -0
- package/react/ink-components/InkMultiSelect/utils/clampListScrollOffset.js +6 -0
- package/react/ink-components/InkMultiSelect/utils/formatMoreLabel.d.ts +1 -0
- package/react/ink-components/InkMultiSelect/utils/formatMoreLabel.js +6 -0
- package/react/ink-components/InkMultiSelect/utils/inkMultiSelectVisibleCount.d.ts +2 -0
- package/react/ink-components/InkMultiSelect/utils/inkMultiSelectVisibleCount.js +7 -0
- package/react/ink-components/InkScrollView/InkScrollView.d.ts +19 -0
- package/react/ink-components/InkScrollView/InkScrollView.js +103 -0
- package/react/ink-components/InkScrollView/Scrollbar.d.ts +7 -0
- package/react/ink-components/InkScrollView/Scrollbar.js +16 -0
- package/react/ink-components/InkScrollView/index.d.ts +9 -0
- package/react/ink-components/InkScrollView/index.js +18 -0
- package/react/ink-components/InkScrollView/utils/applyInkScrollInput.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/applyInkScrollInput.js +57 -0
- package/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.d.ts +7 -0
- package/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.js +19 -0
- package/react/ink-components/InkScrollView/utils/bounds/index.d.ts +3 -0
- package/react/ink-components/InkScrollView/utils/bounds/index.js +4 -0
- package/react/ink-components/InkScrollView/utils/bounds/isInside.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/bounds/isInside.js +7 -0
- package/react/ink-components/InkScrollView/utils/bounds/rowInViewport.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/bounds/rowInViewport.js +4 -0
- package/react/ink-components/InkScrollView/utils/inkScrollInputTarget.d.ts +11 -0
- package/react/ink-components/InkScrollView/utils/inkScrollInputTarget.js +0 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.d.ts +6 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.js +29 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/clampOffset.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/clampOffset.js +7 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.d.ts +5 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.js +14 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/index.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/index.js +11 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.js +12 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.js +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.d.ts +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.js +10 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.js +15 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.d.ts +9 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.js +7 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.js +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/stickToBottomOffset.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/stickToBottomOffset.js +4 -0
- package/react/ink-components/InkScrollView/utils/useInkScrollInput.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/useInkScrollInput.js +17 -0
- package/react/ink-components/InkTimer/InkTimer.d.ts +9 -0
- package/react/ink-components/InkTimer/InkTimer.js +26 -0
- package/react/ink-components/InkTimer/index.d.ts +1 -0
- package/react/ink-components/InkTimer/index.js +2 -0
- package/react/ink-components/index.d.ts +4 -0
- package/react/ink-components/index.js +34 -0
- package/vite-plugins/fileLinePlaceholderPlugin.d.ts +26 -0
- package/vite-plugins/fileLinePlaceholderPlugin.js +57 -0
- package/vite-plugins/index.d.ts +1 -0
- package/vite-plugins/index.js +2 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export * from './anyToString/index.js';
|
|
2
|
+
export * from './assertsType.js';
|
|
3
|
+
export * from './buildSequence.js';
|
|
4
|
+
export * from './tree/buildTree.js';
|
|
5
|
+
export * from './deepClone.js';
|
|
6
|
+
export * from './deepEqual.js';
|
|
7
|
+
export * from './deepParseJsonStrings.js';
|
|
8
|
+
export * from './dependsOn.js';
|
|
9
|
+
export * from './doExpr.js';
|
|
10
|
+
export * from './jsonRecord/filterJsonRecord.js';
|
|
11
|
+
export * from './flatChildren.js';
|
|
12
|
+
export * from './fuzzy/fuzzyMatch.js';
|
|
13
|
+
export * from './fuzzy/fuzzyMatchPath.js';
|
|
14
|
+
export * from './tree/flatTree.js';
|
|
15
|
+
export * from './formatDecimal.js';
|
|
16
|
+
export * from './formatFriendlyTime.js';
|
|
17
|
+
export * from './formatSize.js';
|
|
18
|
+
export * from './isEmptyRecord.js';
|
|
19
|
+
export * from './isNil.js';
|
|
20
|
+
export * from './isNonNil.js';
|
|
21
|
+
export * from './jsonRecord/isJsonRecord.js';
|
|
22
|
+
export * from './isRecord.js';
|
|
23
|
+
export * from './simpleInt/isSimpleInt.js';
|
|
24
|
+
export * from './simpleInt/isSimpleIntInputing.js';
|
|
25
|
+
export * from './simpleInt/isSimpleNumber.js';
|
|
26
|
+
export * from './simpleInt/isSimpleNumberInputing.js';
|
|
27
|
+
export * from './jsonRecord/mapJsonRecord.js';
|
|
28
|
+
export * from './tree/mapTree.js';
|
|
29
|
+
export * from './jsonRecord/modifyJsonRecord.js';
|
|
30
|
+
export * from './onlyUnique.js';
|
|
31
|
+
export * from './simpleInt/parseSimpleInt.js';
|
|
32
|
+
export * from './simpleInt/parseSimpleIntOrNil.js';
|
|
33
|
+
export * from './simpleInt/parseSimpleNumber.js';
|
|
34
|
+
export * from './simpleInt/parseSimpleNumberOrNil.js';
|
|
35
|
+
export * from './pipe.js';
|
|
36
|
+
export * from './pipeNonNil.js';
|
|
37
|
+
export * from './jsonRecord/jsonRecordDiff.js';
|
|
38
|
+
export * from './tree/pruneTree.js';
|
|
39
|
+
export * from './tree/sortTree.js';
|
|
40
|
+
export * from './SimpleType.js';
|
|
41
|
+
export * from './tap.js';
|
|
42
|
+
export * from './tree/treeToArray.js';
|
|
43
|
+
export * from './tree/treeToRows.js';
|
|
44
|
+
export * from './tree/treeTypes.js';
|
|
45
|
+
export * from './truncateJsonStrings.js';
|
|
46
|
+
export * from './truncateString.js';
|
|
47
|
+
export * from './tryParsePartialJson.js';
|
|
48
|
+
export * from './jsonRecord/walkJsonRecord.js';
|
|
49
|
+
export * from './tree/walkTree.js';
|
package/common/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fuzzyMatchPath as e } from "./fuzzy/fuzzyMatchPath.js";
|
|
2
|
+
import { fuzzyMatch as t } from "./fuzzy/fuzzyMatch.js";
|
|
3
|
+
import { formatSize as n } from "./formatSize.js";
|
|
4
|
+
import { truncateString as r } from "./truncateString.js";
|
|
5
|
+
import { anyToString as i } from "./anyToString/anyToString.js";
|
|
6
|
+
import { assertsType as a } from "./assertsType.js";
|
|
7
|
+
import { buildSequence as o } from "./buildSequence.js";
|
|
8
|
+
import { deepClone as s } from "./deepClone.js";
|
|
9
|
+
import { deepEqual as c } from "./deepEqual.js";
|
|
10
|
+
import { deepParseJsonStrings as l } from "./deepParseJsonStrings.js";
|
|
11
|
+
import { dependsOn as u } from "./dependsOn.js";
|
|
12
|
+
import { doExpr as d } from "./doExpr.js";
|
|
13
|
+
import { flatChildren as f } from "./flatChildren.js";
|
|
14
|
+
import { formatDecimal as p } from "./formatDecimal.js";
|
|
15
|
+
import { formatFriendlyTime as m } from "./formatFriendlyTime.js";
|
|
16
|
+
import { isNonNil as h } from "./isNonNil.js";
|
|
17
|
+
import { buildTree as g } from "./tree/buildTree.js";
|
|
18
|
+
import { isRecord as _ } from "./isRecord.js";
|
|
19
|
+
import { isJsonRecord as v } from "./jsonRecord/isJsonRecord.js";
|
|
20
|
+
import { filterJsonRecord as y } from "./jsonRecord/filterJsonRecord.js";
|
|
21
|
+
import { flatTree as b } from "./tree/flatTree.js";
|
|
22
|
+
import { isEmptyRecord as x } from "./isEmptyRecord.js";
|
|
23
|
+
import { isNil as S } from "./isNil.js";
|
|
24
|
+
import { isSimpleInt as C } from "./simpleInt/isSimpleInt.js";
|
|
25
|
+
import { isSimpleIntInputing as w } from "./simpleInt/isSimpleIntInputing.js";
|
|
26
|
+
import { isSimpleNumber as T } from "./simpleInt/isSimpleNumber.js";
|
|
27
|
+
import { isSimpleNumberInputing as E } from "./simpleInt/isSimpleNumberInputing.js";
|
|
28
|
+
import { mapJsonRecord as D } from "./jsonRecord/mapJsonRecord.js";
|
|
29
|
+
import { mapTree as O } from "./tree/mapTree.js";
|
|
30
|
+
import { modifyJsonRecord as k } from "./jsonRecord/modifyJsonRecord.js";
|
|
31
|
+
import { onlyUnique as A } from "./onlyUnique.js";
|
|
32
|
+
import { parseSimpleIntOrNil as j } from "./simpleInt/parseSimpleIntOrNil.js";
|
|
33
|
+
import { parseSimpleInt as M } from "./simpleInt/parseSimpleInt.js";
|
|
34
|
+
import { parseSimpleNumberOrNil as N } from "./simpleInt/parseSimpleNumberOrNil.js";
|
|
35
|
+
import { parseSimpleNumber as P } from "./simpleInt/parseSimpleNumber.js";
|
|
36
|
+
import { pipe as F } from "./pipe.js";
|
|
37
|
+
import { pipeNonNil as I } from "./pipeNonNil.js";
|
|
38
|
+
import { jsonRecordDiff as L } from "./jsonRecord/jsonRecordDiff.js";
|
|
39
|
+
import { pruneTree as R } from "./tree/pruneTree.js";
|
|
40
|
+
import { sortTree as z } from "./tree/sortTree.js";
|
|
41
|
+
import { tap as B } from "./tap.js";
|
|
42
|
+
import { treeToArray as V } from "./tree/treeToArray.js";
|
|
43
|
+
import { treeToRows as H } from "./tree/treeToRows.js";
|
|
44
|
+
import { truncateJsonStrings as U } from "./truncateJsonStrings.js";
|
|
45
|
+
import { tryParsePartialJson as W } from "./tryParsePartialJson.js";
|
|
46
|
+
import { walkJsonRecord as G } from "./jsonRecord/walkJsonRecord.js";
|
|
47
|
+
import { walkTree as K } from "./tree/walkTree.js";
|
|
48
|
+
export { i as anyToString, a as assertsType, o as buildSequence, g as buildTree, s as deepClone, c as deepEqual, l as deepParseJsonStrings, u as dependsOn, d as doExpr, y as filterJsonRecord, f as flatChildren, b as flatTree, p as formatDecimal, m as formatFriendlyTime, n as formatSize, t as fuzzyMatch, e as fuzzyMatchPath, x as isEmptyRecord, v as isJsonRecord, S as isNil, h as isNonNil, _ as isRecord, C as isSimpleInt, w as isSimpleIntInputing, T as isSimpleNumber, E as isSimpleNumberInputing, L as jsonRecordDiff, D as mapJsonRecord, O as mapTree, k as modifyJsonRecord, A as onlyUnique, M as parseSimpleInt, j as parseSimpleIntOrNil, P as parseSimpleNumber, N as parseSimpleNumberOrNil, F as pipe, I as pipeNonNil, R as pruneTree, z as sortTree, B as tap, V as treeToArray, H as treeToRows, U as truncateJsonStrings, r as truncateString, W as tryParsePartialJson, G as walkJsonRecord, K as walkTree };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the value is `null`, `undefined`, or a record with no own keys.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isEmptyRecord({}) // true
|
|
7
|
+
* isEmptyRecord({ a: 1 }) // false
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function isEmptyRecord(value: unknown): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the value is `null` or `undefined`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isNil(undefined) // true
|
|
7
|
+
* isNil(null) // true
|
|
8
|
+
* isNil('hello') // false
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function isNil(arg: undefined): arg is undefined;
|
|
12
|
+
export declare function isNil(arg: null): arg is null;
|
|
13
|
+
export declare function isNil<T>(arg: T | undefined | null): arg is undefined | null;
|
package/common/isNil.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the value is neither `null` nor `undefined`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isNonNil(1) // true
|
|
7
|
+
* isNonNil(undefined) // false
|
|
8
|
+
* isNonNil(null) // false
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function isNonNil<T>(arg: T | undefined | null): arg is T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the value is a key-value record with `Object.prototype`
|
|
3
|
+
* or a `null` prototype.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* isRecord({ a: 1 }) // true
|
|
8
|
+
* isRecord(Object.create(null)) // true
|
|
9
|
+
* isRecord([]) // false
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type FilterJsonRecordFn = (key: string, value: unknown) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Filters keys from a JSON-like record, with optional deep traversal into nested
|
|
4
|
+
* records and arrays.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* filterJsonRecord({ a: 1, b: 'x' }, (key, value) => typeof value === 'number')
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function filterJsonRecord<T extends Record<string, unknown>>(obj: T, filterFn: FilterJsonRecordFn, options?: {
|
|
12
|
+
deep?: boolean;
|
|
13
|
+
}): T;
|
|
14
|
+
export declare function filterJsonRecord<T>(obj: T, filterFn: FilterJsonRecordFn, options?: {
|
|
15
|
+
deep?: boolean;
|
|
16
|
+
}): T | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isNonNil as e } from "../isNonNil.js";
|
|
2
|
+
import { isJsonRecord as t } from "./isJsonRecord.js";
|
|
3
|
+
//#region src/common/jsonRecord/filterJsonRecord.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return t(e) && Object.keys(e).length === 0;
|
|
6
|
+
}
|
|
7
|
+
function r(i, a, o = {}) {
|
|
8
|
+
let { deep: s } = o;
|
|
9
|
+
if (s && Array.isArray(i)) return i.map((e) => r(e, a, o)).filter((t) => e(t) && !n(t));
|
|
10
|
+
if (t(i)) {
|
|
11
|
+
let t = Object.entries(i).map(([e, t]) => {
|
|
12
|
+
let n = s ? r(t, a, o) : void 0;
|
|
13
|
+
return n ? [e, n] : a(e, t) ? [e, t] : void 0;
|
|
14
|
+
}).filter((t) => e(t));
|
|
15
|
+
return Object.fromEntries(t);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as filterJsonRecord };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the value is a JSON-like record tree:
|
|
3
|
+
* - top-level value is a record with `Object.prototype` or a `null` prototype
|
|
4
|
+
* - nested values contain only JSON-compatible primitives, arrays, and records
|
|
5
|
+
* - nested objects and arrays are unique and acyclic
|
|
6
|
+
*
|
|
7
|
+
* This is the structural entry check used by json-record helpers that assume
|
|
8
|
+
* a tree-shaped JSON object instead of shared references or circular graphs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isJsonRecord({ a: 1, items: [true, null] }) // true
|
|
13
|
+
* isJsonRecord([]) // false
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function isJsonRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isRecord as e } from "../isRecord.js";
|
|
2
|
+
//#region src/common/jsonRecord/isJsonRecord.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
return typeof e == "number" && Number.isFinite(e);
|
|
5
|
+
}
|
|
6
|
+
function n(e) {
|
|
7
|
+
return e === null || typeof e == "boolean" || typeof e == "string" || t(e);
|
|
8
|
+
}
|
|
9
|
+
function r(t, i) {
|
|
10
|
+
return n(t) ? !0 : typeof t != "object" || t === void 0 || i.has(t) ? !1 : (i.add(t), Array.isArray(t) ? t.every((e) => r(e, i)) : e(t) ? Object.values(t).every((e) => r(e, i)) : !1);
|
|
11
|
+
}
|
|
12
|
+
function i(t) {
|
|
13
|
+
return e(t) && r(t, /* @__PURE__ */ new WeakSet());
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as isJsonRecord };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diffs two JSON-like records and keeps only the current shape while marking unchanged,
|
|
3
|
+
* removed, and array-prefix portions in a compact readable form.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* jsonRecordDiff(
|
|
8
|
+
* { name: 'next', items: [1, 2, 4] },
|
|
9
|
+
* { name: 'prev', items: [1, 2, 3] },
|
|
10
|
+
* )
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function jsonRecordDiff(current: Record<string, unknown>, previous: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { deepEqual as e } from "../deepEqual.js";
|
|
2
|
+
import { isJsonRecord as t } from "./isJsonRecord.js";
|
|
3
|
+
//#region src/common/jsonRecord/jsonRecordDiff.ts
|
|
4
|
+
var n = "...", r = "... removed";
|
|
5
|
+
function i(e) {
|
|
6
|
+
return `... removed ${e} items`;
|
|
7
|
+
}
|
|
8
|
+
function a(t, n) {
|
|
9
|
+
let r = 0;
|
|
10
|
+
for (; r < t.length && r < n.length && e(t[r], n[r]);) r += 1;
|
|
11
|
+
let a = [];
|
|
12
|
+
r > 0 && a.push(`... common ${r} items`);
|
|
13
|
+
let o = n.slice(r);
|
|
14
|
+
return o.length > 0 && a.push({ [i(o.length)]: o }), a.push(...t.slice(r)), a;
|
|
15
|
+
}
|
|
16
|
+
function o(r, i) {
|
|
17
|
+
return e(r, i) ? n : Array.isArray(r) && Array.isArray(i) ? a(r, i) : t(r) && t(i) ? s(r, i) : r;
|
|
18
|
+
}
|
|
19
|
+
function s(e, t) {
|
|
20
|
+
let n = [], i = /* @__PURE__ */ new Set();
|
|
21
|
+
for (let [r, a] of Object.entries(e)) i.add(r), n.push([r, r in t ? o(a, t[r]) : a]);
|
|
22
|
+
for (let e of Object.keys(t)) i.has(e) || n.push([e, r]);
|
|
23
|
+
return Object.fromEntries(n);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { s as jsonRecordDiff };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MapJsonRecordFn = (key: string, value: unknown) => [string, unknown] | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Maps keys and values in a JSON-like record, with optional deep traversal into
|
|
4
|
+
* nested records and arrays.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* mapJsonRecord({ a: 1 }, (key, value) => [`${key}!`, value])
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function mapJsonRecord<T, U = T>(obj: T, mapFn: MapJsonRecordFn, options?: {
|
|
12
|
+
deep?: boolean;
|
|
13
|
+
}): U;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isNonNil as e } from "../isNonNil.js";
|
|
2
|
+
import { isJsonRecord as t } from "./isJsonRecord.js";
|
|
3
|
+
//#region src/common/jsonRecord/mapJsonRecord.ts
|
|
4
|
+
function n(r, i, a = {}) {
|
|
5
|
+
let { deep: o } = a;
|
|
6
|
+
if (o && Array.isArray(r)) return r.map((e) => n(e, i, a));
|
|
7
|
+
if (t(r)) {
|
|
8
|
+
let t = Object.entries(r).map(([e, t]) => i(e, o ? n(t, i, a) : t)).filter((t) => e(t));
|
|
9
|
+
return Object.fromEntries(t);
|
|
10
|
+
}
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as mapJsonRecord };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ModifyJsonRecordFn = (key: string, value: unknown) => [string, unknown] | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Mutates a JSON-like record in place, with optional deep traversal into nested
|
|
4
|
+
* records and arrays.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const data = { a: 1 }
|
|
9
|
+
* modifyJsonRecord(data, (key, value) => [key, Number(value) + 1])
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function modifyJsonRecord(obj: unknown, modifyFn: ModifyJsonRecordFn, options?: {
|
|
13
|
+
deep?: boolean;
|
|
14
|
+
}): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isJsonRecord as e } from "./isJsonRecord.js";
|
|
2
|
+
//#region src/common/jsonRecord/modifyJsonRecord.ts
|
|
3
|
+
function t(n, r, i = {}) {
|
|
4
|
+
let { deep: a } = i;
|
|
5
|
+
if (a && Array.isArray(n)) {
|
|
6
|
+
n.forEach((e) => {
|
|
7
|
+
t(e, r, i);
|
|
8
|
+
});
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (e(n)) for (let e of Object.keys(n)) {
|
|
12
|
+
let o = n[e];
|
|
13
|
+
a && t(o, r, i);
|
|
14
|
+
let s = r(e, o);
|
|
15
|
+
if (s === void 0) {
|
|
16
|
+
delete n[e];
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
let [c, l] = s;
|
|
20
|
+
delete n[e], n[c] = l;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as modifyJsonRecord };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type WalkJsonRecordFn = (key: string | number, value: unknown) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Walks through keys in a JSON-like record, with optional deep traversal into nested
|
|
4
|
+
* records and arrays.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* walkJsonRecord({ a: 1 }, (key, value) => {
|
|
9
|
+
* console.log(key, value)
|
|
10
|
+
* })
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function walkJsonRecord<T>(obj: T, walkFn: WalkJsonRecordFn, options?: {
|
|
14
|
+
deep?: boolean;
|
|
15
|
+
}): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isJsonRecord as e } from "./isJsonRecord.js";
|
|
2
|
+
//#region src/common/jsonRecord/walkJsonRecord.ts
|
|
3
|
+
function t(n, r, i = {}) {
|
|
4
|
+
let { deep: a } = i;
|
|
5
|
+
if (a && Array.isArray(n)) {
|
|
6
|
+
n.forEach((e, n) => {
|
|
7
|
+
r(n, e), t(e, r, i);
|
|
8
|
+
});
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
e(n) && Object.entries(n).forEach(([e, n]) => {
|
|
12
|
+
r(e, n), a && t(n, r, i);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as walkJsonRecord };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Predicate for `Array.prototype.filter` that keeps only the first occurrence.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const values = [1, 1, 2, 3, 2]
|
|
7
|
+
* const uniqueValues = values.filter(onlyUnique)
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function onlyUnique<T>(item: T, index: number, items: T[]): boolean;
|
package/common/pipe.d.ts
ADDED
package/common/pipe.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passes a value into a function only when the value is not `null` or `undefined`.
|
|
3
|
+
*
|
|
4
|
+
* When the input is nil, it is returned as-is.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* pipeNonNil('hello', (text) => text.length) // 5
|
|
9
|
+
* pipeNonNil(undefined, (text) => text.length) // undefined
|
|
10
|
+
* pipeNonNil(null, (text) => text.length) // null
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function pipeNonNil<T, K>(data: T, fn: (it: T) => K): K;
|
|
14
|
+
export declare function pipeNonNil<T, K>(data: T | undefined, fn: (it: T) => K): K | undefined;
|
|
15
|
+
export declare function pipeNonNil<T, K>(data: T | null, fn: (it: T) => K): K | null;
|
|
16
|
+
export declare function pipeNonNil<T, K>(data: T | undefined | null, fn: (it: T) => K): K | undefined | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SafeJsonStringifyOptions {
|
|
2
|
+
spaces?: number;
|
|
3
|
+
}
|
|
4
|
+
export interface SafeJsonCircularRef {
|
|
5
|
+
$ref: string;
|
|
6
|
+
$type: "circular";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Safely stringifies any value to JSON.
|
|
10
|
+
*
|
|
11
|
+
* The first occurrence of an object is serialized normally. Later references to the
|
|
12
|
+
* same object are replaced with a circular marker object so the output stays valid JSON.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const shared = { id: 1 }
|
|
17
|
+
*
|
|
18
|
+
* safeJsonStringify({
|
|
19
|
+
* first: shared,
|
|
20
|
+
* second: shared,
|
|
21
|
+
* })
|
|
22
|
+
* // {
|
|
23
|
+
* // "first": { "id": 1 },
|
|
24
|
+
* // "second": { "$type": "circular", "$ref": "$.first" }
|
|
25
|
+
* // }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function safeJsonStringify(value: unknown, options?: SafeJsonStringifyOptions): string;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createObjectReferenceTracker as e } from "./_internal/createObjectReferenceTracker.js";
|
|
2
|
+
import { getEnumerableOwnDescriptors as t } from "./getEnumerableOwnDescriptors.js";
|
|
3
|
+
import { anyToString as n } from "./anyToString/anyToString.js";
|
|
4
|
+
import { isJsonRecord as r } from "./jsonRecord/isJsonRecord.js";
|
|
5
|
+
//#region src/common/safeJsonStringify.ts
|
|
6
|
+
function i(t, n = {}) {
|
|
7
|
+
return JSON.stringify(o(t, "$", { referenceTracker: e() }), null, a(n.spaces));
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
return typeof e != "number" || !Number.isFinite(e) ? 0 : Math.max(0, Math.floor(e));
|
|
11
|
+
}
|
|
12
|
+
function o(e, t, n) {
|
|
13
|
+
if (e === null) return null;
|
|
14
|
+
if (e === void 0) return "[undefined]";
|
|
15
|
+
switch (typeof e) {
|
|
16
|
+
case "string": return e;
|
|
17
|
+
case "boolean": return e;
|
|
18
|
+
case "number": return Number.isFinite(e) ? e : String(e);
|
|
19
|
+
case "bigint": return `${e}n`;
|
|
20
|
+
case "symbol": return String(e);
|
|
21
|
+
case "function": return `[Function ${e.name || "anonymous"}]`;
|
|
22
|
+
case "object": return s(e, t, n);
|
|
23
|
+
default: return String(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function s(e, t, r) {
|
|
27
|
+
let i = r.referenceTracker.remember(e, t);
|
|
28
|
+
return i ? {
|
|
29
|
+
$ref: i,
|
|
30
|
+
$type: "circular"
|
|
31
|
+
} : e instanceof Date ? Number.isNaN(e.getTime()) ? "Invalid Date" : e.toISOString() : e instanceof RegExp ? String(e) : e instanceof Error ? c(e, t, r) : typeof URL < "u" && e instanceof URL ? e.href : p(e) ? "[Promise]" : m(e) ? n(e) : Array.isArray(e) ? e.map((e, n) => o(e, `${t}[${n}]`, r)) : e instanceof Map ? {
|
|
32
|
+
$type: "Map",
|
|
33
|
+
entries: Array.from(e.entries()).map(([e, n], i) => [o(e, `${t}.entries[${i}][0]`, r), o(n, `${t}.entries[${i}][1]`, r)])
|
|
34
|
+
} : e instanceof Set ? {
|
|
35
|
+
$type: "Set",
|
|
36
|
+
values: Array.from(e.values()).map((e, n) => o(e, `${t}.values[${n}]`, r))
|
|
37
|
+
} : ArrayBuffer.isView(e) ? l(e, t, r) : e instanceof ArrayBuffer ? {
|
|
38
|
+
$type: "ArrayBuffer",
|
|
39
|
+
byteLength: e.byteLength
|
|
40
|
+
} : u(e, t, r);
|
|
41
|
+
}
|
|
42
|
+
function c(e, t, n) {
|
|
43
|
+
let r = {
|
|
44
|
+
$type: e.name || "Error",
|
|
45
|
+
message: e.message
|
|
46
|
+
};
|
|
47
|
+
e.stack && (r.stack = e.stack.split("\n")[0] || e.stack), "cause" in e && e.cause !== void 0 && (r.cause = o(e.cause, `${t}.cause`, n));
|
|
48
|
+
for (let i of Object.keys(e)) i in r || (r[i] = o(e[i], d(t, i), n));
|
|
49
|
+
return r;
|
|
50
|
+
}
|
|
51
|
+
function l(e, t, n) {
|
|
52
|
+
return e instanceof DataView ? {
|
|
53
|
+
$type: "DataView",
|
|
54
|
+
byteLength: e.byteLength
|
|
55
|
+
} : {
|
|
56
|
+
$type: e.constructor.name || "TypedArray",
|
|
57
|
+
values: Array.from(e).map((e, r) => o(e, `${t}.values[${r}]`, n))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function u(e, n, i) {
|
|
61
|
+
let a = {}, s = e.constructor?.name;
|
|
62
|
+
s && s !== "Object" && !r(e) && (a.$type = s);
|
|
63
|
+
for (let [r, s] of t(e)) {
|
|
64
|
+
let e = f(r);
|
|
65
|
+
if ("value" in s) {
|
|
66
|
+
a[e] = o(s.value, d(n, e), i);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (s.get && s.set) {
|
|
70
|
+
a[e] = "[Getter/Setter]";
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (s.get) {
|
|
74
|
+
a[e] = "[Getter]";
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
a[e] = "[Setter]";
|
|
78
|
+
}
|
|
79
|
+
return a;
|
|
80
|
+
}
|
|
81
|
+
function d(e, t) {
|
|
82
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(t) ? `${e}.${t}` : `${e}[${JSON.stringify(t)}]`;
|
|
83
|
+
}
|
|
84
|
+
function f(e) {
|
|
85
|
+
return typeof e == "symbol" ? `[${String(e)}]` : String(e);
|
|
86
|
+
}
|
|
87
|
+
function p(e) {
|
|
88
|
+
return "then" in e && typeof e.then == "function";
|
|
89
|
+
}
|
|
90
|
+
function m(e) {
|
|
91
|
+
return h(e) || g(e) || _(e);
|
|
92
|
+
}
|
|
93
|
+
function h(e) {
|
|
94
|
+
let t = Object.prototype.toString.call(e);
|
|
95
|
+
return t === "[object Window]" || t === "[object global]" && "window" in e && e.window === e && "document" in e;
|
|
96
|
+
}
|
|
97
|
+
function g(e) {
|
|
98
|
+
let t = Object.prototype.toString.call(e);
|
|
99
|
+
return t === "[object Document]" || t === "[object HTMLDocument]" || "nodeType" in e && e.nodeType === 9;
|
|
100
|
+
}
|
|
101
|
+
function _(e) {
|
|
102
|
+
return "nodeType" in e && e.nodeType === 1 && "tagName" in e;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { i as safeJsonStringify };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the string is a simple integer: `0` or a signed non-zero integer without leading zeros.
|
|
3
|
+
*
|
|
4
|
+
* This intentionally rejects `+1`, `01`, `-0`, and scientific notation.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isSimpleInt(str: string | null | undefined): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the string is a plain decimal number without exponent notation.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* isSimpleNumber('12.3') // true
|
|
7
|
+
* isSimpleNumber('1e2') // false
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSimpleNumber(str: string): boolean;
|