GithubHelp home page GithubHelp logo

joins's Introduction

joins

Utility functions for joining two arrays, including support for non-unique keys.

  • innerJoin : Returns all records in the left array that have a matching record in the right array
  • outerJoin : Returns all records in both the left and right array, matching records if they exist
  • leftJoin : Returns all records in the left array along with any matching records in the right array
  • rightJoin : Returns all records in the right array along with any matching records in the left array
  • leftExcludingJoin : Returns all records in the left array that do NOT match any records in the right array
  • rightExcludingJoin : Returns all records in the right array that do NOT match any records in the left array
  • outerExcludingJoin : Returns all records in the left and right array that do not match

Usage

All join operations are called by passing the left-hand and right-hand arrays along with the name of the 'key' property in each record. An optional merge callback function can be provided to create custom records from each pair of joined records.

Example:

var joins = require('joins');
joins.innerJoin(left, right, leftKey, rightKey);

This will perform an inner join on the left and right array using the leftKey and rightKey properties. The resulting array will contain the joined records with each record containing all of the properties from both the left-hand and right-hand records. Note that for duplicate property names the value from the right-hand record will be used.

Example:

var joins = require('joins');
joins.innerJoin(left, right, leftKey, rightKey, function(left, right) {
    return {
        name: left.firstName + ' ' + left.lastName,
        address: right.location
    };
});

This will perform an inner join on the left and right array using the leftKey and rightKey properties. The resulting array will contain the joined records with each record containing the custom properties specified in the custom merge function.

Examples

License

Apache License Version 2.0

joins's People

Contributors

jeffenglish avatar

Watchers

Navid Nikpour avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.