1.0.1 • Published 4 years ago

shadow-fns v1.0.1

Weekly downloads
38
License
MIT
Repository
github
Last release
4 years ago

shadow-fns

Build Status npm module Coverage Status Dependency Status

Introduction

A javascript function library.

This library referenced ramda and lodash, especially ramda.

Chasing for more simplify and singleness function.

...Okay, just for my own preference.

Features

  • Pure Function
  • Functional
  • Currying
  • Pointfree
  • No Context
  • Close To Native
  • More semantic
f.pipe(f.length, f.gt(5)) 
// => Means check the supplied parameter's length whether longer than 5.

f.tryCatch(JSON.parse, f.always({})) 
// => Means try parse the supplied parameter, when throw an error will return `{}`.

f.pipe(f.map(f.prop('age')), f.sum)
// => Means get every `age` property from the list to an array, then sum it.

All functions read from left-to-right with humanized semantics.

Usage

Browser

<script src="./dist/shadow-fns.umd.min.js"></script>

You can also import from CDN

https://cdn.jsdelivr.net/npm/shadow-fns/dist/shadow-fns.umd.js
https://cdn.jsdelivr.net/npm/shadow-fns/dist/shadow-fns.umd.min.js

then

<script>

f.identity(10) // => 10

</script>

Node

npm i -D shadow-fns

or

yarn add --dev shadow-fns

then in cjs

const f = require('shadow-fns')

or in es

import { * as f } from 'shadow-fns'

then

const users = [
  { name: 'dog', age: 5 },
  { name: 'cat', age: 7 },
  { name: 'human', age: 12 }
]

const sumAge = f.pipe(
  f.map(f.prop('age')), 
  f.sum
)

sumAge(users) // => 24

or just import the required functions

import { pipe, add, multiply } from 'shadow-fns'

const calc = pipe(add(2), multiply(2))

calc(3) // => 10

And if you are using es module, you can import source code directly,

which can show the comments and jump to the source in some IDE, will do much help to develop.

import { * as f } from 'shadow-fns/src'

Documentation

You can check the Full API documentation.

And I propose you to read the Usage Instruction, it will be helpful.

And if you'd like to contribute, see the Contributing Guide.

And Changelog is here.

Try

Click Me!

1.0.1

4 years ago

1.0.0

4 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.4-beta.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1-beta.1

5 years ago

0.1.1-beta.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago