Getting Started

A library of witty Javascript one-liners. The 1loc.dev website has a collection of useful Javascript one-liners, now you get to use them in your Javascript projects.

Installation

You can use the 1loc library in any Javascript application (preferably a node.js environment). Vue, React, Angular, Node.js.

  • Node.js (>= 14 preferably)

Install the 1loc library using your favorite package manager (yarn or npm).

$ yarn add 1loc

Or using NPM

$ npm install 1loc

Import and Use Any Method

import { makeTallyByProperty } from '1loc'

const myArray = [
    { brand: 'audi', model: 'q8', year: '2019' },
    { brand: 'audi', model: 'rs7', year: '2020' },
    { brand: 'ford', model: 'mustang', year: '2019' },
    { brand: 'ford', model: 'explorer', year: '2020' },
    { brand: 'bmw', model: 'x7', year: '2020' },
]

makeTallyByProperty(myArray, 'brand') // { 'audi': 2, 'ford': 2, 'bmw': 1 }

That's it 🎉

Contribute

You can contribute to this project here.

Last updated