Exposes @kingjs/linq.*


081.0.304 years ago4 years agoMinified + gzip package size for @kingjs/linq in KB



Exports all @kingjs/linq.* functionality in one package.


Join pets to their owners, sorted by last name, then first name, excluding fishes, like this:

var linq = require('@kingjs/linq');
var sequence = require('@kingjs/enumerable.create');
var apply = require('@kingjs/apply');

var people = sequence(
  { firstName: 'Bob', lastName: 'Smith', id: 0 },
  { firstName: 'Alice', lastName: 'Smith', id: 1 },
  { firstName: 'Chris', lastName: 'King', id: 2 },

var pets = sequence(
  { name: 'Tiger', type: 'dog', ownerId: 0 },
  { name: 'Spike', type: 'dog', ownerId: 0 },
  { name: 'Fluffy', type: 'cat', ownerId: 1 },
  { name: 'Bubbles', type: 'fish', ownerId: 2 },

  linq.orderBy, [ function(x) { return x.lastName; } ],
  linq.thenBy, [ function(x) { return x.firstName; } ],
  linq.join, [
    function(x) { return x.id; },
    function(x) { return x.ownerId; },
    function(owner, pet) { return { owner: owner, pet: pet } }
  linq.where, [ function(x) { return x.pet.type != 'fish'; } ],
  linq.select, [
    function(x) { 
      var owner = x.owner;
      var pet = x.pet;

      return owner.firstName + " " + owner.lastName + 
        ' owns a ' + pet.type + ' named ' + pet.name + '.';
  linq.toArray, [],
  Array.prototype.join, ['\n']


Alice Smith owns a cat named Fluffy. 
Bob Smith owns a dog named Tiger. 
Bob Smith owns a dog named Spike.


Search Aggregate Set Generator Accrete
all aggregate distinct range append
any average except repeat concat
contains count intersect empty prepend
elementAtOrUndef max union
firstOrUndef min
lastOrUndef sum
singleOrUndef equal
Sort Filter Join Transform Container
orderBy skip groupBy select toArray
orderByDesc skipWhile groupJoin selectMany toDictionary
thenBy take join toLookup
thenByDesc takeWhile zip


With npm installed, run

$ npm install @kingjs/link


See @kingjs/apply to understand the benefit of the "odd" apply convention. Basically, it allows for the separation of data from algorithm; Data and algorithm separation cannot be achieved in Javascript using the dot syntax without polluting the data object or prototype with a function.

See Also


If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.