npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

objeq

v0.6.1

Published

JavaScript Object Querying

Downloads

42

Readme

objeq (JavaScript Object Querying)

objeq (Object Querying) - is a simple library that allows POJSO's (Plain-Old JavaScript Objects) to be queried in real-time. As it relies on property setters, it will only work in more recent browsers and JavaScript environments.

Current Status

Still under active development and still quite a bit to do. Unless you really know what you're doing, you probably shouldn't even try to use this library. If you do use it, know that things will considerably change in future versions.

Installation

This module defines both a Lexer and Grammar that use the Jison Parser Generator (http://zaach.github.com/jison/)

A pre-built version of the parser and minified code are already included, but if you'd like to build them yourself and you have node.js, then you can do so by issuing the following command from the package's top-level directory:

> npm install; npm run-script build

This will also install any development dependencies and run the nodeunit test suite.

Usage

There are really only three steps in using the objeq Query Language, and the third is optional. First, you need to Decorate your data by passing it to the $objeq() function:

var data = $objeq({name:'Ronald'}, {name:'Robert'}, {name:'Thomas'});

Next, you query it. You can do this in one of two ways, both involve calling a method of the Decorated Array that $objeq() returns. The first method is called query() and creates an immediate (or snapshot) Result Set. The second method is called dynamic() and produces a Result Set whose contents are live in that the Array will constantly reflect Items that match the original Query criteria.

// The Result Set membership will not change as its Items are modified
var result = data.query("'^Ro' =~ name");

Or

// The Result Set membership will update as soon as its Items are modified
var result = data.dynamic("'^Ro' =~ name");

And finally, if you want to monitor changes to your results as they happen, you can register an Observer on the Result Set. Note that this really is only useful for the results of a Dynamic Query.

result.on('change', function(target) {
  alert('My Data Changed!');
});

Things Worth Mentioning

Objects and Arrays need to be 'Decorated' in order to be queryable. The result of such decoration is always an Array of Items, even if only a single Object was decorated, so you have to be careful to retrieve the first Item in the Result Set if you want to modify it:

var items = $objeq({name:'William'}); // -> [{name:'William'}]
var will = items[0];

// is the same as the following
var will = $objeq([{name:'William'})[0];

These are chainable, so you can also do:

var items = $objeq({name:'William'}, {name:'Stephen'});
var will = items.query("name == 'William'")[0];

Queries can also be Parameterized where any Objects passed in are also Decorated and treated as live Parameters. This means that the Result Set will be updated every time the Parameter's Properties change:

var items = $objeq({name:'William'}, {name:'Stephen'});
var param = { name: 'William' };
var result = items.dynamic("name == %1.name", param); // 0 -> William
param.name = 'Stephen';                               // 0 -> Stephen

Observables

Presently, you can create Observers on Result Sets in the following ways.

Membership Changes

Monitoring the Result Set for membership changes. Notice that the first parameter to the on() method is '.content'. All Observable keys that start with a '.' are considered to be special properties of the Result Set itself.

// query all items that start with the letter 't'
var items = $objeq([{name:'William'}, {name:'Stephen'});
var query = items.dynamic("'^W' =~ name");
query.on('.content', function(target) {
    // target is the array itself
    console.log("The Query Results have changed!");
});
items[1].name = 'William';

Property Changes

Monitoring the Result Set for Property changes. Here we just specify the property name as is (or names, separated by spaces).

query.on('name', function(target, key, newValue, oldValue) {
    // target is the object that changed
    console.log("The Query Results have changed!");
});
items[1].name = 'William'; // -> There are 2 results

More Information

See doc/Reference.md for more information on the objeq Query Language.

License (MIT License)

Copyright (c) 2012 Agilo Software GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.