Giter VIP home page Giter VIP logo

fwv's Introduction

fwv

tests cover size

A ⚡️ crazy fast streaming ⚡️ Fixed Width Value Parser

This module is mostly useful to folks who have to parse fixed-width format files. Fixed-width files are often created from database reports or from Microsoft Excel. However, this module can also be used to quickly parse a string containing data at specified locations.

Note: This module requires Node v8.11.0 or higher.

Install

Using npm:

$ npm install fwv

Using yarn:

$ yarn add fwv

Usage

const fwv = require('fwv');

const options = {
  columns: [
    { name: 'id', from: 0, to: 4 },
    { name: 'name', from: 5, to: 11 },
    { name: 'cost', from: 12, to: 16 }
  ],
  input: '0001 WIDGET 5.00'
}

const result = await fwv(options);

//→ [ { id: '0001', name: 'WIDGET', cost: '5.00' }]

API

fwv([options])

Returns: Array[object]

options

Type: object

columns

Type: Array[object]

An array of column configurations. Each item in the array will correspond to a property on the result for a given line.

  {
    name: <string>,  // the name of the column / result object property
    from: <integer>, // the start position of the column
    to: <integer>    // the end position of the column
  }

Note: For an example column configuration, see test/fixtures/config.js.

input

Type: string|Buffer|Stream

An input value, upon which the parser will run.

Passing a readable Stream is preferred, but you may pass a string or Buffer, and the module will convert it to a Stream for you.

Meta

CONTRIBUTING

LICENSE (MIT)

fwv's People

Contributors

shellscape avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.