@naturalcycles/nodejs-lib 15.92.1 → 15.94.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,7 +1,7 @@
1
1
  import { _uniq } from '@naturalcycles/js-lib/array'
2
2
  import { _filterNullishValues } from '@naturalcycles/js-lib/object'
3
3
  import type { AnyObject } from '@naturalcycles/js-lib/types'
4
- import type { JsonSchema } from './ajvSchema.js'
4
+ import type { JsonSchema } from './jSchema.js'
5
5
 
6
6
  export const JSON_SCHEMA_ORDER = [
7
7
  '$schema',
@@ -96,6 +96,14 @@ export async function zstdCompress(
96
96
  return await zstdCompressAsync(input, zstdLevelToOptions(level, options))
97
97
  }
98
98
 
99
+ export function zstdCompressSync(
100
+ input: Buffer | string,
101
+ level?: Integer, // defaults to 3
102
+ options: ZstdOptions = {},
103
+ ): Buffer<ArrayBuffer> {
104
+ return zlib.zstdCompressSync(input, zstdLevelToOptions(level, options))
105
+ }
106
+
99
107
  export function zstdLevelToOptions(level: Integer | undefined, opt: ZstdOptions = {}): ZstdOptions {
100
108
  if (!level) return opt
101
109
 
@@ -122,6 +130,14 @@ export async function zstdDecompress(
122
130
  return await zstdDecompressAsync(input, options)
123
131
  }
124
132
 
133
+ export function zstdDecompressToStringSync(input: Buffer, options: ZstdOptions = {}): string {
134
+ return zlib.zstdDecompressSync(input, options).toString()
135
+ }
136
+
137
+ export function zstdDecompressSync(input: Buffer, options: ZstdOptions = {}): Buffer<ArrayBuffer> {
138
+ return zlib.zstdDecompressSync(input, options)
139
+ }
140
+
125
141
  const ZSTD_MAGIC_NUMBER = 0xfd2fb528
126
142
 
127
143
  export function isZstdBuffer(input: Buffer): boolean {