Skip to content

Returns all lists from a collection that match a given criteria

Notifications You must be signed in to change notification settings

graned/confer-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Confer JS

Confer-JS is a tiny library that compares two ordered lists of objects and gives out the matched results.

Installation

 npm install confer-js

Example usage

Using an Object structure

var confer = require('confer-js');
// Given a list of lists
var listOfLists = {
  list1: [{ e: 'element'}, 2, 'anotherElement'],
  list2: [{ e: 'element'}, 1, 'anotherElement'],
  list3: [{ e: 'element'}, 2],
}

// We want to find all lists with these elements in this order
var findList = [{ e: 'element'}, 2]
var result = confer(listOfLists, findLists)

Using an Array of Arrays structure

Confer-js also supports an array of array structure, if that is the case, the usage will be as follows:

var confer = require('confer-js');
// Given a list of lists
var listOfLists = [
  [{ e: 'element'}, 2, 'anotherElement'],
  [{ e: 'element'}, 1, 'anotherElement'],
  [{ e: 'element'}, 2]
]

// We want to find all lists with these elements in this order
var findList = [{ e: 'element'}, 2]
var result = confer(listOfLists, findLists)

Results

The result will contain a list matching the given data or an empty object or array, depending what was passed to the function:

// When listOfLists is an object.
{
  list1: [{ e: 'element'}, 2, 'anotherElement'],
  list3: [{ e: 'element'}, 2],
}
// When listOfLists is an array.
[
  [{ e: 'element'}, 2, 'anotherElement'],
  [{ e: 'element'}, 2]
]

About

Returns all lists from a collection that match a given criteria

Resources

Stars

Watchers

Forks

Packages

No packages published