@yagni-js/yagni

0.7.1 • Public • Published

yagni

Yet another pure functional frontend library.

Pure functional in this context means functional code style - library code is linted using eslint-plugin-fp and eslint-plugin-better. Javascript code is purely functional with just two exceptions:

  • tap() function, used for controllable side effects,
  • mutate() function, used for controllable mutations.

Installation

Using npm:

$ npm install --save-dev @yagni-js/yagni

Using yarn:

$ yarn add -D @yagni-js/yagni

Usage

Source code is written using ES6 modules, built using rollup and distributed in two formats - as CommonJS module and as ES6 module.

CommonJS usage:

const _ = require('@yagni-js/yagni');

ES6 module usage:

import * as _ from '@yagni-js/yagni';
// or
import { pipe, transform, map } from '@yagni-js/yagni';

Documentation

Not yet available, please check sources.

Example

Here is a function to convert an array of objects to http request query string:

import * as _ from '@yagni-js/yagni';


const toQuery = _.pipe([
  _.map(
    _.pipe([
      _.transformArr([
        _.pick('key'),
        _.pipe([
          _.pick('value'),
          encodeURIComponent
        ])
      ]),
      _.join('=')
    ])
  ),
  _.join('&'),
  _.concat('?')
]);

Having input as:

const params = [
  {key: 'name', value: 'John Smith'},
  {key: 'age', value: 35},
  {key: 'country', value: 'UK'}
];

the result will be the following:

const query = toQuery(params);
// query === '?name=John%20Smith&age=35&country=UK'

License

Unlicense

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.7.10latest

Version History

VersionDownloads (Last 7 Days)Published
0.7.10
0.7.00
0.6.00
0.5.00
0.4.00
0.3.00
0.2.10
0.2.00

Package Sidebar

Install

npm i @yagni-js/yagni

Weekly Downloads

0

Version

0.7.1

License

Unlicense

Unpacked Size

155 kB

Total Files

6

Last publish

Collaborators

  • yagnijs
  • ysegorov