groupx

0.0.9 • Public • Published

Groupx

Group data using UnixTime in Javascript

Install

npm install --save groupx

Options

Key Type Default Description
Year Integer Current Year Data of Year
Month Integer Current Month Data of month
Search Key String create_time Unix time key
Sort String Month Options: Week // Month // Year
Format Boolean false (if set to true) format week days to date

Functions

  • month: set group month.
  • year: set group year
  • type: sort type (by week/month/year)
  • serach_key: set search_key
  • sort: sort data
  • format: convert week days number to date, works only with arrays.

You can't use month/year/type/search_key functions after sort and you can't use format before sort

Examples

Arrays:

var data = new groupx({search_key:"create_time",sort:"week"}).sort([{   name:"Jamal1",   create_time:1524758704  },{  name:"Jamal2",  create_time:1524860213  }]); 

console.log(data); // => {"f":[1,1],"g":{"26":[ "data" ],"27":[ "data" ]},"v":[0,0,0,0,1,1,0],"y":[{"key":22,"results":0},{"key":23,"results":0},{"key":24,"results":0},{"key":25,"results":0},{"key":26,"results":1},{"key":27,"results":1},{"key":28,"results":0}],"x":[0,0,0,0,1,1,0]}

JSON:

var data2 = new groupx({search_key:"create_time",sort:"week"}).sort({  x:{  key:"x",  data:[{  name:"Jamal1",  create_time:1524758704  },{  name:"Jamal2",  create_time:1524860213  }]  },  y:{  key:"y",  data:[{  name:"Jamal1",  create_time:1524758704  },{  name:"Jamal2",  create_time:1524860213  }]  }  }); 

console.log(data2); // => [ { key: 22, x: 0, y: 0 }, { key: 23, x: 0, y: 0 }, { key: 24, x: 0, y: 0 }, { key: 25, x: 0, y: 0 }, { key: 26, x: 1, y: 1 }, { key: 27, x: 1, y: 1 }, { key: 28, x: 0, y: 0 } ]

License

GPL-3.0

Package Sidebar

Install

npm i groupx

Weekly Downloads

1

Version

0.0.9

License

GPL-3.0

Unpacked Size

46.2 kB

Total Files

10

Last publish

Collaborators

  • jamalabo1