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

csv-array-to-object

v1.0.13

Published

exSetCSV:

Downloads

376

Readme

how to simplely use

exSetCSV:

[
    ["Key", "column1", "column2"],
    ["uuid1", val1, val3], 
    ["uuid2", val2, val4]
]

ex1:

import csvToObject from "csvToObject"

const toObject = new csvToObject()

// regist header && UUIDKey
toObject.registHeader(header, "Key")
const output = toObject.exec(csvArray) // without header
/*
ex data:

output {
    column1:
        uuid1: val1,
        uuid2: val2

    column2:
        uuid1: val3,
        uuid2: val4
}
*/

ex2:

import csvToObject from "csvToObject"

const toObject = new csvToObject(header, "Key") // setConstructor
const output = toObject.exec(csvArray) // without header

ex3:

import csvToObject from "csvToObject"

const toObject = new csvToObject()

const output = toObject.allInOneExec(csvArray, "Key") // with header

parameter

header

一次元配列を受け取ります。

要素をkeyとしてindexをvalueとして保存します。

numberHeader

一次元配列を受け取ります。

要素をvalueとしてindexをkeyとして保存します。

uuidKey

ユニークなKey名になる列のcolumn名を保存します。

outputKeys

Object化する時のColumn名(ex: column1, column2)を指定の名前で保存します。

function

constructor(header = [], _uuidKey, outputKeys = {})

headerの登録と、outputKeysが存在すれば、outputKeysも登録します。

registOutputKey(src, dst)

srcにheader名,keyに出力したいKey名を入力し、登録します。

changeOutputKeys(src,dst)

srcにheader名,keyに出力したいKey名を入力し、登録します。 ただし、登録されていないheader名の場合Errorを返します。

registUUIDKey(key)

UUIDKeyをkeyで登録します。

registUUIDIndex(index)

UUIDKeyを該当するindexのcolumn名として登録します。

registOutputKeys(outputKeys)

key名とvalueでOutputKeysを登録します。

registHeader(header, uuidKey)

headerを登録し、まだheader名で登録されていないOutputKeyがあれば、valueをheader名として、登録します。

また第二引数でuuidKeyを登録します。

init()

parameterをすべて初期状態に戻します。

exec(data)

引数を、二次元配列で受け取り(headerが存在する場合は除けてください。)出力を返します。

allInOneExec(data, _uuidKey)

引数を、二次元配列で受け取り(header付きで)出力を返します。

githubURL

https://github.com/imamiya-masaki/csvArrayToObject

npmURL

https://www.npmjs.com/package/csv-array-to-object