@ezs/core
A wrapper to build Stream transformers with functional style
Last updated 8 days ago by touv .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @ezs/core 
SYNC missed versions from official npm registry.

core

Ce plugin propose une série d'instructions natives. Elles sont constamment disponibles car chargées automatiquement.

installation

npm install @ezs/core

usage

Table of Contents

pack

Take all Object, throw encoded String

Returns String

unpack

Take String and throw Object builded by JSON.parse on each line

Returns object

tracer

Take Object, print a character and throw the same object. Useful to see the progress in the stream.

Parameters

  • print String character to print at each object (optional, default .)
  • last String character to print at last call (optional, default .)
  • first String character to print at first call (optional, default .)

Returns Object

debug

Take Object , print it and throw the same object

Parameters

  • level String console level : log or error (optional, default log)
  • text String text before the dump (optional, default valueOf)
  • path String? path of field to print

Returns Object

env

Take Object and send the same object but in the meantime, it is possible to add new environment field with the first Object of the feed

Parameters

  • path String? path of the new field
  • value String? value of the new field

Returns Object

spawn

Take Object and delegate processing to an external pipeline, throw each chunk from the result Note : works like [delegate], but each chunk use its own external pipeline

Parameters

  • file String? the external pipeline is described in a file
  • script String? the external pipeline is described in a string of characters
  • commands String? the external pipeline is described in a object
  • command String? the external pipeline is described in a URL-like command
  • cache String? Use a specific ezs statement to run commands (advanced)

Returns Object

delegate

Takes an Object delegate processing to an external pipeline Note : works like [spawn], but each chunk share the same external pipeline

Parameters

  • file String? the external pipeline is described in a file
  • script String? the external pipeline is described in a string of characters
  • commands String? the external pipeline is described in a object
  • command String? the external pipeline is described in a URL-like command

Returns Object

dispatch

Takes an Object dispatch processing to an external pipeline on one or more servers

Parameters

  • file String? the external pipeline is described in a file
  • script String? the external pipeline is described in a string of characters
  • commands String? the external pipeline is described in a object
  • command String? the external pipeline is described in a URL-like command

Returns Object

parallel

Takes an Object delegate processing to X internal pipelines

Parameters

  • file String? the external pipeline is described in a file
  • script String? the external pipeline is described in a string of characters
  • commands String? the external pipeline is described in a object
  • command String? the external pipeline is described in a URL-like command

Returns Object

time

Measure the execution time of a script, on each chunk on input.

Parameters

Examples

Input

[1]

Program

const script = `
[transit]
`;
from([1])
    .pipe(ezs('time', { script }))

Output

[{
  data: 1,
  time: 15 // milliseconds
}]

Returns object

transit

Take Object and throw the same object Input file:

[{
   a: 1,
},
{
   a: 2,
}]

Script:

[transit]

Output:

[{
   a: 1,
},
{
   a: 2,
}]

Returns Object

concat

Take all String, concat them and thow just one

[
     'a',
     'b',
     'c',
]

Script:

[concat]
beginWith = <
joinWith = |
endWith = >

Output:

[
     '<a|b|c>',
]

Parameters

  • beginWith String? Add value at the begin
  • joinWith String? use value to join 2 chunk
  • endWith String? Add value at the end

Returns String

ungroup

  • **See: group **

Take all chunks, and throw one item for every chunk

[
     [ 'a', 'b', 'c' ],
     [ 'd', 'e', 'f' ],
     [ 'g', 'h' ],
]

Script:

[ungroup]

Output:

[
     'a',
     'b',
     'c',
     'd',
     'e',
     'f',
     'g',
     'h',
]

Returns String

group

Take all chunks, and throw one array of chunks

[
     'a',
     'b',
     'c',
     'd',
     'e',
     'f',
     'g',
     'h',
]

Script:

[group]
length = 3

Output:

[
     [ 'a', 'b', 'c' ],
     [ 'd', 'e', 'f' ],
     [ 'g', 'h' ],
]

Parameters

  • length Number? Size of each partition

Returns String

shift

Return the first Object and close the feed Input file:

[{
   a: 1,
},
{
   a: 2,
},
{
   a: 3,
},
{
   a: 4,
},
{
   a: 5,
}]

Script:

[shift]

Output:

[{
   a: 1,
}]

Returns Object

exchange

Take Object and throw un new item computed by the value= parameter Input file:

[{
   a: 'abcdefg',
   b: '1234567',
   c: 'XXXXXXX',
},
{
   a: 'abcdefg',
   b: '1234567',
   c: 'XXXXXXX',
}]

Script:

[exchange]
value = omit('c')

Output:

[{
   a: 'abcdefg',
   b: '1234567',
},
{
   a: 'abcdefg',
   b: '1234567',
}]

Parameters

  • value String? value to replace input object

Returns Object

extract

Take Object and throw each value of fields Note: extract cannot throw undefined or null values

[{
   a: 'abcdefg',
   b: '1234567',
   c: 'XXXXXXX',
},
{
   a: 'abcdefg',
   b: '1234567',
   c: 'XXXXXXX',
}]

Script:

[extract]
path = a
path = b

Output:

[
   'abcdefg',
   '1234567',
   'abcdefg',
   '1234567',
}]

Parameters

  • path String? path of field to extract

Returns Object

keep

Take Object and throw the same object but keep only specific fields Input file:

[{
   a: 'abcdefg',
   b: '1234567',
   c: 'XXXXXXX',
},
{
   a: 'abcdefg',
   b: '1234567',
   c: 'XXXXXXX',
}]

Script:

[keep]
path = a
path = b

Output:

