New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

lomatch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lomatch

A tool that figures out what LoDash function you should use given an input, desired output, and predicate.

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

CircleCI

LoMatch

LoMatch

LoMatch is a tool that figures out what Lodash function you should use given an input, desired output, and predicate.

Online Tool

LoMatch isn't likely to live inside of a project, but more likely to be used a few times throughout a project in order to determine what Lodash functions to use. Because of this, I created an online tool to use LoMatch. You will almost always only need to use this tool and not need to install the npm module.

https://www.lomatch.online

Installation

LoMatch is available as an npm module if you so choose to include it in your project. This is the easiest way to install it:

npm

npm install lomatch

yarn

yarn add lomatch

Usage

const { LoMatch } = require('lomatch');
let results = LoMatch(input, output, primers);
console.log(results);

input - an object, array, or string that you currently have output - the desired format you want your data in primers - an array of values that you think will help LoMatch figure out a result results - an array of objects containing a func and args that when in combination with your input can get you to your output

Examples below

Arrays

Example

I have a starting array of [1, 2, 3, 2, 2], and I want a final array of [1, 3]. I don't know which Lodash functions I need to use in order to get there, so I'll use LoMatch!

const { LoMatch } = require('lomatch');
LoMatch([1, 2, 3, 2, 2], [1, 3], []);

This will return an output of all the Lodash functions and predicate combinations you should use (only one 'smallest' predicate per function).

[ { func: '_.difference', args: [ 2 ] },
  { func: '_.differenceBy', args: [ 2 ] },
  { func: '_.differenceWith', args: [ 2 ] },
  { func: '_.intersection', args: [ 1, 3 ] },
  { func: '_.intersectionBy', args: [ 1, 3 ] },
  { func: '_.intersectionWith', args: [ 1, 3 ] },
  { func: '_.pull', args: 2 },
  { func: '_.pullAll', args: [ 2 ] },
  { func: '_.pullAllBy', args: [ 2 ] },
  { func: '_.pullAllWith', args: [ 2 ] },
  { func: '_.pullAt', args: [ 0, 2 ] },
  { func: '_.without', args: 2 },
  { func: '_.xor', args: [ 2 ] },
  { func: '_.xorBy', args: [ 2 ] },
  { func: '_.xorWith', args: [ 2 ] } ]

This means that you can use something like _.pull([1, 2, 3, 2, 2], 2) in order to get [1, 3]. LoMatch will return results for both modified arrays and returned arrays. Be sure to read the Lodash documentation for the function you are going to use.

Objects

Example

I have a starting object of { 'a': [{ 'b': { 'c': 3 } }, 4] }, and I want a final array of [3, 4].

const { LoMatch } = require('lomatch');
LoMatch({ 'a': [{ 'b': { 'c': 3 } }, 4] }, [3, 4], []);

This will return an output of all the Lodash functions and predicate combinations you should use.

[ { func: '_.at', args: [ 'a[0].b.c', 'a[1]' ] } ]

This means that you can use _.at({ 'a': [{ 'b': { 'c': 3 } }, 4] }, [ 'a[0].b.c', 'a[1]' ]) in order to get [3, 4]. LoMatch will return results for both modified objects and returned objects. Be sure to read the Lodash documentation for the function you are going to use.

Strings

While strings are supported by LoMatch, there will only in rare cases be more than one solution.

Example

I have a starting string of 'fred, barney, & pebbles', and I want a final array of ['fred', 'barney', 'pebbles'].

const { LoMatch } = require('lomatch');
LoMatch('fred, barney, & pebbles', ['fred', 'barney', 'pebbles'], []);

This will return an output of all the Lodash functions and predicate combinations you should use.

[ { func: '_.words', args: [] } ]

This means that you can use _.words('fred, barney, & pebbles') in order to get ['fred', 'barney', 'pebbles']. Keep in mind strings are primitives and thus cannot be mutated in JavaScript. Be sure to read the Lodash documentation for the function you are going to use.

Keywords

lodash

FAQs

Package last updated on 23 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts