All Projects â†’ eserozvataf â†’ Evangelist

eserozvataf / Evangelist

Licence: apache-2.0
🌟 Library of helpers that are useful for functional programming

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Evangelist

Umbrella
"A collection of functional programming libraries that can be composed together. Unlike a framework, thi.ng is a suite of instruments and you (the user) must be the composer of. Geared towards versatility, not any specific type of music." — @loganpowell via Twitter
Stars: ✭ 2,186 (+3668.97%)
Mutual labels:  composition, functional
Typed
The TypeScript Standard Library
Stars: ✭ 124 (+113.79%)
Mutual labels:  composition, functional
Pipetools
Functional plumbing for Python
Stars: ✭ 143 (+146.55%)
Mutual labels:  composition, functional
functional-structures-refactoring-kata
Starting code and proposed solution for Functional Structures Refactoring Kata
Stars: ✭ 31 (-46.55%)
Mutual labels:  functional, composition
v-bucket
📦 Fast, Simple, and Lightweight State Manager for Vue 3.0 built with composition API, inspired by Vuex.
Stars: ✭ 42 (-27.59%)
Mutual labels:  composition, javascript-library
Revalidate
Elegant and composable validations
Stars: ✭ 363 (+525.86%)
Mutual labels:  composition, functional
pyroclastic
Functional dataflow through composable computations
Stars: ✭ 17 (-70.69%)
Mutual labels:  functional, composition
Redash
Tiny functional programming suite for JavaScript.
Stars: ✭ 40 (-31.03%)
Mutual labels:  composition, javascript-library
Simpletones.js
The goal of simpleTones.js is to provide every JavaScript developer with a lightweight solution for creating custom sounds in their web applications. This documentation has been written in hopes that the least experienced developer can read, understand and go on to do great things. You can check out several examples at this link:
Stars: ✭ 45 (-22.41%)
Mutual labels:  javascript-library
Drafter.js
API Blueprint parser in JS
Stars: ✭ 50 (-13.79%)
Mutual labels:  javascript-library
Ansi Escape Sequences
A simple, isomorphic library containing all known terminal ansi escape codes and sequences.
Stars: ✭ 44 (-24.14%)
Mutual labels:  javascript-library
Angular Tree Component
A simple yet powerful tree component for Angular (>=2)
Stars: ✭ 1,031 (+1677.59%)
Mutual labels:  javascript-library
Yglu
Yglu á•„ !? - YAML glue for structural templating and processing
Stars: ✭ 51 (-12.07%)
Mutual labels:  functional
Filepond Boilerplate Php
🔥 A FilePond PHP project starter kit
Stars: ✭ 45 (-22.41%)
Mutual labels:  javascript-library
Opencrypto
OpenCrypto is a lightweight JavaScript library built on top of WebCryptography API
Stars: ✭ 54 (-6.9%)
Mutual labels:  javascript-library
Vue Prism
Simple Vue.js Syntax highlighting with Prism.js
Stars: ✭ 43 (-25.86%)
Mutual labels:  javascript-library
React Native Heic Converter
Convert your HEIC files with React Native
Stars: ✭ 43 (-25.86%)
Mutual labels:  javascript-library
Messageviewjs
Talking Scene JavaScript Library
Stars: ✭ 56 (-3.45%)
Mutual labels:  javascript-library
Prosemirror Mentions
ProseMirror plugin to enable @mentions and #hashtags
Stars: ✭ 55 (-5.17%)
Mutual labels:  javascript-library
Chroma.js
JavaScript library for all kinds of color manipulations
Stars: ✭ 8,364 (+14320.69%)
Mutual labels:  javascript-library

🌟 evangelist

build status npm version npm download dependencies coverage status license

What is the Evangelist?

Evangelist is a set of helper methods that are useful and reusable for base functional programming requirements such as function composition, function decoration, event dispatching and emitting, etc.

Plus, as a library, Evangelist is completely tree-shaking-friendly. Your favorite module bundler can easily inline the functionality you need with no extra configuration, instead of bundling the whole Evangelist package.

Quick start

Execute npm install evangelist or yarn add evangelist to install evangelist and its dependencies into your project directory.

Usage of modules

compose(...functionsForComposition)

import compose from 'evangelist/compose';

// compose - slug sample
const lower = x => x.toLowerCase();
const chars = x => x.replace(/[^\w \-]+/g, '');
const spaces = x => x.split(' ');
const dashes = x => x.join('-');

const slug = compose(lower, chars, spaces, dashes);

const message = slug('Hello World!');

// outputs 'slug: hello-world'
console.log(`slug: ${message}`);

curry(targetFunction, ...argumentsToBePrepended)

import curry from 'evangelist/curry';

// curry - sum sample
const sum = (a, b) => a + b;

