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

ni-data-types

v1.3.0

Published

Non-standard data types used by the webcharts team.

Downloads

250

Readme

data-types Build Status

This repository contains support for non-standard Javascript data types needed for engineering and scientific applications.

Data Types

NIType

Contains all the information needed to fully describe a NIType, as as an API to retrieve the information. It can be constructed from a JSON encoded string or a full notation object.

var booleanType = new NIType('"Boolean"'); // A single boolean.
var arrayType = new NIType({name: 'Array', rank: 1, subtype:{name: 'Boolean'}}); // 1-D array of booleans.

var arraySubtype = arrayType.getSubtype(); // An instance of NIType

console.log(arraySubtype.isBoolean()); // true
console.log(booleanType.isBoolean()); // true
console.log(booleanType.equals(arraySubtype)); // true
console.log(booleanType.equals(arrayType)); // false

For more information, you can look at the docs of NIType.

NIComplex. Complex numbers for high performance applications

Can be constructed from a string representing

  • complex numbers with real part before imaginary part or imaginary part before real part
  • complex numbers represented with scientific notation
  • complex numbers whose real and/or imaginary parts contain metric (SI) prefixes, such as kilo (k) or mega (M).
  • complex numbers with only real or imaginary part
  • complex numbers containing NaN as imaginary part, real part, or both
  • +/-infinity, +/-inf, +/-Infinity, +/-Inf
  • complex numbers that have the imaginary part represented only as +/-i or i

Can be constructed from numbers

  • first paramater value is used for the real part and the second one for the imaginary part

It throw errors for any type of invalid input

var complex = new NIComplex('1 + 2i');
var complex1 = new NIComplex(1, 2);
var complex2 = new NIComplex(1);
var wrongComplex = new NIComplex('not a number'); // will throw

Complex numbers are objects containing two IEEE754 numbers, realPart and imaginaryPart.

var complex = new NIComplex('1 + 2i');
var re = complex.realPart;
var im = complex.imaginaryPart;

NITimestamp. High precision timestamps

A NITimestamp is a data structure used to represent time with the high precision needed by scientific and engineering applications. An NITimestamp is composed by a pair of:

  • seconds, a integer number representing seconds passed since the epoch
  • fractions, an integer number between 0 and 252 - 1 representing the fractions of seconds in the timestamp. A fraction is one second divided by 252.

The main design goals of the NITimestamp is interoperability with LabVIEW Timestamp, and as a consequence:

  1. the epoch used in NITimestamps is the LabVIEW epoch (1 January 1904).
  2. the serialization format of the NITimestamp is using Int64, UInt64

Usage

var timestamp = new NITimestamp(); // the epoch
var timestamp2 = new NITimestamp('0:0'); // the epoch
var timestamp3 = new NITimestamp(new Date(Date.now())); // current time
var timestamp4 = new NITimestamp(35.27); // 35.27 seconds past the epoch
var timestamp5 = new NITimestamp(timestamp); // copy a timestamp

The NITimestamp constructor can be called with no parameters or with different types of parameters:

  1. a string in the format "123:567890" where
  • the first part is an INT64 serialized to a decimal string, representing the nr. of seconds relative to epoch
  • the second part is a UINT64 serialized to a decimal string, representing the fractional part of the seconds
  1. a javascript Date
  2. a Number, representing the seconds passed since the epoch
  3. a NITimestamp.

NIAnalogWaveform. A waveform of analog data samples

A NIAnalogWaveform represents a series of analog data samples. The main use case for it is for samples acquired periodically with a constant time interval between them.

NIColorValueConverters. Converters for several color formats

A NIColorValueConverters has static functions that allow conversion between formats like RGBA, ARGB and hexadecimal.

Usage

var integerColor = window.NIColorValueConverters.rgbaToInteger('rgb(237, 12, 140, 1)'); // Returns 4281020467

var hexColor = window.NIColorValueConverters.argbIntegerColorToRgbaHexColor(integerColor); // Returns "#ED0C8CFF"