@naturalcycles/nodejs-lib 15.99.0 → 15.100.0

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.
@@ -1,8 +1,9 @@
1
1
  import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToStringOptions } from 'yaml';
2
+ export type YamlParseOptions = ParseOptions & DocumentOptions & SchemaOptions;
2
3
  export type YamlStringifyOptions = DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions & ToStringOptions;
3
4
  declare class Yaml2 {
4
- readYaml<T = unknown>(filePath: string): T;
5
- readYamlAsync<T = unknown>(filePath: string): Promise<T>;
5
+ readYaml<T = unknown>(filePath: string, opt?: YamlParseOptions): T;
6
+ readYamlAsync<T = unknown>(filePath: string, opt?: YamlParseOptions): Promise<T>;
6
7
  writeYaml(filePath: string, data: any, opt?: YamlStringifyOptions): void;
7
8
  writeYamlAsync(filePath: string, data: any, opt?: YamlStringifyOptions): Promise<void>;
8
9
  outputYaml(filePath: string, data: any, opt?: YamlStringifyOptions): void;
package/dist/fs/yaml2.js CHANGED
@@ -3,11 +3,11 @@ import fsp from 'node:fs/promises';
3
3
  import { parse, stringify } from 'yaml';
4
4
  import { fs2 } from './fs2.js';
5
5
  class Yaml2 {
6
- readYaml(filePath) {
7
- return parse(fs.readFileSync(filePath, 'utf8'));
6
+ readYaml(filePath, opt) {
7
+ return parse(fs.readFileSync(filePath, 'utf8'), opt);
8
8
  }
9
- async readYamlAsync(filePath) {
10
- return parse(await fsp.readFile(filePath, 'utf8'));
9
+ async readYamlAsync(filePath, opt) {
10
+ return parse(await fsp.readFile(filePath, 'utf8'), opt);
11
11
  }
12
12
  writeYaml(filePath, data, opt) {
13
13
  const str = stringify(data, opt);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.99.0",
4
+ "version": "15.100.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
package/src/fs/yaml2.ts CHANGED
@@ -10,6 +10,8 @@ import type {
10
10
  import { parse, stringify } from 'yaml'
11
11
  import { fs2 } from './fs2.js'
12
12
 
13
+ export type YamlParseOptions = ParseOptions & DocumentOptions & SchemaOptions
14
+
13
15
  export type YamlStringifyOptions = DocumentOptions &
14
16
  SchemaOptions &
15
17
  ParseOptions &
@@ -17,12 +19,12 @@ export type YamlStringifyOptions = DocumentOptions &
17
19
  ToStringOptions
18
20
 
19
21
  class Yaml2 {
20
- readYaml<T = unknown>(filePath: string): T {
21
- return parse(fs.readFileSync(filePath, 'utf8')) as T
22
+ readYaml<T = unknown>(filePath: string, opt?: YamlParseOptions): T {
23
+ return parse(fs.readFileSync(filePath, 'utf8'), opt) as T
22
24
  }
23
25
 
24
- async readYamlAsync<T = unknown>(filePath: string): Promise<T> {
25
- return parse(await fsp.readFile(filePath, 'utf8')) as T
26
+ async readYamlAsync<T = unknown>(filePath: string, opt?: YamlParseOptions): Promise<T> {
27
+ return parse(await fsp.readFile(filePath, 'utf8'), opt) as T
26
28
  }
27
29
 
28
30
  writeYaml(filePath: string, data: any, opt?: YamlStringifyOptions): void {