[{
   a: 'abcdefg',
   b: '1234567',
},
{
   a: 'abcdefg',
   b: '1234567',
}]

Parameters

  • path String? path of field to keep

Returns Object

dump

Take all Object and generete a JSON array

[
    { a: 1 },
    { a: 2 },
    { a: 3 },
    { a: 4 },
    { a: 5 }
]

Script:

[dump]
indent = true

Output:

 [{
    "a": 1
   },
   {
    "a": 2
   },
   {
    "a": 3
   },
   {
    "a": 4
   },
   {
    "a": 5
   }
]

Parameters

  • indent boolean indent JSON (optional, default false)

Returns String

ignore

Takes all the chunks, and ignore the firtst N chunk Input file:

[{
   a: 1,
},
{
   a: 2,
},
{
   a: 3,
},
{
   a: 4,
},
{
   a: 5,
}]

Script:

[ignore]
length = 3

Output:

[{
   a: 4,
},
{
   a: 5,
}]

Parameters

  • length Number? Length of the feed

Returns any

truncate

Takes all the chunks, and closes the feed when the total length is equal to the parameter Input file:

[{
   a: 1,
},
{
   a: 2,
},
{
   a: 3,
},
{
   a: 4,
},
{
   a: 5,
}]

Script:

[truncate]
length = 3

Output:

[{
   a: 1,
},
{
   a: 2,
},
{
   a: 3,
}]

Parameters

  • length Number? Length of the feed

Returns any

shuffle

Take Object, shuffle data of the whole object or only some fields specified by path Input file:

[{
   a: 'abcdefg',
   b: '1234567',
},
{
   a: 'abcdefg',
   b: '1234567',
}]

Script:

[shuffle]
path = a

Output:

[{
   a: 'cadbefg',
   b: '1234567',
},
{
   a: 'dcaegbf',
   b: '1234567',
}]

Parameters

  • path String? path of field to shuffle

Returns Object

validate

From a Object, throw the same object if all rules pass

Input file:

[{
   a: 1,
   b: 'titi',
},
{
   a: 2,
   b: 'toto',
},
{
   a: false,
},
]

Script:

[validate]
path = a
rule = required|number

path = a
rule = required|string

Output:

[{
   a: 1,
   b: 'titi',
},
{
   a: 2,
   b: 'toto',
},
}]

Parameters

  • path String? path of the field
  • rule String? rule to validate the field

Returns Object

replace

Take Object and replace it with a new object with some fields Input file:

[{
   a: 1,
},
{
   a: 2,
},
{
   a: 3,
},
{
   a: 4,
},
{
   a: 5,
}]

Script:

[replace]
path = b.c
value = 'X'

Output:

[{
   b: { c: "X" },
},
{
   b: { c: "X" },
},
{
   b: { c: "X" },
},
{
   b: { c: "X" },
},
{
   b: { c: "X" },
}]

Parameters

  • path String? path of the new field
  • value String? value of the new field

Returns Object

assign

Take Object and add new field Input file:

[{
   a: 1,
},
{
   a: 2,
},
{
   a: 3,
},
{
   a: 4,
},
{
   a: 5,
}]

Script:

[assign]
path = b.c
value = 'X'

Output:

[{
   a: 1,
   b: { c: "X" },
},
{
   a: 2,
   b: { c: "X" },
},
{
   a: 3,
   b: { c: "X" },
},
{
   a: 4,
   b: { c: "X" },
},
{
   a: 5,
   b: { c: "X" },
}]

Parameters

  • path String? path of the new field
  • value String? value of the new field

Returns Object

Current Tags

  • 1.15.0                                ...           latest (8 days ago)

47 Versions

  • 1.15.0                                ...           8 days ago
  • 1.14.0                                ...           9 days ago
  • 1.13.0                                ...           11 days ago
  • 1.12.3                                ...           21 days ago
  • 1.12.2                                ...           a month ago
  • 1.12.1                                ...           2 months ago
  • 1.12.0                                ...           2 months ago
  • 1.11.0                                ...           2 months ago
  • 1.10.4                                ...           2 months ago
  • 1.10.3                                ...           2 months ago
  • 1.10.2                                ...           2 months ago
  • 1.10.1                                ...           3 months ago
  • 1.10.0                                ...           3 months ago
  • 1.9.3                                ...           3 months ago
  • 1.9.2                                ...           4 months ago
  • 1.9.1                                ...           4 months ago
  • 1.9.0                                ...           4 months ago
  • 1.8.3                                ...           5 months ago
  • 1.8.2                                ...           5 months ago
  • 1.8.1                                ...           6 months ago
  • 1.8.0                                ...           6 months ago
  • 1.7.2                                ...           6 months ago
  • 1.7.1                                ...           6 months ago
  • 1.7.0                                ...           6 months ago
  • 1.6.4                                ...           7 months ago
  • 1.6.3                                ...           7 months ago
  • 1.6.2                                ...           7 months ago
  • 1.6.1                                ...           7 months ago
  • 1.6.0                                ...           7 months ago
  • 1.5.1                                ...           8 months ago
  • 1.5.0                                ...           8 months ago
  • 1.3.1                                ...           9 months ago
  • 1.3.0                                ...           9 months ago
  • 1.2.4                                ...           10 months ago
  • 1.2.3                                ...           10 months ago
  • 1.2.2                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.7                                ...           a year ago
  • 1.1.6                                ...           a year ago
  • 1.1.5                                ...           a year ago
  • 1.1.4                                ...           a year ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 44
Last Day 0
Last Week 34
Last Month 12
Dependencies (19)
Dev Dependencies (0)
None
Dependents (2)

Copyright 2014 - 2016 © taobao.org |