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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lq

v0.0.1

Published

lq - a node.js query library

Downloads

1

Readme

lq - A query like library

lq is a query like library that is inspired by the LINQ library from .NET.

lq instance will attempt to delay the calculation of intermediate values to avoid the time an memory such intermediate values will cost. For example,

var a = [0, 1, 2, 3, 4, 5];
var q = lq(a).where(function (v) { return v % 2 == 0 });
q.each(function (v) { console.info(v) });

will print all the even numbers without producing an array that contains all the even number. In this example, calling .where() returns immediately and the callback function is only invoked when .each() is invoked.

Module

lq(a)

The lq module is a function that returns an query that wraps the array.

Module Functions

lq.of(a)

lq.of() is an alias for lq() and is sometime easier to read.

lq.fieldsOf(o)

fieldsOf() returns a query that contains an array of fields and their values of the for { name: <field-name>, value: <value> }.

lq.join(keySelect, a1 ... an)

Experimental

lq.is(o)

Returns true if o is a lq query, false otherwise.

Query Functions

.count()

Returns the number of values in the query.

.all(predicate)

Returns true if all the predicate returns true for all the values in the query.

.any(predicate)

Returns true if the predicate returns true for any of the values in the query.

.concat(q1, [... qn])

Returns a query that is the concatentaion of one or more queries passed as parameters.

.each(callback)

Calls callback with the values in the query. The callback is callback(value, index) where the value is the value in the query and the index is the position the value would be if toArray() where called on the lq instance.

.first()

Returns the first value in the query.

.forEach()

This is an alias for .each().

.last()

Returns the last value in the query.

.realize()

Ensure that all the selector and predicate functions are invoked. This is used to ensure that expensive work in the selector and predicate functions are not repeated. realize() should be inserted to optimize a query.

.select(selector)

Produce a projection of qyer where all the values in the query is replaced with the result of the selector. The selector might not be called immediately and might be called multiple times on the same value.

.skip(count)

Produce a query that skips at least the count values. If the query has fewer than count values then the query is empty.

.take(count)

Produce a query that contains at most the first count values.

.toArray()

Produce a fresh array that contains the values included in query.

.toObject(keySelector)

Produces an object with the properties with the values of the query and the with the name returned by keySelector(value).

.where(predicate)

Returns a query that only contains values where predicate returns true. predicate is called as predicate(value) where the value is the value in the query.