All Projects β†’ nanoutils β†’ Nanoutils

nanoutils / Nanoutils

Licence: mit
🌊 Tiniest FP-friendly JavaScript utils library

Programming Languages

javascript
184084 projects - #8 most used programming language
js
455 projects

Projects that are alternatives of or similar to Nanoutils

Dynamic Dark Mode
The smart, automatic Dark Mode toggle for macOS Mojave+
Stars: ✭ 397 (+98.5%)
Mutual labels:  hacktoberfest, utilities
Wipe Modules
πŸ—‘οΈ Easily remove the node_modules folder of non-active projects
Stars: ✭ 304 (+52%)
Mutual labels:  hacktoberfest, utilities
Ramda Adjunct
Ramda Adjunct is the most popular and most comprehensive set of functional utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
Stars: ✭ 550 (+175%)
Mutual labels:  hacktoberfest, utilities
Hyperjson
A hyper-fast Python module for reading/writing JSON data using Rust's serde-json.
Stars: ✭ 374 (+87%)
Mutual labels:  hacktoberfest, module
Npkill
List any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space.
Stars: ✭ 5,325 (+2562.5%)
Mutual labels:  hacktoberfest, module
Airshare
Cross-platform content sharing in a local network
Stars: ✭ 497 (+148.5%)
Mutual labels:  module, utilities
Date Fns
⏳ Modern JavaScript date utility library βŒ›οΈ
Stars: ✭ 27,650 (+13725%)
Mutual labels:  hacktoberfest, utilities
Sequenceserver
Intuitive local web frontend for the BLAST bioinformatics tool
Stars: ✭ 198 (-1%)
Mutual labels:  hacktoberfest
Euclid
User Profile Interface Animation
Stars: ✭ 2,246 (+1023%)
Mutual labels:  module
Mattermost Redux
Redux for Mattermost
Stars: ✭ 198 (-1%)
Mutual labels:  hacktoberfest
Fondo
πŸ“· Wallpaper App for Linux
Stars: ✭ 198 (-1%)
Mutual labels:  hacktoberfest
A Good Readme Template
A template to make good README.md
Stars: ✭ 196 (-2%)
Mutual labels:  hacktoberfest
Codeigniter Ion Auth
Simple and Lightweight Auth System for CodeIgniter
Stars: ✭ 2,290 (+1045%)
Mutual labels:  hacktoberfest
Go Yara
Go bindings for YARA
Stars: ✭ 198 (-1%)
Mutual labels:  hacktoberfest
Windows Terminals
Repository with some awesome Windows Terminals themes
Stars: ✭ 199 (-0.5%)
Mutual labels:  hacktoberfest
Lighthouse Ci
A useful wrapper around Google Lighthouse CLI
Stars: ✭ 198 (-1%)
Mutual labels:  hacktoberfest
Segmented Control
React Native SegmentedControl library
Stars: ✭ 199 (-0.5%)
Mutual labels:  hacktoberfest
Learn Python
List of resources useful for learning Python 🐍
Stars: ✭ 199 (-0.5%)
Mutual labels:  hacktoberfest
Linkedin Skill Assessments Quizzes
Full reference of LinkedIn answers 2021 for skill assessments, LinkedIn test, questions and answers (aws-lambda, rest-api, javascript, react, git, html, jquery, mongodb, java, Go, python, machine-learning, power-point) linkedin excel test lΓΆsungen, linkedin machine learning test
Stars: ✭ 7,014 (+3407%)
Mutual labels:  hacktoberfest
Zeebe Modeler
Desktop Application for modeling Zeebe Workflows with BPMN
Stars: ✭ 198 (-1%)
Mutual labels:  hacktoberfest

nanoutils

npm version npm download npm download

Tiniest JavaScript utils library

Usage

First, install nanoutils:

$ npm install --save nanoutils

or install it with yarn:

$ yarn add nanoutils

To use ES modules we wrote a plugin babel-plugin-nanoutils

To install:

$ npm install --save-dev babel-plugin-nanoutils

or

$ yarn add --dev babel-plugin-nanoutils

Using .babelrc:

{
  "preset": ["env"]
+ "plugins": ["nanoutils"]
}

via CLI:

{
  "scripts": {
+   "babel": "babel --plugins nanoutils app.js",
    "test": "jest && eslint ."
  }
}

or with Node API:

const babel = require('babel-core')

