Socket
Socket
Sign inDemoInstall

miniquery

Package Overview
Dependencies
1
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    miniquery

Simplest object querying tool


Version published
Weekly downloads
203
decreased by-29.27%
Maintainers
2
Install size
70.9 kB
Created
Weekly downloads
 

Readme

Source

miniquery

miniquery allows you to query objects for a given path and returns you an Array of values matching.

NPM version Build status Dependency Status devDependency Status Coverage Status Code Climate

Installation

First install miniquery in you project:

npm install --save miniquery

Getting started

Then, use it:

var miniquery = require('miniquery');
var assert = require('assert');

var fruits = [{
  name: 'orange'
  count: 2,
  colors: ['orange']
}, {
	name: 'banana',
  count: 0,
  colors: ['yellow', 'white']
}, {
	name: 'kiwi',
  count: 8,
  colors: ['brown', 'green']
}];

var orangeColor = miniquery('0.colors.0', [fruits]);
assert.deepEqual(orangeColor, ['orange']);

var counts = miniquery('*.count', [fruits]);
assert.deepEqual(counts, [2, 0, 8]);

var colors = miniquery('colors.#', fruits);
assert.deepEqual(colors, ['orange', 'yellow', 'white', 'brown', 'green']);

Note that miniquery always returns an Array even if there is no or only one result.

## CLI usage

Install miniquery globally:

sudo npm install -g miniquery

Then, simply run your queries on one or more JSON files. Let's assume we want to list distinct keywords on all of our NodeJS projects :

miniquery "keywords.*" ~/projects/*/package.json -p | uniq
# minimatch
# gulp
# svg
# gulp
# gulp-plugin
# (...)
# github
# REST
# HTTP
# server
# web
#services

Get every available options by running:

miniquery -h

# Usage: miniquery [options] <query> <file ...>
#
# Options:
#
#   -h, --help       output usage information
#   -V, --version    output the version number
#   -v, --verbose    tell me everything!
#   -j, --json       output JSON
#   -p, --primitive  print primitives only

## API

### values:Array miniquery(path:String, objs:Array) Return the values matching the given path for the objects contained in objs.

Contribute

Feel free to submit us your improvements. To do so, you must accept to publish your code under the MIT license.

To start contributing, first run the following to setup the development environment:

git clone git@github.com:SimpliField/miniquery.git
cd miniquery
npm install

Then, run the tests:

npm test

Stats

NPM NPM

Keywords

FAQs

Last updated on 05 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc