0.0.9 • Published 5 years ago

groupx v0.0.9

Weekly downloads
1
License
GPL-3.0
Repository
-
Last release
5 years ago

Groupx

Group data using UnixTime in Javascript

Install

npm install --save groupx

Options

KeyTypeDefaultDescription
YearIntegerCurrent YearData of Year
MonthIntegerCurrent MonthData of month
Search KeyStringcreate_timeUnix time key
SortStringMonthOptions: Week // Month // Year
FormatBooleanfalse(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

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago