@reconbot/jsoff

1.0.0 • Public • Published

jsoff

Count which JSON fields you've accessed and remove the rest.

const { jsOff, countSymbol } = require('@reconbot/jsoff')
const input = {
  foo: {
    bar: 4,
    baz: null
  },
  arr: [{ name: 'spock', age: 64 }, { name: undefined }]
}

const data = jsOff(input)

console.log(data.foo.bar)
console.log(data.arr.map(i => i.name ))

console.log(data[countSymbol])
// { foo: 1, arr: 1 })
console.log(data.arr[0][countSymbol])
// { name: 1, age: 0 }
console.log(JSON.stringify(data))
// {"foo":{"bar":4},"arr":[{"name":"spock"},{}]}

Readme

Keywords

none

Package Sidebar

Install

npm i @reconbot/jsoff

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.02 kB

Total Files

3

Last publish

Collaborators

  • reconbot