@ezs/analytics
Analytics statements for EZS
Last updated 9 days ago by touv .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @ezs/analytics 
SYNC missed versions from official npm registry.

analytics

Présentation

Ce plugin est propose une série d'instructions pour croiser, compter, trier, agréger des flux d’objets Javascript

installation

npm install @ezs/analytics

usage

Table of Contents

output

Format the output with data a meta

Parameters

  • indent boolean indent or not (optional, default false)
  • meta Array<string>? fields to be considered as metadata object

Examples

Input

[
     { _id: 1, value: 2, total: 2 },
     { _id: 2, value: 4, total: 2 }
]

Script

.pipe(ezs('output', { meta: 'total' }))

Output

{
    data: [
        { _id: 1, value: 2 },
        { _id: 2, value: 4 }
    ],
    meta: {
        total: 2
    }
}

Returns string

topics

Take Object and take values with [value] path (must be an array)

[{
}]

Script:

[use]
plugin = analytics

[topics]

Output:

[
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

minimizing

Take special Object like {id, value} and replace value with the min of values

[{
}]

Script:

[use]
plugin = analytics

[drop]

Output:

[
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

files

Take Object containing filename et throw content by chunk

Note : files must be under the working directory of the Node.js process.

[ fi1e1.csv, file2.csv ]

Script:

[use]
plugin = analytics
plugin = basics

[files]
[CSVParse]

Output:

[
(...)
]

Parameters

  • location String path location to find files (optional, default .)

Returns Object

buffers

Takes all Objects from a store

[
     'AEERRFFF',
     'DFERGGGV',
]

Script:

[use]
plugin = analytics

[buffers]
from = store/13455666/ddd

Output:

 [
          { year: 2000, dept: 54, bufferID: 'AEERRFFF' },
          { year: 2001, dept: 55, bufferID: 'AEERRFFF' },
          { annee: 2003, bufferID: 'DFERGGGV' },
 ]

Parameters

Returns Object

maximizing

Take special Object like {id, value} and replace value with the max of values

[
  { id: 'toul', value: [1, 2, 3] },
  { id: 'nancy', value: [2, 3, 4] },
  { id: 'neufchateau', value: [3, 4, 5] },
]

Script:

[use]
plugin = analytics

[maximizing]

Output:

[
   { "id": "toul", "value": 3 },
   { "id": "nancy", "value": 4 },
   { "id": "neufchateau", "value": 5 }
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

bufferize

Takes all Objects and bufferize them in a store

[
          { year: 2000, dept: 54 },
          { year: 2001, dept: 55 },
          { year: 2003, dept: 54 },
]

Script:

[use]
plugin = analytics

[bufferize]
path = bufferID

Output:

 [
          { year: 2000, dept: 54, bufferID: 'AEERRFFF' },
          { year: 2001, dept: 55, bufferID: 'AEERRFFF' },
          { year: 2003, dept: 54, bufferID: 'AEERRFFF' },
 ]

Parameters

  • path String the path to insert the bufferID (optional, default bufferID)

Returns Object

groupingByModulo

Take Object like { id, value } and reduce all values with the same modulo computation in a ansingle object

[{
}]

Script:

[use]
plugin = analytics

[groupingByModulo]

Output:

[
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

reducing

Take Object group value of { id, value } objectpath

[{
         { id: 'x', value: 2 },
         { id: 't', value: 2 },
         { id: 'x', value: 3 },
         { id: 'x', value: 5 },
}]

Script:

[use]
plugin = analytics

[reducing]

Output:

[
         { id: 'x', value: [2, 3, 5] },
         { id: 't', value: [2] },
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

aggregate

Aggregate by id and count

[{
         { id: 'x', value: 2 },
         { id: 't', value: 2 },
         { id: 'x', value: 3 },
         { id: 'x', value: 5 },
}]

Script:

[use]
plugin = analytics

[aggregate]
path = id

Output:

[
         { id: 'x', value: [ 2, 3, 5] },
         { id: 't', value: [ 2 ]  },
]

Parameters

  • path String path to use for id (optional, default id)
  • value String path to use for value (if not found 1 is the default value) (optional, default value)

Returns Object

slice

Take Object and throw the same object only if it is in the section of the stream between start and start + size. stream is numbered from 1

[{
 { id: 2000, value: 1 },
 { id: 2001, value: 2 },
 { id: 2003, value: 3 },
 { id: 2005, value: 4 },
 { id: 2007, value: 5 },
 { id: 2009, value: 6 },
 { id: 2011, value: 7 },
 { id: 2013, value: 8 },
}]

Script:

[use]
plugin = analytics

[drop]

Output:

[
{ "id": 2001, "value": 2 },
{ "id": 2003, "value": 3 },
]

Parameters

  • start Number start of the slice (optional, default 0)
  • size Number size of the slice (optional, default 10)

Returns Object

distinct

Take Object object getting some fields with json path, and do ...

[{
          { a: 'x', b: 'z' },
          { a: 't', b: 'z' },
          { a: 't', b: 'z' },
          { a: 'x', b: 'z' },
          { a: 'x', b: 'z' },
}]

Script:

[use]
plugin = analytics

[distinct]
path = a

Output:

[
          { id: 'x', value: 1 },
          { id: 't', value: 1 },
          { id: 't', value: 1 },
          { id: 'x', value: 1 },
          { id: 'x', value: 1 },
]

Parameters

  • path String path (optional, default "id")

Returns Object

exploding

Take Object and take values with [value] path (must be an array) and throw object of each value. The new object is build with [id] and eac value.

[
 { departure: ['tokyo', 'nancy'], arrival: 'toul' },
 { departure: ['paris', 'nancy'], arrival: 'toul' },
 { departure: ['london', 'berlin'], arrival: 'toul' },
}]

Script:

[use]
plugin = analytics

[exploding]

Output:

[
   { "id": "toul", "value": "tokyo" },
   { "id": "toul", "value": "nancy" },
   { "id": "toul", "value": "paris" },
   { "id": "toul", "value": "nancy" },
   { "id": "toul", "value": "london" },
   { "id": "toul", "value": "berlin" }
]

Parameters

  • id String path to use for id (optional, default "id")
  • value String path to use for value (optional, default "value")

Returns Object

graph

Take Object and throw a new special object (id, value) for each combination of values

[
 { cities: ['berlin', 'nancy', 'toul'] },
 { cities: ['paris', 'nancy', 'toul']},
 { cities: ['paris', 'berlin', 'toul'] },
}]

Script:

[use]
plugin = analytics

[graph]
path = cities

Output:

[
  { "id": [ "berlin", "nancy" ], "value": 1 },
  { "id": [ "berlin", "toul" ], "value": 2 },
  { "id": [ "nancy", "toul" ], "value": 2 },
  { "id": [ "nancy", "paris" ], "value": 1 },
  { "id": [ "paris", "toul" ], "value": 2 },
  { "id": [ "berlin", "paris" ], "value": 1 }
]

Parameters

Returns Object

pair

Take Object object getting some fields with json path, and throw all pair of value from two fields

[
 { departure: ['tokyo', 'nancy'], arrival: 'toul' },
 { departure: ['paris', 'nancy'], arrival: 'toul' },
 { departure: ['london', 'berlin'], arrival: 'toul' },
]

Script:

[use]
plugin = analytics

[pair]
path = departure
path = arrival

Output:

[
 { "id": [ "tokyo", "toul" ], "value": 1 },
{ "id": [ "nancy", "toul" ], "value": 1 },
{ "id": [ "paris", "toul" ], "value": 1 },
 { "id": [ "nancy", "toul" ], "value": 1 },
 { "id": [ "london", "toul" ], "value": 1 },
 { "id": [ "berlin", "toul" ], "value": 1 }
]

Parameters

Returns Object

merging

Take special Object like {id, value} and replace value with the merge of values

[{
}]

Script:

[use]
plugin = analytics

[merging]

Output:

[
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

summing

Take special Object like {id, value} and replace value with the sum of values

[
 { "id": "A", "value": [1, 1, 1] },
 { "id": "B", "value": [1] },
 { "id": "C", "value": [1, 1, 1, 1] },
]

Script:

[use]
plugin = analytics

[summing]

Output:

[{
  "id": "A", "value": 3
},
{
   "id": "B",
   "value": 1
},
{
   "id": "C",
  "value": 4
}]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

filter

Take Object and throw the same object only if there the value of the select field is equals than a value

  • [
              { id: 2000, value: 1 },
              { id: 2001, value: 2 },
              { id: 2003, value: 3 },
              { id: 2005, value: 4 },
              { id: 2007, value: 5 },
              { id: 2003, value: 3 },
              { id: 2011, value: 7 },
              { id: 2013, value: 8 },
    ]
    

    Script:

    [use]
    plugin = analytics
    
    [filter]
    path = id
    if = 2003
    if = 2013
    
    

Output:

 [
          { id: 2003, value: 3 },
          { id: 2003, value: 3 },
          { id: 2013, value: 8 },
 ]

Parameters

  • path String path of the field to compare (optional, default "value")
  • if Number value to compare (optional, default "")

Returns Object

value

Take Object object and getting the value field

[
 { id: 2000, value: 1 },
 { id: 2001, value: 2 },
 { id: 2003, value: 3 },
 { id: 2005, value: 4 },
 { id: 2007, value: 5 },
 { id: 2009, value: 6 },
 { id: 2011, value: 7 },
 { id: 2013, value: 8 },
]

Script:

[use]
plugin = analytics

[value]
path = id

Output:

[
2000,
2001,
2003,
2005,
2007,
2009,
2011,
2013
]

Parameters

  • path String the pah of the value field (optional, default value)

Returns Object

greater

Take Object and throw the same object only if the value of the selected field is greater (or equal) than a value

[
          { id: 2000, value: 1 },
          { id: 2001, value: 2 },
          { id: 2003, value: 3 },
          { id: 2005, value: 4 },
          { id: 2007, value: 5 },
          { id: 2009, value: 6 },
          { id: 2011, value: 7 },
          { id: 2013, value: 8 },
]

Script:

[use]
plugin = analytics

[greater]
than = 3
strict = true

Output:

[
          { id: 2005, value: 4 },
          { id: 2007, value: 5 },
          { id: 2009, value: 6 },
          { id: 2011, value: 7 },
          { id: 2013, value: 8 },
]

Parameters

  • path String path of the field to compare (optional, default "value")
  • than Number value to compare (optional, default 0)
  • strict Boolean greater than but not equal (optional, default false)

Returns Object

pluck

Take Object object getting value of fields (with json path) and throws an object for each value

[
 { city: 'tokyo', year: 2000, count: 1 },
 { city: 'paris', year: 2001, count: 2 },
 { city: 'london', year: 2003, count: 3 },
 { city: 'nancy', year: 2005, count: 4 },
 { city: 'berlin', year: 2007, count: 5 },
 { city: 'madrid', year: 2009, count: 6 },
 { city: 'stockholm', year: 2011, count: 7 },
 { city: 'bruxelles', year: 2013, count: 8 },
]

Script:

[use]
plugin = analytics

[pluck]
path = year

Output:

[
{ "id": "year", "value": 2000 },
{ "id": "year", "value": 2001 },
{ "id": "year", "value": 2003 },
{ "id": "year", "value": 2005 },
{ "id": "year", "value": 2007 },
{ "id": "year", "value": 2009 },
{ "id": "year", "value": 2011 },
{ "id": "year", "value": 2013 }
]

Parameters

  • path String path to use form group by (optional, default id)

Returns Object

drop

Take Object and throw the same object only if there the value of the select field is not equals than a value

[
  {
   "departure": "nancy",
   "arrival": "paris",
 },
 {
   "departure": "nancy",
   "arrival": "toul",
 },
 {
   "departure": "paris",
   "arrival": "londre",
 }
]

Script:

[use]
plugin = analytics

[drop]

Output:

[{
  "departure": "nancy",
  "arrival": "paris"
},
{
   "departure": "nancy",
  "arrival": "toul"
}]

Parameters

  • path String path of the field to compare (optional, default "value")
  • if Number value to compare (optional, default "")

Returns Object

groupingByHamming

Take Object like { id, value } and reduce all value with id which have the same Hamming distance in a single object

  • [
       { "id": "lorem", "value": 1 },
       { "id": "Lorem", "value": 1 },
       { "id": "loren", "value": 1 },
       { "id": "korem", "value": 1 },
       { "id": "olrem", "value": 1 },
       { "id": "toto", "value": 1 },
       { "id": "titi", "value": 1 },
       { "id": "lorem", "value": 1 }
    ]
    

    Script:

    [use]
    plugin = analytics
    
    [groupingByHamming]
    distance = 1
    
    [summing]
    
    

Output:

[
   { "id": [ "lorem", "Lorem", "loren", "korem" ], "value": 5 },
   { "id": [ "olrem" ], "value": 1 },
   { "id": [ "toto", "titi" ], "value": 2 }
]

Parameters

  • id String path to use for id (optional, default "id")
  • value String path to use for value (optional, default "value")

Returns Object

groupingByLevenshtein

Take Object like { id, value } and reduce all values with id which have the same Levenshtein distance in a single object

[
   { "id": "lorem", "value": 1 },
   { "id": "Lorem", "value": 1 },
   { "id": "loren", "value": 1 },
   { "id": "korem", "value": 1 },
   { "id": "olrem", "value": 1 },
   { "id": "toto", "value": 1 },
   { "id": "titi", "value": 1 },
   { "id": "lorem", "value": 1 }
]

Script:

[use]
plugin = analytics

[groupingByLevenshtein]
distance = 2

[summing]

Output:

[
   { "id": [ "lorem", "Lorem", "loren", "korem", "olrem" ], "value": 6 },
   { "id": [ "toto", "titi" ], "value": 2 }
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)
  • distance Number minimal levenshtein distance to have a same id (optional, default 1)

Returns Object

keys

Take Object and throws all its keys

[
 { city: 'tokyo', year: 2000, count: 1 },
 { city: 'paris', year: 2001, count: 2 },
 { city: 'london', year: 2003, count: 3 },
 { city: 'nancy', year: 2005, count: 4 },
 { city: 'berlin', year: 2007, count: 5 },
 { city: 'madrid', year: 2009, count: 6 },
 { city: 'stockholm', year: 2011, count: 7 },
 { city: 'bruxelles', year: 2013, count: 8 },
]

Script:

[use]
plugin = analytics

[keys]
[aggregate]
[summing]

Output:

[
{
   "id": "city",
   "value": 8
},
{
  "id": "year",
  "value": 8
},
{
   "id": "count",
   "value": 8
}⏎
]

Parameters

Returns Object

groupingByEquality

Take Object like { id, value } and reduce all values with the same id in a single object

[
   { "id": "lorem", "value": 1 },
   { "id": "Lorem", "value": 1 },
   { "id": "loren", "value": 1 },
   { "id": "korem", "value": 1 },
   { "id": "olrem", "value": 1 },
   { "id": "toto", "value": 1 },
   { "id": "titi", "value": 1 },
   { "id": "lorem", "value": 1 }
]

Script:

[use]
plugin = analytics

[groupingByEquality]

[summing]

Output:

[
  { "id": [ "lorem" ], "value": 2 },
  { "id": [ "Lorem" ], "value": 1 },
  { "id": [ "loren" ], "value": 1 },
  { "id": [ "korem" ], "value": 1 },
  { "id": [ "olrem" ], "value": 1 },
  { "id": [ "toto" ], "value": 1 },
  { "id": [ "titi" ], "value": 1 }
]

Parameters

  • id String path to use for id (optional, default id)
  • value String path to use for value (optional, default value)

Returns Object

multiply

Take Object and throw the same object only if there the value of the select field is equals than a value Input file:

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

Script:

[use]
plugin = analytics

[multiply]
path = factor
value = X
value = Y
value = Z

Output:

[{
   a: 1,
   b: 2,
   factor: X
},
{
   a: 1,
   b: 2,
   factor: Y
},
{
   a: 1,
   b: 2,
   factor: Z
},
]

Parameters

  • path String path of the field to add (optional, default "factor")
  • value String value(s) to set factor field (optional, default "")

Returns Object

less

Take Object and throw the same object only if the value of the selected field is less (or equal) than a value

[{
          { id: 2000, value: 1 },
          { id: 2001, value: 2 },
          { id: 2003, value: 3 },
          { id: 2005, value: 4 },
          { id: 2007, value: 5 },
          { id: 2009, value: 6 },
          { id: 2011, value: 7 },
          { id: 2013, value: 8 },
}]

Script:

[use]
plugin = analytics

[less]
path = value
than = 4

Output:

[{
   "id": 2000,
   "value": 1
},
{
   "id": 2001,
  "value": 2
},
{
   "id": 2003,
   "value": 3
},
{
   "id": 2005,
   "value": 4
}]

Parameters

  • path String path of the field to compare (optional, default value)
  • than Number value to compare (optional, default 0)
  • strict Boolean less than but not equal (optional, default false)

Returns Object

count

Take Object and throw special Object like {id, value} if key(s) was found id is the key, value is equal to 1 (if found)

[
 {
      "a": "nancy",
      "b": "lucy",
      "c": "geny",
  },
  {
      "a": "lorem",
      "b": "loret",
  },
  {
      "a": "fred",
  }
]

Script:

[use]
plugin = analytics

[count]
path = a
path = b
path = c

[aggregate]
[summing]

Output:

[{
   "id": "a",
   "value": 3
},
{
   "id": "b",
   "value": 2
},
{
   "id": "c",
   "value": 1
}]

Parameters

Returns Object

distribute

Take Object like { id, value } and throw a serie of number value

[
          { id: 2000, value: 1 },
          { id: 2001, value: 2 },
          { id: 2003, value: 3 },
          { id: 2005, value: 4 },
          { id: 2007, value: 5 },
          { id: 2009, value: 6 },
          { id: 2011, value: 7 },
          { id: 2013, value: 8 },
]

Script:

[use]
plugin = analytics

[distribute]

Output:

[
      { "id": 2000, "value": 1 },
     { "id": 2001, "value": 2 },
     { "id": 2002, "value": 0 },
     { "id": 2003, "value": 3 },
     { "id": 2004, "value": 0 },
     { "id": 2005, "value": 4 },
     { "id": 2006, "value": 0 },
     { "id": 2007, "value": 5 },
     { "id": 2008, "value": 0 },
     { "id": 2009, "value": 6 },
     { "id": 2010, "value": 0 },
     { "id": 2011, "value": 7 },
     { "id": 2012, "value": 0 },
     { "id": 2013, "value": 8 }
]

Parameters

  • id String path to use for id (optional, default "id")
  • value String path to use for value (optional, default "value")
  • step String step between each value (optional, default 1)
  • start Number first value to throw (optional, default minvalueinthestream)
  • size Number size of the distribution (optional, default (maxvalue-minvalue)inthestream)
  • default Number default value for missing object (optional, default 0)

Returns Object

sort

Take all Object and sort them with dedicated key

[{
 { id: 2000, value: 1 },
 { id: 2001, value: 2 },
 { id: 2003, value: 3 },
 { id: 2005, value: 4 },
 { id: 2007, value: 5 },
 { id: 2009, value: 6 },
 { id: 2011, value: 7 },
 { id: 2013, value: 8 },
}]

Script:

[use]
plugin = analytics

[sort]
path = value
reverse = true

Output:

[
{ "id": 2013, "value": 8 },
{ "id": 2011, "value": 7 },
{ "id": 2009, "value": 6 },
{ "id": 2007, "value": 5 },
{ "id": 2005, "value": 4 },
{ "id": 2003, "value": 3 },
{ "id": 2001, "value": 2 },
{ "id": 2000, "value": 1 }
]

Parameters

  • path String path to use for id (optional, default id)
  • reverse boolean reverser order (optional, default false)

Returns Object

expand

Takes an Object and substitute a field with the corresponding value found in a external pipeline the internal pipeline receive a special object { id, value } id is the item identifier & value is the item path value The internal pipeline can expand value with another

[
          { year: 2000, dept: 54 },
          { year: 2001, dept: 55 },
          { year: 2003, dept: 54 },
]

Script:

[use]
plugin = analytics

[expand]
path = dept
file = ./departement.ini

Output:

 [
          { year: 2000, dept: { id: 54, value: 'Meurthe et moselle' } },
          { year: 2001, dept: { id: 55, value: 'Meuse' } },
          { year: 2003, dept: { id: 54, value: 'Meurthe et moselle' } },
 ]

Parameters

  • path String? the path to substitute
  • 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

combine

Takes an Object and substitute a field with the corresponding value found in a external pipeline the internal pipeline must produce a stream of special object (id, value)

[
          { year: 2000, dept: 54 },
          { year: 2001, dept: 55 },
          { year: 2003, dept: 54 },
]

Script:

[use]
plugin = analytics

[combine]
path = dept
file = ./departement.ini

Output:

 [
          { year: 2000, dept: { id: 54, value: 'Meurthe et moselle' } },
          { year: 2001, dept: { id: 55, value: 'Meuse' } },
          { year: 2003, dept: { id: 54, value: 'Meurthe et moselle' } },
 ]

Parameters

  • path String? the path to substitute
  • primer String Data to send to the external pipeline (optional, default auto)
  • 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
  • persistent String The internal database will be reused until it is deleted (optional, default false)
  • cache String? Use a specific ezs statement to run commands (advanced)

Returns Object

distance

To compare 2 fields with 2 id and compute a distance

  • for arrays, the distance is calculated according to the number of element in common
[{
           {
              id_of_a: 1,
              id_of_b: 2,
              a: ['x', 'y'],
              b: ['x', 'z'],
          },
          {
              id_of_a: 1,
              id_of_b: 3,
              a: ['x', 'y'],
              b: ['y', 'z'],
          },
          {
              id_of_a: 1,
              id_of_b: 4,
              a: ['x', 'y'],
              b: ['z'],
          },
          {
              id_of_a: 1,
              id_of_b: 5,
              a: ['x', 'y'],
              b: ['x', 'y', 'z'],
          },
          {
              id_of_a: 1,
              id_of_b: 6,
              a: ['x', 'y'],
              b: ['x', 'y'],
          },
}]

Script:

[use]
plugin = analytics

[distance]
id = id_of_a
id = id_of_b
value = a
value = b

Output:

[
    { id: [ 1, 2 ], value: 0.5 },
    { id: [ 1, 3 ], value: 0.5 },
    { id: [ 1, 4 ], value: 0 },
    { id: [ 1, 5 ], value: 0.8 },
    { id: [ 1, 6 ], value: 1 }
  ]

]

Parameters

  • path String path (optional, default value)

Returns Object

segment

Take Object object getting some fields with json path, and throw segment of value. Ex: get [a,b,c] and throw [a,b], [b,c]

[{
          {
              id: 'doc#1',
              value: [
                   1,
                   2,
                  3,
                   4,
               ],
          },
          {
              id: 'doc#2',
              value: [
                  4,
                  5,
                  6,
              ],
          },
          {
              id: 'doc#3',
              value: [
                  6,
                  7,
              ]
          },
          {
              id: 'doc#4',
              value: [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
              ]
          }
}]

Script:

[use]
plugin = analytics

[segment]
path = value

Output:

[
  { id: [ 1, 2 ], value: 1 }
  { id: [ 2, 3 ], value: 1 }
  { id: [ 3, 4 ], value: 1 }
  { id: [ 4, 5 ], value: 1 }
  { id: [ 5, 6 ], value: 1 }
  { id: [ 6, 7 ], value: 1 }
  { id: [ 1, 2 ], value: 1 }
  { id: [ 2, 3 ], value: 1 }
  { id: [ 3, 4 ], value: 1 }
  { id: [ 4, 5 ], value: 1 }
  { id: [ 5, 6 ], value: 1 }
  { id: [ 6, 7 ], value: 1 }
]

Parameters

  • path String path (optional, default value)
  • aggregate Boolean aggregate all values for all paths (or not) (optional, default true)

Returns Object

tune

Take all Object and sort them with selected field

[{
}]

Script:

[use]
plugin = analytics

[tune]

Output:

[
]

Parameters

  • path String path to use for the sort key (optional, default id)

Returns Object

statistics

Compute some statistics from one or more fields

Parameters

  • path String path of the value field (optional, default value)
  • target String path of statistics in output object (optional, default _statistics)

Examples

Input

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

Script

```ini
[use]
plugin = analytics

[statistics]
path = a

```

Output

```json
[{
    "a": 1,
    "stats": {
        "a": {
            "sample": 2,
            "frequency": 1,
            "percentage": 25,
            "sum": 4,
            "count": 3,
            "min": 1,
            "max": 2,
            "mean": 1.3333333333333333,
            "range": 1,
            "midrange": 0.5,
            "variance": 0.2222222222222222,
            "deviation": 0.4714045207910317,
            "population": 2
        }
    }
},
{
    "a": 1,
    "stats": {
        "a": {
            "sample": 2,
            "frequency": 1,
            "percentage": 25,
            "sum": 4,
            "count": 3,
            "min": 1,
            "max": 2,
            "mean": 1.3333333333333333,
            "range": 1,
            "midrange": 0.5,
            "variance": 0.2222222222222222,
            "deviation": 0.4714045207910317,
            "population": 2
        }
     }
},
{
    "a": 2,
    "stats": {
        "a": {
            "sample": 1,
            "frequency": 0.5,
            "percentage": 50,
            "sum": 4,
            "count": 3,
            "min": 1,
            "max": 2,
            "mean": 1.3333333333333333,
            "range": 1,
            "midrange": 0.5,
            "variance": 0.2222222222222222,
            "deviation": 0.4714045207910317,
            "population": 2
     }
   }
}]
```

Returns Object

Current Tags

  • 1.9.2                                ...           latest (9 days ago)

38 Versions

  • 1.9.2                                ...           9 days ago
  • 1.9.1                                ...           11 days ago
  • 1.8.0                                ...           2 months ago
  • 1.7.2                                ...           2 months ago
  • 1.7.1                                ...           2 months ago
  • 1.7.0                                ...           2 months ago
  • 1.6.2                                ...           3 months ago
  • 1.6.1                                ...           3 months ago
  • 1.6.0                                ...           3 months ago
  • 1.5.1                                ...           4 months ago
  • 1.5.0                                ...           4 months ago
  • 1.4.3                                ...           5 months ago
  • 1.4.2                                ...           5 months ago
  • 1.4.1                                ...           5 months ago
  • 1.4.0                                ...           5 months ago
  • 1.3.4                                ...           6 months ago
  • 1.3.3                                ...           6 months ago
  • 1.3.2                                ...           6 months ago
  • 1.3.1                                ...           6 months ago
  • 1.3.0                                ...           6 months ago
  • 1.2.7                                ...           7 months ago
  • 1.2.6                                ...           7 months ago
  • 1.2.5                                ...           8 months ago
  • 1.2.4                                ...           8 months ago
  • 1.2.2                                ...           9 months ago
  • 1.2.1                                ...           9 months ago
  • 1.2.0                                ...           9 months ago
  • 1.1.0                                ...           9 months ago
  • 1.0.10                                ...           10 months ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 21
Last Day 0
Last Week 21
Last Month 0
Dependencies (11)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |