@bluelovers/fs-json 1.0.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.3 (2021-12-29)
7
+
8
+
9
+ ### đŸ”–ă€€Miscellaneous
10
+
11
+ * . ([c60df45](https://github.com/bluelovers/ws-iconv/commit/c60df451cb6728e0c28522bba043feaad4a883e0))
12
+ * . ([526ff7c](https://github.com/bluelovers/ws-iconv/commit/526ff7c919a83f407386c2e872170813bfc575d0))
13
+ * stringify with final EOL ([a8a12fc](https://github.com/bluelovers/ws-iconv/commit/a8a12fc59eff65b35a568084d027807d9d1b0a34))
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # README.md
2
+
3
+
4
+
5
+ ## install
6
+
7
+ ```bash
8
+ yarn add @bluelovers/fs-json
9
+ yarn-tool add @bluelovers/fs-json
10
+ yt add @bluelovers/fs-json
11
+ ```
12
+
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { readJSON, readJSONSync, WriteOptions } from 'fs-extra';
2
+ import { JFWriteOptions } from 'jsonfile';
3
+ declare module 'fs-extra' {
4
+ interface WriteOptions extends Exclude<JFWriteOptions, string | null> {
5
+ finalEOL?: boolean;
6
+ }
7
+ }
8
+ export declare type IWriteOptions = WriteOptions & Exclude<JFWriteOptions, string | null>;
9
+ export declare function _handleWriteOptions(options?: IWriteOptions): IWriteOptions;
10
+ export { readJSON, readJSONSync, };
11
+ export declare function outputJSON(file: string, data: any, options?: IWriteOptions): Promise<void>;
12
+ export declare function outputJSONSync(file: string, data: any, options?: IWriteOptions): void;
13
+ export declare function writeJSON(file: string, data: any, options?: IWriteOptions): Promise<void>;
14
+ export declare function writeJSONSync(file: string, data: any, options?: IWriteOptions): void;
15
+ export declare function stringifyJSON(data: any, options?: IWriteOptions): string;
16
+ export declare function parseJSON(stringOrUint8Array: string | Uint8Array, reviver?: (this: any, key: string, value: any) => any): string;
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseJSON = exports.stringifyJSON = exports.writeJSONSync = exports.writeJSON = exports.outputJSONSync = exports.outputJSON = exports.readJSONSync = exports.readJSON = exports._handleWriteOptions = void 0;
4
+ const fs_extra_1 = require("fs-extra");
5
+ Object.defineProperty(exports, "readJSON", { enumerable: true, get: function () { return fs_extra_1.readJSON; } });
6
+ Object.defineProperty(exports, "readJSONSync", { enumerable: true, get: function () { return fs_extra_1.readJSONSync; } });
7
+ const utils_1 = require("jsonfile/utils");
8
+ function _handleWriteOptions(options) {
9
+ var _a;
10
+ options !== null && options !== void 0 ? options : (options = {});
11
+ (_a = options.finalEOL) !== null && _a !== void 0 ? _a : (options.finalEOL = true);
12
+ return options;
13
+ }
14
+ exports._handleWriteOptions = _handleWriteOptions;
15
+ function outputJSON(file, data, options) {
16
+ options = _handleWriteOptions(options);
17
+ return (0, fs_extra_1.outputJSON)(file, data, options);
18
+ }
19
+ exports.outputJSON = outputJSON;
20
+ function outputJSONSync(file, data, options) {
21
+ options = _handleWriteOptions(options);
22
+ return (0, fs_extra_1.outputJSONSync)(file, data, options);
23
+ }
24
+ exports.outputJSONSync = outputJSONSync;
25
+ function writeJSON(file, data, options) {
26
+ options = _handleWriteOptions(options);
27
+ return (0, fs_extra_1.writeJSON)(file, data, options);
28
+ }
29
+ exports.writeJSON = writeJSON;
30
+ function writeJSONSync(file, data, options) {
31
+ options = _handleWriteOptions(options);
32
+ return (0, fs_extra_1.writeJSONSync)(file, data, options);
33
+ }
34
+ exports.writeJSONSync = writeJSONSync;
35
+ function stringifyJSON(data, options) {
36
+ options = _handleWriteOptions(options);
37
+ return (0, utils_1.stringify)(data, options);
38
+ }
39
+ exports.stringifyJSON = stringifyJSON;
40
+ function parseJSON(stringOrUint8Array, reviver) {
41
+ return JSON.parse(stringOrUint8Array.toString(), reviver);
42
+ }
43
+ exports.parseJSON = parseJSON;
44
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uCAQkB;AAsBjB,yFA3BA,mBAAQ,OA2BA;AACR,6FA3BA,uBAAY,OA2BA;AAtBb,0CAA2C;AAa3C,SAAgB,mBAAmB,CAAC,OAAuB;;IAE1D,OAAO,aAAP,OAAO,cAAP,OAAO,IAAP,OAAO,GAAK,EAAE,EAAC;IACf,MAAA,OAAO,CAAC,QAAQ,oCAAhB,OAAO,CAAC,QAAQ,GAAK,IAAI,EAAC;IAC1B,OAAO,OAAO,CAAA;AACf,CAAC;AALD,kDAKC;AAOD,SAAgB,UAAU,CAAC,IAAY,EAAE,IAAS,EAAE,OAAuB;IAE1E,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,IAAA,qBAAW,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC;AAJD,gCAIC;AAED,SAAgB,cAAc,CAAC,IAAY,EAAE,IAAS,EAAE,OAAuB;IAE9E,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,IAAA,yBAAe,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC;AAJD,wCAIC;AAED,SAAgB,SAAS,CAAC,IAAY,EAAE,IAAS,EAAE,OAAuB;IAEzE,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,IAAA,oBAAU,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAJD,8BAIC;AAED,SAAgB,aAAa,CAAC,IAAY,EAAE,IAAS,EAAE,OAAuB;IAE7E,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,IAAA,wBAAc,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC;AAJD,sCAIC;AAED,SAAgB,aAAa,CAAC,IAAS,EAAE,OAAuB;IAE/D,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,IAAA,iBAAS,EAAC,IAAI,EAAE,OAAc,CAAC,CAAA;AACvC,CAAC;AAJD,sCAIC;AAED,SAAgB,SAAS,CAAC,kBAAuC,EAChE,OAAqD;IAGrD,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC;AALD,8BAKC","sourcesContent":["import {\n\toutputJSON as _outputJSON,\n\toutputJSONSync as _outputJSONSync,\n\treadJSON,\n\treadJSONSync,\n\twriteJSON as _writeJSON,\n\twriteJSONSync as _writeJSONSync,\n\tWriteOptions,\n} from 'fs-extra';\nimport { stringify } from 'jsonfile/utils';\nimport { JFWriteOptions } from 'jsonfile';\n\ndeclare module 'fs-extra'\n{\n\tinterface WriteOptions extends Exclude<JFWriteOptions, string | null>\n\t{\n\t\tfinalEOL?: boolean\n\t}\n}\n\nexport type IWriteOptions = WriteOptions & Exclude<JFWriteOptions, string | null>;\n\nexport function _handleWriteOptions(options?: IWriteOptions): IWriteOptions\n{\n\toptions ??= {};\n\toptions.finalEOL ??= true;\n\treturn options\n}\n\nexport {\n\treadJSON,\n\treadJSONSync,\n}\n\nexport function outputJSON(file: string, data: any, options?: IWriteOptions)\n{\n\toptions = _handleWriteOptions(options);\n\treturn _outputJSON(file, data, options)\n}\n\nexport function outputJSONSync(file: string, data: any, options?: IWriteOptions)\n{\n\toptions = _handleWriteOptions(options);\n\treturn _outputJSONSync(file, data, options)\n}\n\nexport function writeJSON(file: string, data: any, options?: IWriteOptions)\n{\n\toptions = _handleWriteOptions(options);\n\treturn _writeJSON(file, data, options)\n}\n\nexport function writeJSONSync(file: string, data: any, options?: IWriteOptions)\n{\n\toptions = _handleWriteOptions(options);\n\treturn _writeJSONSync(file, data, options)\n}\n\nexport function stringifyJSON(data: any, options?: IWriteOptions): string\n{\n\toptions = _handleWriteOptions(options);\n\treturn stringify(data, options as any)\n}\n\nexport function parseJSON(stringOrUint8Array: string | Uint8Array,\n\treviver?: (this: any, key: string, value: any) => any,\n): string\n{\n\treturn JSON.parse(stringOrUint8Array.toString(), reviver)\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@bluelovers/fs-json",
3
+ "version": "1.0.3",
4
+ "description": "stringify with final EOL",
5
+ "keywords": [
6
+ "create-by-yarn-tool"
7
+ ],
8
+ "homepage": "https://github.com/bluelovers/ws-iconv/tree/master/packages/@bluelovers/fs-json#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/bluelovers/ws-iconv/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/bluelovers/ws-iconv.git"
15
+ },
16
+ "license": "ISC",
17
+ "author": "bluelovers",
18
+ "main": "index.js",
19
+ "scripts": {
20
+ "coverage": "yarn run test -- --coverage",
21
+ "lint": "ynpx --quiet eslint -- **/*.ts",
22
+ "test": "jest --passWithNoTests",
23
+ "test:jest": "jest --passWithNoTests",
24
+ "test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
25
+ "test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
26
+ "build:dts": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner & echo build:dts",
27
+ "build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
28
+ "build:dts:tsc": "tsc --emitDeclarationOnly --declaration --noEmit false",
29
+ "build:microbundle": "ynpx microbundle --target node",
30
+ "build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index",
31
+ "preversion": "echo preversion && yarn run test",
32
+ "version": "echo version",
33
+ "postversion": "echo postversion",
34
+ "prepublish": "echo prepublish",
35
+ "prepublishOnly": "echo prepublishOnly",
36
+ "prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
37
+ "publish": "echo publish",
38
+ "postpublish": "echo postpublish",
39
+ "postpublishOnly": "echo postpublishOnly",
40
+ "ncu": "yarn-tool ncu -u",
41
+ "sort-package-json": "yarn-tool sort",
42
+ "tsc:showConfig": "ynpx get-current-tsconfig -p"
43
+ },
44
+ "dependencies": {
45
+ "fs-extra": "^10.0.0",
46
+ "jsonfile": "^6.1.0",
47
+ "tslib": "^2.3.1"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "packageManager": "yarn@^1.22.11",
53
+ "gitHead": "5af510f708e5d8b9bbd54fe65bc8dc09f4079ac0"
54
+ }