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

eflex-fixy

v1.2.0

Published

A Fixed Width Input Parser

Downloads

4

Readme

npm version Dependency Status devDependency Status Build Status

Fixy

Fixy is an npm module for parsing fixed formatted strings/files and unparsing an Array of Objects.

Install

npm install fixy --save

Usage

fixy.parse | Single Level
var fixy = fixy.parse({
	map:[{
		name: "Age",
		width: 2,
		start: 1,
		type: "int"
	},{
		name: "Initial",
		width: 3,
		start: 3,
		type: "string"
	}],
	options:{
		fullwidth: 5,
		skiplines: null,
		format: "csv"
	}
}, "21ABC\n22DEF");
fixy.parse | Multi Level
var fixy = fixy.parse({
	map:[{
		name: "Name",
		width: 7,
		start: 1,
		type: "string",
		level: "A"
	},{
		name: "Age",
		width: 2,
		start: 1,
		type: "int",
		level: "B"
	}],
	options:{
		skiplines: null,
		levels: {
			"A": {
				nickname: "A",
				start: 0,
				end: 0,
				fullwidth: 7
			},
			"B": {
				nickname: "B",
				start: 1,
				end: 2,
				fullwidth: 2
			}
		}
	}
}, "Steve  \n30");
fixy.unparse | Single Level
var fixy = fixy.unparse([{
	name: "Age",
	width: 7,
	padding_position: "end",
	padding_symbol: "#"
},{
	name: "Initial",
	width: 4,
	padding_position: "end",
	padding_symbol: "@"
}], [{
	Age: 30,
	Initial: "SJP"
},{
	Age: 20,
	Initial: "CCS"
}]);
fixy.unparse | Multi Level
var fixy = fixy.unparse([{
	name: "Name",
	width: 7,
	padding_position: "end",
	level: "A",
},{
	name: "Age",
	width: 3,
	padding_position: "end",
	level: "B"
},{
	name: "Initial",
	width: 4,
	padding_position: "end",
	level: "B"
}], {
	A: [{ Name: "Mike" }],
	B: [{
		Age: 30,
		Initial: "MAS"
	},{
		Age: 20,
		Initial: "SAM"
	}]
}, ["A", "B"]);

Configuration

fixy.parse({map, options}, fixed-format-string)
map

A map [array of objects] of the column names, width, starting point, type of value, extra type settings.

  • Integer
    • type : "int"
    • name (Required) | Name of the Column
    • width (Required) | Length of Column
    • start (Required) | Start of Column in Row
    • level (Required if Multi Level) | Level Map Name
  • Float
    • type : "float" (decimal use allowed but not required)
    • name (Required) | Name of the Column
    • width (Required) | Length of Column
    • start (Required) | Start of Column in Row
    • percision (Optional) | Float Percision Value (Ex: 9.20 is 2) | DEFAULT TO 2 DECIMAL PLACES
    • sybmol (Optional) | Symbol Value (Ex: $9.20) | ONLY AVAILABLE FOR FORMAT = CSV
    • level (Required if Multi Level) | Level Map Name
  • Date
    • type : "date"
    • name (Required) | Name of the Column
    • width (Required) | Length of Column
    • start (Required) | Start of Column in Row
    • inputformat (Required) | Format Date Date is Currently In
    • outputformat (Required) | Format Date Date is Returned As
    • level (Required if Multi Level) | Level Map Name
  • String
    • type : "string"
    • name (Required) | Name of the Column
    • width (Required) | Length of Column
    • start (Required) | Start of Column in Row
    • level (Required if Multi Level) | Level Map Name
  • Boolean
    • type : "bool"
    • name (Required) | Name of the Column
    • width (Required) | Length of Column
    • start (Required) | Start of Column in Row
    • tVal (Required) | String Value of True
    • fVal (Required) | String Value of False
    • level (Required if Multi Level) | Level Map Name
options (for single level)
  • fullwidth = full length of rows from start to end
  • skiplines = optional array of rows to be skipped. May be left null
  • format = defaults "json". Valid selections are: json, csv
options (for multi level)
  • skiplines = optional array of rows to be skipped. May be left null

  • levels = level map object (see example)

    "LEVELNAME": { nickname: "NameInMap", start: 0, //row start, zero based end: 0, //row end, zero based fullwidth: 7 // row width per level }

fixy.unparse(map, array of objects || object with levels [see example], [array level order (required for multi)])
map

A map [array of objects] of the column names, width, starting point, type of value, extra type settings.

  • name (Required) | Name of the Key
  • width (Required) | Length of Fixed Section
  • padding_position (Optional. Default: "start") | Where padding should start ("start" or "end")
  • padding_symbol (Optional. Default: space " ") | What empty space should be padded with (any symbol, letter or number)
  • level (Required if Multi Level) | Level Map Name
example object with level mapping
{
	A: [{ Name: "Mike" }],
	B: [{
		Age: 30,
		Initial: "MSP"
	}]
}