babel.transform('code', {
+ plugins: ['nanoutils']
})

Examples

Sort array of values by name alphabetically or by age

import { ascend, az, prop, sortBy } from 'nanoutils'

const sortByName = sortBy(az(prop('name')))
const sortByAge = sortBy(ascend(prop('age')))

const consultants = [
  { name: 'Mike', age: 30 },
  { name: 'David', age: 35 },
  { name: 'Alex', age: 25 }
]

sortByName(consultants)     // [{ name: 'Alex', age: 25 }, { name: 'David', age: 35 }, { name: 'Mike', age: 30 }]
sortByAge(consultants)     // [{ name: 'Alex', age: 25 }, { name: 'Mike', age: 30 }, { name: 'David', age: 35 }]

Find sum of all ages which will be even next year

import { add, filterT, mapT, pipeT, prop, transduce } from 'nanoutils'

const isEven = value => value % 2 === 0

const sumOfAllEvenAgesNextYear = array => transduce(
  pipeT(
    mapT(prop('age')),
    mapT(add(1)),
    filterT(isEven),
  ),
  add,
  0,
  array
)

const consultants = [
  { name: 'Mike', age: 30 },
  { name: 'David', age: 35 },
  { name: 'Alex', age: 25 }
]

sumOfAllEvenAgesNextYear(ages)   // 62

Return memoized mean

import { ascend, identity, join, mean, memoizeWith, sort } from 'nanoutils'

const getHash = pipe(
  sort(ascend(identity)),
  join('-')
)
const memoizedMean = memoizeWith(getHash, mean)

memoizedMean([1, 2, 3])   // 2
memoizedMean([1, 2, 3])   // 2 (extracts from memoizeWith function with hash='1-2-3')
memoizedMean([3, 1, 2])   // 2 (extracts from memoizeWith function with hash='1-2-3')

Inspiration

We support nano-hype in JavaScript and want to create as much nano-things as possible.
So we're starting a challenge - write Ramda clone where no one method will be over 1KB size.
More nano's for the God of nano's!

Basic ideas

  • Functional style. FP is cool, isn't it? 😎 So we'll add some Ramda methods too.
  • No ES6 features. We don't use Babel to save support in older browsers and save a status of nano-library.
  • Use methods composition only if it won't greatly increase the size of method

Can I use it in my project?

It's production-ready but still has following drawbacks:

  • No TS/Flow types

It's also a Ramda-supportive, you can see both docs and types here: Ramda docs

Roadmap

  • [x] Create methods list
  • [x] Complete all needed methods (we get list of methods from Ramda) with 100% tests and types coverage
  • [x] Add documentation for all methods
  • [ ] Create a tool to split nanoutils to separated packages
  • [ ] Cover all methods with performance tests
  • [ ] Reduce methods sizes even more
  • [ ] Compare to lodash, underscore (?)

NPM scripts

If you want to help, here are some tools for you.

Shortcut for new methods

npm run method:add <...methods> -- [flags]
yarn method:add <...methods> -- [flags]

Params:
    methods           List with method names (separated by space)

Flags:
    -f                Overwrite methods (if exists)
    --curried         Add curried method
                      you can use --curried=<N> to add curryN
    --types           Add index.d.ts and index.js.flow for method typings
    --perf            Add <method>.performance.js for performance test of method

It will create lib/method dir with following files:

index.js                File with method
index.d.ts              TypeScript typings (if --types passed)
index.js.flow           Flow type declaration (if --types passed)
method.test.js          Test for method (I use Jest)
method.performance.js   Performance test for method (if --perf passed)

Check sizes of methods

npm run size <...methods>
yarn size <...methods>

Params
methods           List of method names (separated by space) you want to check.
                  If no methods it will check size of all methods

Check time of methods

npm run time <...methods>
yarn time <...methods>


Params
methods           List of method names (separated by space) you want to check.
                  If no methods it will check time of all possible methods (which have *.performance.js file)
                  If type is set as no_perf (by default), it will throw an error: max.performance.js must have data to return

Check ramda/nanoutils diff

npm run method:check <type>
yarn method:check <type>

Params
type           What to display?
               - both: display methods that are both in ramda and nanoutils
               - nano: display nanoutils methods that ramda doesn't have
               - ramda: display ramda methods that nanoutils doesn't have

We use size-limit to check the size of methods.

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].