Skip to content

hutsoninc/utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

utils

Build Status Current npm package version

Hutson marketing team utility belt. Used for prototyping and creating one-off tools and scripts.

Usage

npm install @hutsoninc/utils

const {
    csvToJson,
} = require('@hutsoninc/utils')

const csv = 'id\n1\n2'

await csvToJson(csv)
// => [{id: 1}, {id: 2}]

API

csvToJson

Converts a CSV string to a JavaScript object.

const csv = 'id\n1\n2'

await csvToJson(csv)
// => [{id: 1}, {id: 2}]

delay

Asynchronous function to wait for a specified amount of time in ms.

await delay(3000)
// Resolves after 3000ms (3 seconds)

jsonToCsv

Converts a JavaScript object to a CSV string.

const obj = [{ id: 1 }, { id: 2 }]

jsonToCsv(obj, ['id'])
// => 'id\n1\n2'

xmlToJson

Converts a XML string to a JavaScript object.

const xml = '<root>Hello World</root>'

await xmlToJson(xml)
// => { root: 'Hello World' }

License

MIT © Hutson Inc

Releases

No releases published

Packages

No packages published