SR_Data_Manipulator
This package has possible to be diveded into some packages, and to be cold to develop when this is version 1.0.0
バージョン1.0.0になる際に、複数のパッケージに分割したのち、このパッケージの開発自体は凍結する可能性があります。
const Result match = ;const response = "You can use \"Enum\" on JavaScript !";;// You can use "Enum" on JavaScript !
const Enum = ;const OriginalEnum = "you" "can" "make" "original" "enum" "class";const foo = "Each enumeratior can have a value";// .name() method returns own tag nameconsole; //true// .tag() method returns Symbol of own tagconsole //false// "$" + [tag name] means Sybom of each tagsconsole //true
How to install
> npm install sr-data-manipulator
Caution
This module is beta-version. It means that the module probably will be in radical changing.
require / import
You can require all modules as follows.
// Enumconst Enum match Option Result resultOf $Some $None $Ok $Err = ;// Pipelineconst Pipeline Pipe Adaptor:$ R = ;
You can import all modules as follows.
// Enum;// Pipeline;
What's this
This packege give you Enum and pipeline-process.
Enum
Enum(...tags)
make enumeration. Tags should be String witch does not begin with "$" .
Enumeration maek enumerator by new [enumeration].[enumerator]([value])
, and enumerator can have a value.
expect
const FooBar = "Foo" "Bar" "Baz" "Qux"; let mayBeFoo = "fooooo!"; mayBeFoo // "fooooo!" will be shown // nothing will be shown mayBeFoo = "FOOOOO!!"; mayBeFoo // nothing will be shown // "FOOOOO!!" will be shown mayBeFoo = 10; const foo = mayBeFoo ; console; // "9" will be shown
match
const FooBar = "Foo" "Bar" "Baz" "Qux";let mayBeFoo = mayBeFoo = "hello";const foo =;let mayBeFoo = mayBeFoo = "Hello";const foo =;console; // "Hello SR_D_M !" will be shownlet mayBeFoo = mayBeFoo = "Hello";const baz =;console; // "Others" will be shown
default enums
Option = "Some" "None";Result = "Ok" "Err";value;value;value;value;
Pipeline
Pipeline(...Adaptors)
make pipeline with adaptors. Adaptor is a function (process: function(any -> any), data: any) -> result: any
. Each adaptor means how to adapt previous result to process.
Pipe
is default pipeline, witch has $
to pass through previous result and R
to undeal Result.Err
.
Pipe
const someData = "Pipeline of SR_D_M";try const result = await someData //Pipeline of SR_D_M ! //Result.Ok("Pipeline of SR_D_M !") //20 //Result.Err("some thing errored") //will not be dealed //will not be dealed //Pipeline_of_SR_D_M ! --you can overwrite previous result catcherr ;