Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A functionnal library based on a powerfull chain mecanism.

License

NotificationsYou must be signed in to change notification settings

evanliomain/taninsam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation available in :https://evanliomain.github.io/taninsam

A functionnal library based on a powerfull chain mecanism.

ReleaseCoveralls

styled with prettierMade withCommitizen friendlysemantic-release

npmnpm bundle sizenpm bundle sizenpmnpm

npm

Why should I use Taninsam ?

Yes you could just use simple ESNext functions to do your transformation. If you enjoy with it, just keep it that way.

But sometime, the code don't feel linear, so you are tempted to use a library. So why this one, instead of another ?

Taninsam is:

  • Write in Typescript to enforced the feature correctness
  • Write in full TDD because is so easy to do it that way
  • Offer a simple way for chain function
  • Offer a constante way to code data transformation: no more function alias or 2 way to compose functions
  • Easy to extend: justchain a function

Getting started

Install taninsam:

npm install --save taninsam

or

yarn add taninsam

Import the librairie and start the chain:

import{chain,filter,map,sum}from'taninsam';// Sum square of even number in this collectionchain([1,2,3,4,5,6,7,8,9,10]).chain(filter(x=>0===x%2))// [2, 4, 6, 8, 10].chain(map(x=>x**2))// [4, 16, 36, 64, 100].chain(sum())// 220.value();

To understand the chain function, it's as easy as this:

functionchain(x){return{chain:f=>chain(f(x)),value:()=>x};}

So you canchain as much as function you want, and calledvalue() at the end to get the actual value.

To extend the chain, it's as easy as to write a function:

import{chain}from'taninsam';chain(2).chain(x=>x**2).chain(x=>`square of 2 is${x}`).value();// 'square of 2 is 4'

Contributing

Installation

yarn

Coding

Main commands to develop

  • Use vscode for coding (or any other good editor that suite you)
  • yarn gen: Create a new function
  • yarn test:watch: Run test suite ininteractive watch mode
  • yarn commit: Commit using conventional commit style

Additionals commands

  • yarn lint: Lints code
  • yarn test: Run test suite once
  • yarn stryker: Run mutation testing suite once
  • yarn build: Generate bundles and typings, create docs
  • yarn start: Runsnpm run build in watch mode

Code source is automatically formatted and linted at each commit.

This library was bootstraped bytypescript-library-starter.


[8]ページ先頭

©2009-2025 Movatter.jp