@naturalcycles/nodejs-lib 13.0.0 → 13.0.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.
@@ -118,6 +118,7 @@ export declare const fs2: {
118
118
  writevSync: typeof fs.writevSync;
119
119
  readv: typeof fs.readv;
120
120
  readvSync: typeof fs.readvSync;
121
+ openAsBlob: typeof fs.openAsBlob;
121
122
  opendirSync: typeof fs.opendirSync;
122
123
  opendir: typeof fs.opendir;
123
124
  cp: typeof fs.cp;
@@ -120,23 +120,27 @@ function _outputFileSync(filePath, data) {
120
120
  fs.writeFileSync(filePath, data);
121
121
  }
122
122
  exports._outputFileSync = _outputFileSync;
123
+ function stringify(data, opt) {
124
+ // If pretty-printing is enabled (spaces) - also add a newline at the end (to match our prettier config)
125
+ return JSON.stringify(data, null, opt?.spaces) + (opt?.spaces ? '\n' : '');
126
+ }
123
127
  async function _writeJson(filePath, data, opt) {
124
- const str = JSON.stringify(data, null, opt?.spaces);
128
+ const str = stringify(data, opt);
125
129
  await fsp.writeFile(filePath, str);
126
130
  }
127
131
  exports._writeJson = _writeJson;
128
132
  function _writeJsonSync(filePath, data, opt) {
129
- const str = JSON.stringify(data, null, opt?.spaces);
133
+ const str = stringify(data, opt);
130
134
  fs.writeFileSync(filePath, str);
131
135
  }
132
136
  exports._writeJsonSync = _writeJsonSync;
133
137
  async function _outputJson(filePath, data, opt) {
134
- const str = JSON.stringify(data, null, opt?.spaces);
138
+ const str = stringify(data, opt);
135
139
  await _outputFile(filePath, str);
136
140
  }
137
141
  exports._outputJson = _outputJson;
138
142
  function _outputJsonSync(filePath, data, opt) {
139
- const str = JSON.stringify(data, null, opt?.spaces);
143
+ const str = stringify(data, opt);
140
144
  _outputFileSync(filePath, str);
141
145
  }
142
146
  exports._outputJsonSync = _outputJsonSync;
@@ -4,7 +4,9 @@ exports.AjvValidationError = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  class AjvValidationError extends js_lib_1.AppError {
6
6
  constructor(message, data) {
7
- super(message, data);
7
+ super(message, data, {
8
+ name: 'AjvValidationError',
9
+ });
8
10
  }
9
11
  }
10
12
  exports.AjvValidationError = AjvValidationError;
@@ -92,4 +92,4 @@ export declare const userAgentSchema: StringSchema<string>;
92
92
  export declare const utcOffsetSchema: NumberSchema<number>;
93
93
  export declare const ipAddressSchema: StringSchema<string>;
94
94
  export declare const baseDBEntitySchema: ObjectSchema<BaseDBEntity>;
95
- export declare const savedDBEntitySchema: ObjectSchema<SavedDBEntity<string>>;
95
+ export declare const savedDBEntitySchema: ObjectSchema<SavedDBEntity>;
@@ -4,7 +4,9 @@ exports.JoiValidationError = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  class JoiValidationError extends js_lib_1.AppError {
6
6
  constructor(message, data) {
7
- super(message, data);
7
+ super(message, data, {
8
+ name: 'JoiValidationError',
9
+ });
8
10
  }
9
11
  }
10
12
  exports.JoiValidationError = JoiValidationError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.0.0",
3
+ "version": "13.0.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
package/src/fs/fs.util.ts CHANGED
@@ -126,23 +126,28 @@ export function _outputFileSync(filePath: string, data: string | Buffer): void {
126
126
  fs.writeFileSync(filePath, data)
127
127
  }
128
128
 
129
+ function stringify(data: any, opt?: JsonOptions): string {
130
+ // If pretty-printing is enabled (spaces) - also add a newline at the end (to match our prettier config)
131
+ return JSON.stringify(data, null, opt?.spaces) + (opt?.spaces ? '\n' : '')
132
+ }
133
+
129
134
  export async function _writeJson(filePath: string, data: any, opt?: JsonOptions): Promise<void> {
130
- const str = JSON.stringify(data, null, opt?.spaces)
135
+ const str = stringify(data, opt)
131
136
  await fsp.writeFile(filePath, str)
132
137
  }
133
138
 
134
139
  export function _writeJsonSync(filePath: string, data: any, opt?: JsonOptions): void {
135
- const str = JSON.stringify(data, null, opt?.spaces)
140
+ const str = stringify(data, opt)
136
141
  fs.writeFileSync(filePath, str)
137
142
  }
138
143
 
139
144
  export async function _outputJson(filePath: string, data: any, opt?: JsonOptions): Promise<void> {
140
- const str = JSON.stringify(data, null, opt?.spaces)
145
+ const str = stringify(data, opt)
141
146
  await _outputFile(filePath, str)
142
147
  }
143
148
 
144
149
  export function _outputJsonSync(filePath: string, data: any, opt?: JsonOptions): void {
145
- const str = JSON.stringify(data, null, opt?.spaces)
150
+ const str = stringify(data, opt)
146
151
  _outputFileSync(filePath, str)
147
152
  }
148
153
 
@@ -40,7 +40,7 @@ export function memoryUsageFull(): {
40
40
  }
41
41
 
42
42
  class ProcessUtil {
43
- private timer!: NodeJS.Timer
43
+ private timer!: NodeJS.Timeout
44
44
 
45
45
  startMemoryTimer(intervalMillis = 1000): void {
46
46
  console.log(memoryUsage())
@@ -9,6 +9,8 @@ export interface AjvValidationErrorData extends ErrorData {
9
9
 
10
10
  export class AjvValidationError extends AppError<AjvValidationErrorData> {
11
11
  constructor(message: string, data: AjvValidationErrorData) {
12
- super(message, data)
12
+ super(message, data, {
13
+ name: 'AjvValidationError',
14
+ })
13
15
  }
14
16
  }
@@ -27,6 +27,8 @@ export interface JoiValidationErrorData extends ErrorData {
27
27
 
28
28
  export class JoiValidationError extends AppError<JoiValidationErrorData> {
29
29
  constructor(message: string, data: JoiValidationErrorData) {
30
- super(message, data)
30
+ super(message, data, {
31
+ name: 'JoiValidationError',
32
+ })
31
33
  }
32
34
  }