Skip to content

object-scanvskiba

MIT 15 8 169
133.2 thousand (month) Jun 10 2018 19.0.5(1 year, 2 months ago)
1,753 1 - LGPL-3.0
Apr 18 2015 21.3 thousand (month) 4.0.0(3 years ago)

object-scan allows traversal of complex javascript objects to find specific keys.

In web scraping, it's useful for parsing large, nested JSON datasets for specific datafields. object-scan can be used to recursively find any key in any object structure:

import objectScan from 'object-scan';

const haystack = { a: { b: { c: 'd' }, e: { f: 'g' } } };
objectScan(['a.*.f'], { joined: true })(haystack);
// => [ 'a.e.f' ]

Kiba is a lightweight Ruby gem that provides a simple and powerful way to process and transform data in an ETL (Extract, Transform, Load) pipeline. It allows you to define a set of operations to perform on the data, and then automatically applies those operations to the data, making it easy to extract, transform, and load data from various sources and formats.

Kiba provides a simple and intuitive API for defining the pipeline, and it is built on top of the Enumerator API, which allows for easy manipulation of large datasets with low memory usage.

Example Use


const objectScan = require('object-scan');

const myNestedObject = {
  level1: {
    level2: {
      level3: {
        myTargetKey: 'value',
      },
    },
  },
};

const searchTerm = 'myTargetKey';
const result = objectScan([`**.${searchTerm}`], { joined: false })(myNestedObject);
console.log(result);
require 'kiba'

data = [{ name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }]

Kiba.parse do
  source Kiba::Common::EnumerableSource, data
  transform { |row| row[:age] += 1 }
  destination Kiba::Common::EnumerableDestination
end.run

# Output: [{ name: 'Alice', age: 26 }, { name: 'Bob', age: 31 }]

Alternatives / Similar


Was this page helpful?