Skip to content
/ pipjs Public

A POP(protocal oriented programming) lib with FP and immutable. (developing)

Notifications You must be signed in to change notification settings

dayuoba/pipjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pipjs (developing)

A POP(protocal oriented programming) lib with FP and immutable.

Demo

toolchain with lazy and immutable inside

const $ = require('pipjs');

const x = $.pip([0, 2, 3, 4])
  .map(item => {
  	return item;
  })
  .filter(Boolean)
  .reduce((prev, curr) => {
  	return prev + curr;
  }, 0)
  .done();

deal with http

const $ = require('pipjs');
const $TYPE = $.MODEL_TYPE;

const people = $.model({
	name: $TYPE.string.isRequired,
	age: $TYPE.number.isRequired,
	sex: $TYPE.string.isRequired,
	habits: $TYPE.arrayString.isRequired,
});

// here is a data where you got from a http request
const u = {
	name: 'lilei',
	age: '19', // wrong type
	sex: 'F',
	habits: ['sing', 12], // wrong mix type array
	foo: 'bar'
};

let [err, data] = people.fit(u);
if (err) {
	return console.log(err);
}
console.log(data); // data is a new set which match people model

About

A POP(protocal oriented programming) lib with FP and immutable. (developing)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published