All Projects β†’ concretesolutions β†’ Pareto.js

concretesolutions / Pareto.js

Licence: other
An extremely small, intuitive and fast functional utility library for JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Pareto.js

Autocomplete.js
Simple autocomplete pure vanilla Javascript library.
Stars: ✭ 3,428 (+1249.61%)
Mutual labels:  hacktoberfest, lightweight, fast
React Select Me
Fast πŸ†. Lightweight 🐜. Configurable πŸ™. Easy to use πŸ¦„. Give it a shot πŸ‘‰πŸΌ
Stars: ✭ 119 (-53.15%)
Mutual labels:  lightweight, fast
Duckstation
Fast PlayStation 1 emulator for x86-64/AArch32/AArch64
Stars: ✭ 2,888 (+1037.01%)
Mutual labels:  hacktoberfest, fast
Axel
Axel tries to accelerate the download process by using multiple connections per file, and can also balance the load between different servers.
Stars: ✭ 1,997 (+686.22%)
Mutual labels:  hacktoberfest, lightweight
Cstate
πŸ”₯ Open source static (serverless) status page. Uses hyperfast Go & Hugo, minimal HTML/CSS/JS, customizable, outstanding browser support (IE8+), preloaded CMS, read-only API, badges & more.
Stars: ✭ 1,186 (+366.93%)
Mutual labels:  hacktoberfest, fast
Snoopwpf
Snoop - The WPF Spy Utility
Stars: ✭ 1,286 (+406.3%)
Mutual labels:  utility, hacktoberfest
Arare
Lightweight curried functional programming library
Stars: ✭ 127 (-50%)
Mutual labels:  lightweight, functional
Utox
Β΅Tox the lightest and fluffiest Tox client
Stars: ✭ 820 (+222.83%)
Mutual labels:  lightweight, fast
Kotlin Openapi Spring Functional Template
πŸƒ Kotlin Spring 5 Webflux functional application with api request validation and interactive api doc
Stars: ✭ 159 (-37.4%)
Mutual labels:  hacktoberfest, functional
Redux Zero
A lightweight state container based on Redux
Stars: ✭ 1,977 (+678.35%)
Mutual labels:  lightweight, functional
Fiber
⚑️ Express inspired web framework written in Go
Stars: ✭ 17,334 (+6724.41%)
Mutual labels:  hacktoberfest, fast
Openapi Spring Webflux Validator
🌱 A friendly kotlin library to validate API endpoints using an OpenApi 3.0 and Swagger 2.0 specification
Stars: ✭ 67 (-73.62%)
Mutual labels:  hacktoberfest, functional
Siler
⚑ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.
Stars: ✭ 1,056 (+315.75%)
Mutual labels:  hacktoberfest, functional
Lens
A utility for working with nested data structures.
Stars: ✭ 104 (-59.06%)
Mutual labels:  utility, functional
Executor
Watch for file changes and then execute command. Very nice for test driven development.
Stars: ✭ 14 (-94.49%)
Mutual labels:  utility, hacktoberfest
Crepe
The thin API stack.
Stars: ✭ 120 (-52.76%)
Mutual labels:  lightweight, fast
Wolff
🐺 Lightweight and easy to use framework for building web apps.
Stars: ✭ 203 (-20.08%)
Mutual labels:  lightweight, fast
Remeda
A utility library for JavaScript and TypeScript.
Stars: ✭ 774 (+204.72%)
Mutual labels:  utility, functional
Fdir
⚑ The fastest directory crawler & globbing library for NodeJS. Crawls 1m files in < 1s
Stars: ✭ 777 (+205.91%)
Mutual labels:  hacktoberfest, fast
Fselect
Find files with SQL-like queries
Stars: ✭ 3,103 (+1121.65%)
Mutual labels:  utility, hacktoberfest

pareto.js

An extremely small, intuitive and fast functional utility library for JavaScript

  • Only 14 core functions
  • Written in TypeScript
  • Encourages immutability
  • Only pure functions (no side-effects)
  • Smaller than lodash

build downloads npm

Example

import { flatten, tail } from 'paretojs'

flatten([1, 2, [3, 4], 5]) // [1, 2, 3, 4, 5]
tail([1, 2, 3]) // [2, 3]

Installation

To install the stable version:

npm install --save paretojs

This assumes that you’re using npm with a module bundler like Webpack

How

ES2015 or TypeScript:

import _ from 'paretojs'

or

import { chunk, debounce } from 'paretojs'

CommonJS:

var _ = require('paretojs');

or

var chunk = require('paretojs').chunk;
var debounce = require('paretojs').debounce;

UMD:

<script src="https://unpkg.com/paretojs/dist/paretojs.min.js"></script>

API

chunk

Returns the chunk of an array based on an integer n

import { chunk } from 'paretojs';

chunk([1,2,3,4,5,6,7], 3); // [ [1,2,3], [4,5,6], [7] ]

compose

Gets a composed function

import { compose } from 'paretojs';

const toUpperCase = x => x.toUpperCase();
const exclaim = x => x + '!!!';

const angry = compose(toUpperCase, exclaim);

angry('stop'); // 'STOP!!!

curry

Gets a curried function

import { curry } from 'paretojs';

const add = (x, y) => x + y;

curry(add, 1, 2); // 3
curry(add)(1)(2); // 3
curry(add)(1, 2); // 3
curry(add, 1)(2); // 3

debounce

Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked.

import { debounce } from 'paretojs';

let a = 1;
const fn = () => a = 42;

const debounce = debounce(fn, 500);
debounce();

console.log(a); // 1 before 500ms

setTimeout(() => {
  console.log(a); // 42 after 500ms
}, 600)

deepCopy

Creates a deep copy of an object

import { deepCopy } from 'paretojs';

const object = {
  a: 1,
  b: 2,
  c: {
    d: 3,
  },
};

deepCopy(object); // { a: 1, b: 2, c: { d: 3} }

flatMap

Generates a flattened array by iterating through a collection and applying a function to each element

import { flatMap } from 'paretojs';

const inc = n => n + 1;
flatMap([1, 2, 3], inc)); // [2, 3, 4]

const dup = n => [n, n];
flatMap([1, 2, 3], dup)); // [1, 1, 2, 2, 3, 3]

const sq = n => n ** 2;
flatMap([1, 2, 3], sq)) // [1, 4, 9]

flatten

Flattens (recursively) an array

import { flatten } from 'paretojs';

flatten([1, [2, 3], 4]); // [1, 2, 3, 4]

get

Gets the value of an object property based on a string path provided. If the property is not found, the defaultValues is returned

import { get } from 'paretojs';

get({ a: 1 }, "a")); // 1
get({ a: 1 }, "b", "default")); // "default"
get({ a: { b: 2 } }, "a")); // { b: 2 }
get({ a: { b: 2 } }, "a.b")); // 2
get({ a: { b: 2 } }, "a.c")); // undefined

matches

Checks if an objects matches with some properties

import { matches } from 'paretojs';

const object1 = { a: 1, b: 2 };

matches(object1, { a: 1 }); // true
matches(object1, { a: 1, b: 2 }); // true
matches(object1, { a: 3 }); // false

memoize

Creates a function that memoizes (caches) the result

import { memoize } from 'paretojs';

let count = 0;

const square = x => {
  count = count + 1;
  return x * x;
};

const memoSquare = memoize(square);

count; // 0
memoSquare(10); // 100
memoSquare(10); // 100
memoSquare(10); // 100
count; // 1

pipe

Creates and returns a new function that performs a left-to-right function composition.

import { pipe } from 'paretojs';

const increment = x => x + 1;
const decrement = x => x - 1;

const piped = pipe(increment, increment, decrement);
piped(0); // 1

prop

Gets the property of an object

import { prop } from 'paretojs';

const object = {
  label: 'custom label',
};

prop('label', object); // custom label

sort

Sorts a collection based on a property

import { sort } from 'paretojs';

const collection = [
  {
    id: 2,
  },
  {
    id: 1,
  },
];

sort(collection, 'id'); // [{ id: 1 }, { id: 2 }]

tail

Gets all, except the first element of an array.

import { tail } from 'paretojs';

tail([1, 2, 3]); // [2, 3]

Misc

If you want to add a new function, please open an issue and explain why.

Docs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].