npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

x2-utils

v1.3.2

Published

tools

Downloads

5

Readme

x2-utils

Installation

npm install x2-utils const x2utils= require('x2-utils')

API

data processing utils

x2utils.tojson2(options)

{
  from: string, // need to transfer excel path /excel/a.xls
  to: string, // need to save json path /json/a.json
  sheetName: string // need to transfer excel's sheet  
}  

x2utils.toMap(keyName, valueName, data)

keyName: map's key
valueName: map's value

x2utils.toTree(options)

{
  rows: array,  // the data array
  parentId: string, // the root value
  idKey: string, // id's field name
  pidKey: string, // pid's field name
  nameKey: string // name's field name
}

x2utils.findTreeNode = ({ rows=[], id='' }))

{
  rows: array,  // the data array
  id: string // to find the id's node
}

x2utils.col2row = ({data, idField, colField, valueField})

{
  data:array, // data
  idField: string, // unique col field
  colField: string, // col to rows's field name
  valueField: string // colField's value
}

x2utils.row2col = ({data, idField, colField, valueField})

{
  data:array, // data
  idField: string, // unique col field
  colField: string, // row to col's field name
  valueField: string // colField's value
}

http utils

x2utils.getUrl(url, params, tokenId)

url: string, // request url   
params: object, // request params  
tokenId: string // request required tokenId   

x2utils.postUrl(url, params, tokenId)

url: string, // request url   
params: object, // request params  
tokenId: string // request required tokenId   

number utils

Number format thousands: x2utils.addKannma(value, deg)

value: number,  // numbers
deg: int  // Retain decimal places

Number format thousands: x2utils.format(value, option)

value: number,  // numbers
option: {
          type: string,// num , percent, flowNum   
          deg: 2,//  
          kannma: boolean,//is add Thousandths  
          autoUnit: boolean,//is auto calc
          unit: int // Unit conversion value/unit   
        }

Number format thousands and tofixed 2 deg: x2utils.numFormat(value)

value: number,  // numbers  

date utils

date utils: x2utils.getPreMonthsByNum(yearMonth, num)

yearMonth: number,  // yyyy-MM  
num: number // to get a few  month ago

date utils: x2utils.getPreYearsByNum(yearMonth, num)

yearMonth: number,  // yyyy-MM   or yyyy
num: number // to get a few year ago

date utils: x2utils.getMonthBetween(startDate, endDate)

startDate: number,  // yyyy-MM 
 endDate: number // yyyy-MM

formula processing utils

x2utils.formulaValue(formula = '', data = {})

formula:string, // formula like '{value1} / {value2}'
data: object // {value1:1, value2: 1}

x2utils.formulaValues({formula='', data=[], dataKey='formulaName', fields=['value1', 'value2']})

formula:string, // formula like '{name1} + {name2}'
data: object // [{value1:1, value2: 1, formulaName: 'name1'},{value1:1, value2: 1, formulaName: 'name2'}]
fields:arr, // need to calc field
dataKey: string // data's mapping formula's field name

x2utils.computed({formulas = [], data = [], dataKey='formulaName', fields = ['value1', 'value2']})

formula:array, // formula like {formulaName:'name1', formula: '{{name11}} + {{name12}}'}, {formulaName: 'name0', formula: '{{name1}} + {{name2}} - {{name3}}'}]
data: object // [{value1:1, value2: 1, formulaName: 'name1'},{value1:1, value2: 1, formulaName: 'name2'}]
fields:arr, // need to calc field
dataKey: string // data's mapping formula's field name