ansuko 1.2.9 → 1.2.11
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.ja.md +0 -1
- package/README.md +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -3
- package/package.json +1 -1
package/README.ja.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# ansuko
|
|
2
2
|
|
|
3
|
-
[](https://github.com/sera4am/ansuko/actions/workflows/ci.yml)
|
|
4
3
|
|
|
5
4
|
A modern JavaScript/TypeScript utility library that extends lodash with practical, intuitive behaviors.
|
|
6
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -96,12 +96,14 @@ declare const parseJSON: <T = any>(str: string | object) => T | null;
|
|
|
96
96
|
/**
|
|
97
97
|
* Stringifies objects/arrays; returns null for strings or numbers.
|
|
98
98
|
* @param obj - Target object
|
|
99
|
+
* @param replacer — A function that transforms the results.
|
|
100
|
+
* @param space - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
99
101
|
* @returns JSON string or null
|
|
100
102
|
* @example jsonStringify({a:1}) // '{"a":1}'
|
|
101
103
|
* @example jsonStringify('{a:1}') // '{"a":1}' (normalize)
|
|
102
104
|
* @category Conversion
|
|
103
105
|
*/
|
|
104
|
-
declare const jsonStringify: <T = any>(obj: T) => string | null;
|
|
106
|
+
declare const jsonStringify: <T = any>(obj: T, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined) => string | null;
|
|
105
107
|
/**
|
|
106
108
|
* Casts value to array; null/undefined become [] (not [null]).
|
|
107
109
|
* @param value - Value
|
package/dist/index.js
CHANGED
|
@@ -329,19 +329,21 @@ const parseJSON = (str) => {
|
|
|
329
329
|
/**
|
|
330
330
|
* Stringifies objects/arrays; returns null for strings or numbers.
|
|
331
331
|
* @param obj - Target object
|
|
332
|
+
* @param replacer — A function that transforms the results.
|
|
333
|
+
* @param space - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
332
334
|
* @returns JSON string or null
|
|
333
335
|
* @example jsonStringify({a:1}) // '{"a":1}'
|
|
334
336
|
* @example jsonStringify('{a:1}') // '{"a":1}' (normalize)
|
|
335
337
|
* @category Conversion
|
|
336
338
|
*/
|
|
337
|
-
const jsonStringify = (obj) => {
|
|
339
|
+
const jsonStringify = (obj, replacer, space) => {
|
|
338
340
|
if (_.isNil(obj)) {
|
|
339
341
|
return null;
|
|
340
342
|
}
|
|
341
343
|
if (typeof obj === "string") {
|
|
342
344
|
try {
|
|
343
345
|
const j = JSON5.parse(obj);
|
|
344
|
-
return JSON.stringify(j);
|
|
346
|
+
return JSON.stringify(j, replacer, space);
|
|
345
347
|
}
|
|
346
348
|
catch {
|
|
347
349
|
return null;
|
|
@@ -349,7 +351,7 @@ const jsonStringify = (obj) => {
|
|
|
349
351
|
}
|
|
350
352
|
if (typeof obj === "object") {
|
|
351
353
|
try {
|
|
352
|
-
return JSON.stringify(obj);
|
|
354
|
+
return JSON.stringify(obj, replacer, space);
|
|
353
355
|
}
|
|
354
356
|
catch {
|
|
355
357
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ansuko",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "A modern JavaScript/TypeScript utility library that extends lodash with practical, intuitive behaviors. Fixes lodash quirks, adds Promise support, Japanese text processing, and GeoJSON utilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lodash",
|