UNPKG

@winglet/json

Version:

TypeScript library for safe and efficient JSON data manipulation with RFC 6901 (JSON Pointer) and RFC 6902 (JSON Patch) compliance, featuring prototype pollution protection and immutable operations

15 lines (11 loc) 597 B
'use strict'; var filter = require('@winglet/common-utils/filter'); var compileSegments = require('./utils/compileSegments.cjs'); var error = require('./utils/error.cjs'); var getValueByPointer = require('./utils/getValueByPointer.cjs'); const getValue = (value, pointer) => { if (!(filter.isPlainObject(value) || filter.isArray(value))) throw new error.JSONPointerError('INVALID_INPUT', '`input` must be a plain object or an array.', { input: value }); return getValueByPointer.getValueByPointer(value, compileSegments.compilePointer(pointer)); }; exports.getValue = getValue;