Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@cnpmjs/packument

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cnpmjs/packument - npm Package Compare versions

Comparing version
1.3.0
to
1.4.0
+7
-0
index.d.ts

@@ -115,2 +115,9 @@ /* auto-generated by NAPI-RS */

export declare function getIn(data: Uint8Array, paths: Array<string>): GetInResult | null
export interface GetInResult {
start: number
end: number
}
export declare function hasIn(data: Uint8Array, paths: Array<string>): boolean

@@ -117,0 +124,0 @@

+52
-51

@@ -84,4 +84,4 @@ // prettier-ignore

const bindingPackageVersion = require('@cnpmjs/packument-android-arm64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -101,4 +101,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -122,4 +122,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-win32-x64-msvc/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -139,4 +139,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -156,4 +156,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -176,4 +176,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-darwin-universal/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -193,4 +193,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-darwin-x64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -210,4 +210,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-darwin-arm64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -231,4 +231,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-freebsd-x64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -248,4 +248,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -270,4 +270,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-x64-musl/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -287,4 +287,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -306,4 +306,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-arm64-musl/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -323,4 +323,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -342,4 +342,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-arm-musleabihf/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -359,4 +359,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -378,4 +378,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-loong64-musl/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -395,4 +395,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-loong64-gnu/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -414,4 +414,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -431,4 +431,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -449,4 +449,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -466,4 +466,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -487,4 +487,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -504,4 +504,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-openharmony-x64/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -521,4 +521,4 @@ return binding

const bindingPackageVersion = require('@cnpmjs/packument-openharmony-arm/package.json').version
if (bindingPackageVersion !== '1.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
if (bindingPackageVersion !== '1.4.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.4.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}

@@ -585,3 +585,3 @@ return binding

const { Package, DeletePropertyKind, detectDeletePropertyPosition, detectSetPropertyPosition, hasIn, SetPropertyKind } = nativeBinding
const { Package, DeletePropertyKind, detectDeletePropertyPosition, detectSetPropertyPosition, getIn, hasIn, SetPropertyKind } = nativeBinding
export { Package }

@@ -591,3 +591,4 @@ export { DeletePropertyKind }

export { detectSetPropertyPosition }
export { getIn }
export { hasIn }
export { SetPropertyKind }

@@ -15,3 +15,5 @@ export type SetValue = string | number | boolean | Date | object | Buffer;

hasIn(paths: string[]): boolean;
getIn<T = unknown>(paths: string[]): T | undefined;
getBufferIn(paths: string[]): Buffer | undefined;
build(): Buffer;
}

@@ -1,2 +0,2 @@

import { detectDeletePropertyPosition, detectSetPropertyPosition, hasIn, } from '../index.js';
import { detectDeletePropertyPosition, detectSetPropertyPosition, getIn, hasIn, } from '../index.js';
export class JSONBuilder {

@@ -8,5 +8,2 @@ #data;

setIn(paths, value) {
if (paths.length === 0) {
throw new TypeError('paths should not be empty array');
}
const result = detectSetPropertyPosition(this.#data, paths);

@@ -59,5 +56,2 @@ if (result.kind === "ParentNotObject" /* SetPropertyKind.ParentNotObject */) {

deleteIn(paths, options) {
if (paths.length === 0) {
throw new TypeError('paths should not be empty array');
}
const result = detectDeletePropertyPosition(this.#data, paths);

@@ -77,7 +71,19 @@ if (result.kind === "NotFound" /* DeletePropertyKind.NotFound */) {

hasIn(paths) {
if (paths.length === 0) {
throw new TypeError('paths should not be empty array');
}
return hasIn(this.#data, paths);
}
getIn(paths) {
const buffer = this.getBufferIn(paths);
if (!buffer) {
return undefined;
}
// @ts-expect-error - JSON.parse can work with Uint8Array
return JSON.parse(buffer);
}
getBufferIn(paths) {
const result = getIn(this.#data, paths);
if (!result) {
return undefined;
}
return this.#data.subarray(result.start, result.end);
}
build() {

@@ -84,0 +90,0 @@ return this.#data;

@@ -5,2 +5,3 @@ import {

detectSetPropertyPosition,
getIn,
hasIn,

@@ -28,5 +29,2 @@ SetPropertyKind,

setIn(paths: string[], value: SetValue): this {
if (paths.length === 0) {
throw new TypeError('paths should not be empty array')
}
const result = detectSetPropertyPosition(this.#data, paths)

@@ -84,5 +82,2 @@ if (result.kind === SetPropertyKind.ParentNotObject) {

deleteIn(paths: string[], options?: DeleteOptions): this {
if (paths.length === 0) {
throw new TypeError('paths should not be empty array')
}
const result = detectDeletePropertyPosition(this.#data, paths)

@@ -103,8 +98,22 @@ if (result.kind === DeletePropertyKind.NotFound) {

hasIn(paths: string[]): boolean {
if (paths.length === 0) {
throw new TypeError('paths should not be empty array')
}
return hasIn(this.#data, paths)
}
getIn<T = unknown>(paths: string[]): T | undefined {
const buffer = this.getBufferIn(paths)
if (!buffer) {
return undefined
}
// @ts-expect-error - JSON.parse can work with Uint8Array
return JSON.parse(buffer) as T
}
getBufferIn(paths: string[]): Buffer | undefined {
const result = getIn(this.#data, paths)
if (!result) {
return undefined
}
return this.#data.subarray(result.start, result.end)
}
build(): Buffer {

@@ -111,0 +120,0 @@ return this.#data

{
"name": "@cnpmjs/packument",
"version": "1.3.0",
"version": "1.4.0",
"description": "Packument helper",

@@ -58,3 +58,6 @@ "repository": {

"prebench": "yarn build",
"bench": "node benchmark/bench.ts && node benchmark/bench_memory.ts",
"bench": "node benchmark/bench.ts && node benchmark/bench_memory.ts && yarn bench:gc",
"bench:gc": "yarn bench:gc:add_version && yarn bench:gc:get_property_value",
"bench:gc:add_version": "GC=1 node benchmark/add_version.ts && GC=1 node benchmark/add_version.ts SonicJSONParse",
"bench:gc:get_property_value": "GC=1 node benchmark/get_property_value.ts && GC=1 node benchmark/get_property_value.ts SonicJSONParse",
"build": "tsc && napi build --platform --release --esm",

@@ -116,11 +119,11 @@ "build:debug": "tsc && napi build --platform --esm",

"optionalDependencies": {
"@cnpmjs/packument-win32-x64-msvc": "1.3.0",
"@cnpmjs/packument-darwin-x64": "1.3.0",
"@cnpmjs/packument-linux-x64-gnu": "1.3.0",
"@cnpmjs/packument-linux-x64-musl": "1.3.0",
"@cnpmjs/packument-linux-arm64-gnu": "1.3.0",
"@cnpmjs/packument-darwin-arm64": "1.3.0",
"@cnpmjs/packument-linux-arm64-musl": "1.3.0",
"@cnpmjs/packument-win32-arm64-msvc": "1.3.0"
"@cnpmjs/packument-win32-x64-msvc": "1.4.0",
"@cnpmjs/packument-darwin-x64": "1.4.0",
"@cnpmjs/packument-linux-x64-gnu": "1.4.0",
"@cnpmjs/packument-linux-x64-musl": "1.4.0",
"@cnpmjs/packument-linux-arm64-gnu": "1.4.0",
"@cnpmjs/packument-darwin-arm64": "1.4.0",
"@cnpmjs/packument-linux-arm64-musl": "1.4.0",
"@cnpmjs/packument-win32-arm64-msvc": "1.4.0"
}
}