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

@nxus/data-loader

v2.4.0-10

Published

Data format parsers and loaders for nxus

Downloads

16

Readme

DataLoader

src/index.js:43-183

Import file contents as arrays of objects

Installation

npm install @nxus/data-loader --save

Options

All responses accept an options argument, in addition to any parser-specific options you can indicate:

  • mapping: object of {field: newField} name mappings
  • identityFields: for importing to models, array of fields to be used for createOrUpdate query

Events

You can modify the records during import with the following specific events:

  • records.type: e.g. app.get('data-loader').after('records.csv', (results) => {})
  • record.type: e.g. app.get('data-loader).after('record.csv', (one) => {})
  • models.identity: e.g. app.get('data-loader').after('models.user', (results) => {})
  • model.identity: e.g. app.get('data-loader).after('model.user', (user) => {})

record_ events occur after parsing and name mapping model_ events occur after record events and before models are created/updated.

API

src/index.js:32-32

Import file contents as arrays of objects

Installation

npm install @nxus/data-loader --save

Options

All responses accept an options argument, in addition to any parser-specific options you can indicate:

  • mapping: object of {field: newField} name mappings
  • identityFields: for importing to models, array of fields to be used for createOrUpdate query
  • truncate: for importing to models, true/false for deleting existing collection data before import. Ignored if identityFields is provided.
  • strict: defaults to true. Only import columns/data that matches the attribute names for the model. Set to false to import everything.

Events

You can modify the records during import with the following specific events:

  • records.type: e.g. app.get('data-loader').after('records.csv', (results) => {})
  • record.type: e.g. app.get('data-loader).after('record.csv', (one) => {})
  • models.identity: e.g. app.get('data-loader').after('models.user', (results) => {})
  • model.identity: e.g. app.get('data-loader).after('model.user', (user) => {})

record_ events occur after parsing and name mapping model_ events occur after record events and before models are created/updated.

API


export

src/JSONExporter.js:14-21

Stringify an array of results into JSON. Assumes top-level is array, unless opts.key is provided to wrap results in an object.

Parameters

export

src/index.js:112-116

Request formattted output based on type

Parameters

  • type string The type (e.g. 'html') of the output content
  • records [object] The records to export
  • opts object Options for the exporter context

Returns Promise String of formatted output

exporter

src/index.js:96-98

Provide an exporter for a particular type (file extension)

Parameters

  • type string The type (e.g. 'html') this exporter creates
  • handler function Function to receive (content, options) and return formatted output content

import

src/index.js:125-132

Request parsed results based on type

Parameters

  • type string The type (e.g. 'html') of the content
  • content string The contents to parse
  • opts object Options for the parser context

Returns Promise Array of parsed result objects

importFile

src/index.js:140-149

Request parsed results from a file path

Parameters

  • filename string The filename to read and parse
  • opts object Options for the parser context

Returns Promise Array of parsed result objects

importFileToModel

src/index.js:172-176

Import file contents to a model

Parameters

  • model string The identity of the model to populate
  • filename string The filename to read and parse
  • opts object Options for the parser context

Returns Promise Array of instances

importToModel

src/index.js:159-163

Import string contents to a model

Parameters

  • model string The identity of the model to populate
  • type string The type (e.g. 'html') of the content
  • content string The contents to parse
  • opts object Options for the parser context

Returns Promise Array of instances

parser

src/index.js:86-90

Provide a parser for a particular type (file extension)

Parameters

  • type string The type (e.g. 'html') this renderer should handle
  • handler function Function to receive (content, options) and return parsed array of result objects

parse

src/JSONParser.js:14-20

Parse JSON into an array of results. Assumes top-level is array, unless opts.key is provided to pick a top-level key from parsed object as results.

Parameters