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

comparable-storable-types

v1.0.0

Published

read, write, and compare binary types

Downloads

107

Readme

comparable-storable-types

read, write, and compare binary types

Use this module if you want uniform access for reading, writing, comparison, sizes, and minimum/maximum values for a bunch of different machine types.

This module was built specifically for implementing a range of types for spatial trees on disk.

example

write

var type = require('comparable-storable-types')
var f = type('uint16')
var buf = new Buffer(2)
f.write(buf, 5555, 0)
console.log(buf.toString('hex'))

read

var type = require('comparable-storable-types')
var f = type('float32')
var x = f.read(Buffer([ 0x40, 0x49, 0x0f, 0xdb ]), 0)
console.log(x)

cmp

var type = require('comparable-storable-types')
var B = type('buffer[3]')
var bufs = [ 'zzz', 'qrs', '123', '100' ].map(Buffer)
bufs.sort(function (a, b) { return B.cmp.lt(a, b) ? -1 : 1 })
console.log(bufs.map(String))

api

var types = require('comparable-storable-types')

var t = types(str)

Look up a type object t by a description string str.

Types are:

  • float, float32, f, f32
  • double, float64, d, f64
  • uint8, ui8, u8
  • uint16, ui16, u16
  • uint32, ui32, u32
  • sint8, int8, si8, i8, s8
  • sint16, int16, si16, i16, s16
  • sint32, int32, si32, i32, s32

var value = t.read(buf, offset)

Parse the value for the type at offset in buf.

t.write(buf, value, offset)

Write value into buf at offset.

t.size

Size in bytes of the type

t.min

Minimum value for the type

t.max

Maximum value for the type

t.cmp

Comparison operators:

  • t.cmp.eq(a, b)
  • t.cmp.lt(a, b)
  • t.cmp.lte(a, b)
  • t.cmp.gt(a, b)
  • t.cmp.gte(a, b)

install

npm install comparable-storable-types

license

BSD