@stryke/json 0.7.0 â 0.7.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 +2 -1
- package/dist/utils/stringify.cjs +6 -5
- package/dist/utils/stringify.mjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This package is part of Storm Software's **đŠī¸ Stryke** monorepo. Stryke pac
|
|
|
22
22
|
|
|
23
23
|
<h3 align="center">đģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
24
24
|
|
|
25
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
26
26
|
|
|
27
27
|
> [!IMPORTANT] This repository, and the apps, libraries, and tools contained
|
|
28
28
|
> within, is still in it's initial development phase. As a result, bugs and
|
|
@@ -52,6 +52,7 @@ flexibility and customization.
|
|
|
52
52
|
|
|
53
53
|
<!-- START doctoc -->
|
|
54
54
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
55
|
+
|
|
55
56
|
## Table of Contents
|
|
56
57
|
|
|
57
58
|
- [Installing](#installing)
|
package/dist/utils/stringify.cjs
CHANGED
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.stringify = void 0;
|
|
7
7
|
var _isNumber = require("@stryke/type-checks/is-number");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var _isUndefined = require("@stryke/type-checks/is-undefined");
|
|
9
|
+
const stringify = (r, e = 2) => {
|
|
10
|
+
const n = (0, _isNumber.isNumber)(e) ? " ".repeat(e) : e;
|
|
10
11
|
switch (r) {
|
|
11
12
|
case null:
|
|
12
13
|
return "null";
|
|
@@ -21,7 +22,7 @@ const stringify = (r, t = 2) => {
|
|
|
21
22
|
case Number.NEGATIVE_INFINITY:
|
|
22
23
|
return "-infinity";
|
|
23
24
|
}
|
|
24
|
-
if (Array.isArray(r)) return `[${n}${r.map(
|
|
25
|
+
if (Array.isArray(r)) return `[${n}${r.map(i => stringify(i, n)).join(`,${n}`)}${n}]`;
|
|
25
26
|
if (r instanceof Uint8Array) return r.toString();
|
|
26
27
|
switch (typeof r) {
|
|
27
28
|
case "number":
|
|
@@ -30,8 +31,8 @@ const stringify = (r, t = 2) => {
|
|
|
30
31
|
return JSON.stringify(r);
|
|
31
32
|
case "object":
|
|
32
33
|
{
|
|
33
|
-
const
|
|
34
|
-
return `{${n}${
|
|
34
|
+
const i = Object.keys(r).filter(t => !(0, _isUndefined.isUndefined)(r[t]));
|
|
35
|
+
return `{${n}${i.map(t => `${t}: ${n}${stringify(r[t], n)}`).join(`,${n}`)}${n}}`;
|
|
35
36
|
}
|
|
36
37
|
default:
|
|
37
38
|
return "null";
|
package/dist/utils/stringify.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNumber as
|
|
1
|
+
import{isNumber as s}from"@stryke/type-checks/is-number";import{isUndefined as c}from"@stryke/type-checks/is-undefined";export const stringify=(r,e=2)=>{const n=s(e)?" ".repeat(e):e;switch(r){case null:return"null";case void 0:return'"undefined"';case!0:return"true";case!1:return"false";case Number.POSITIVE_INFINITY:return"infinity";case Number.NEGATIVE_INFINITY:return"-infinity"}if(Array.isArray(r))return`[${n}${r.map(i=>stringify(i,n)).join(`,${n}`)}${n}]`;if(r instanceof Uint8Array)return r.toString();switch(typeof r){case"number":return`${r}`;case"string":return JSON.stringify(r);case"object":{const i=Object.keys(r).filter(t=>!c(r[t]));return`{${n}${i.map(t=>`${t}: ${n}${stringify(r[t],n)}`).join(`,${n}`)}${n}}`}default:return"null"}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/json",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing JSON parsing/stringify utilities used by Storm Software.",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"jsonc-parser": "3.3.1",
|
|
15
15
|
"lines-and-columns": "2.0.4",
|
|
16
16
|
"superjson": "2.2.2",
|
|
17
|
-
"@stryke/type-checks": "^0.2
|
|
18
|
-
"@stryke/types": "^0.
|
|
17
|
+
"@stryke/type-checks": "^0.3.2",
|
|
18
|
+
"@stryke/types": "^0.8.1"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": { "access": "public" },
|
|
21
21
|
"devDependencies": {},
|