const sumWith5 = curry(sum, 5);

const result = sumWith5(3);

// outputs 'result: 8'
console.log(`result: ${result}`);

curryRight(targetFunction, ...argumentsToBeAppended)

import curryRight from 'evangelist/curryRight';

// curryRight - sum sample
const dec = (a, b) => a - b;

const decWith5 = curry(dec, 5);

const result = decWith5(3);

// outputs 'result: -2'
console.log(`result: ${result}`);

decorate(functionToDecorate, decoratorFunction)

import decorate from 'evangelist/decorate';

// decorate - calculator sample
let generator = () => 5;
generator = decorate(generator, (func) => func() * 2);
generator = decorate(generator, (func) => func() + 1);

// outputs: 'generated: 11'
console.log(`generated: ${generator()}`);

dispatcher(initialState, mutators) (awaitable)

import dispatcher from 'evangelist/dispatcher';

// dispatcher - state mutation sample
const initialState = { quarter: 1, year: 2018, sum: 1 };

const actionAdd5 = (state, next) => next({ ...state, sum: state.sum + 5 });
const actionDiv2 = (state, next) => next({ ...state, sum: state.sum / 2 });

// outputs 'new state is: {"quarter":1,"year":2018,"sum":3}'
dispatcher(initialState, [ actionAdd5, actionDiv2 ])
    .then(state => console.log(`new state is: ${JSON.stringify(state)}`));

dispatcher(initialState, mutators, subscribers) (awaitable)

import dispatcher from 'evangelist/dispatcher';

// dispatcher - action logger sample
const initialState = { quarter: 1, year: 2018, sum: 1 };

const actionAdd5 = (state, next) => next({ ...state, sum: state.sum + 5 });
const actionDiv2 = (state, next) => next({ ...state, sum: state.sum / 2 });

const logger = (x) => console.log('INFO', x);

/* outputs:
   INFO { action: 'actionAdd5',
     previousState: { quarter: 1, year: 2018, sum: 1 },
     newState: { quarter: 1, year: 2018, sum: 6 } }
   INFO { action: 'actionDiv2',
     previousState: { quarter: 1, year: 2018, sum: 6 },
     newState: { quarter: 1, year: 2018, sum: 3 } }
   new state is: {"quarter":1,"year":2018,"sum":3}'
*/
dispatcher(initialState, [ actionAdd5, actionDiv2 ], [ logger ])
    .then(state => console.log(`new state is: ${JSON.stringify(state)}`));

emitter(events, eventName, eventParameters) (awaitable)

import emitter from 'evangelist/emitter';

// emitter - static pub/sub sample
const subscriberOne = (value) => console.log(`subscriberOne had value ${value}`);
const subscriberTwo = (value) => console.log(`subscriberTwo had value ${value}`);

const events = {
    printToConsole: [ subscriberOne, subscriberTwo ],
};

/* outputs:
   subscriberOne had value 5
   subscriberTwo had value 5
*/
emitter(events, 'printToConsole', [ 5 ]);

emitter(events, eventName, eventParameters, subscribers) (awaitable)

import emitter from 'evangelist/emitter';

// emitter - event logger sample
const subscriberOne = (value) => console.log(`subscriberOne had value ${value}`);
const subscriberTwo = (value) => console.log(`subscriberTwo had value ${value}`);

const logger = (x) => console.log('INFO', x);

const events = {
    printToConsole: [ subscriberOne, subscriberTwo ],
};

/* outputs:
   INFO { event: 'printToConsole',
     subscriber: 'subscriberOne',
     args: [ 5 ] }
   subscriberOne had value 5
   INFO { event: 'printToConsole',
     subscriber: 'subscriberTwo',
     args: [ 5 ] }
   subscriberTwo had value 5
*/
emitter(events, 'printToConsole', [ 5 ], [ logger ]);

iterate(iterable, func) (awaitable)

import iterate from 'evangelist/iterate';
import compose from 'evangelist/compose';

// iterate - url fetcher example
const generator = function* () {
    yield 'http://localhost/samples/1'; // { value: 1 }
    yield 'http://localhost/samples/2'; // { value: 2 }
    yield 'http://localhost/samples/3'; // { value: 3 }
};

const fetchUrl = async function (url) {
    const response = await fetch(url);
    const document = await response.json();

    return document.value;
}

const add5 = async value => await value + 5;
const printToConsole = async value => { console.log(await value); };

/* outputs:
   value is 6
   value is 7
   value is 8
*/
iterate(
    generator(),
    compose(fetchUrl, add5, printToConsole),
);

Todo List

See GitHub Projects for more.

Requirements

License

Apache 2.0, for further details, please see LICENSE file

Contributing

See contributors.md

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub Issues.

To Support

Visit my patreon profile at patreon.com/eserozvataf

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