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

imb

v1.0.3

Published

Simple encoder and decoder for the United States Postal Service (USPS) Intelligent Mail Barcode (IMB) service.

Downloads

41

Readme

IMB

License: CC0-1.0 Version Repo Size

Maintainability Open Source Love

Simple encoder and decoder for the USPS' IMB service based on:

In that spirit, I've included their comment below:

USPS "Intelligent Mail Barcode" Decoder

You may use this code for any purpose, with no restrictions. However, there is NO WARRANTY for this code; use it at your own risk. This work is released under the Creative Commons Zero License. To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0/

This is a simple and small module (6kb) designed to easily transform an IMB ready object to an IMB String and back again. It supports both synchronous and asynchronous (callback) implementations.

Encoding

Synchronous

const imb = require('imb');

const imb_string = imb.encode({
  delivery_pt:    "",
  zip:            "",
  plus4:          "",
  barcode_id:     "12",
  service_type:   "234",
  mailer_id:      "567094",
  serial_num:     "987654321"
});

// Result
// ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT

Asynchronous

const imb = require('imb');

imb.encode({
  delivery_pt:    "",
  zip:            "",
  plus4:          "",
  barcode_id:     "12",
  service_type:   "234",
  mailer_id:      "567094",
  serial_num:     "987654321"
}, (err, imb_string) => {
    if (err)
        throw new Error(err);
    
    // imb_string
    // ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT
});

Decoding

Synchronous

const imb = require('imb');

const imb_object = imb.decode("ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT");

// imb_object
// { 
//      barcode_id: '12',
//      service_type: '234',
//      mailer_id: '567094',
//      serial_num: '987654321' 
//  }

Asynchronous

const imb = require('imb');

imb.decode("ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT", (err, imb_object) => {
    if (err)
        throw new Error(err);
    
    // imb_object
    // { 
    //      barcode_id: '12',
    //      service_type: '234',
    //      mailer_id: '567094',
    //      serial_num: '987654321' 
    //  }
});

CLI

I have included a basic CLI that should help easily encode or decode single records.

| Option | Descriptive | Abbreviated | Meaning | |---------------|---------------|:-------------:| ------------------------------------------------------| | Type | --type | -t | "encode" or "decode" | | Barcode | --barcode | -b | Automatically set type to 'decode' and decode value |

You should be able to encode an object using:

$ imb
? Would you like to encode or decode an IMB? (Use arrow keys)
    encode
  ❯ decode
? Delivery Point 2-Characters (Optional):
? Zip (Optional):
? Zip Plus 4 (Optional):
? Barcode ID: 12
? Service Type: 234
? USPS Mailer ID: 567094
? USPS Serial Number: 987654321

Encoded output
     ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT

And decoding an object is even easier:

$ imb
? Would you like to encode or decode an IMB? (Use arrow keys)
    encode
  ❯ decode
? Barcode String: ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT

Decoded output
     barcode_id:     12
     service_type:   234
     mailer_id:      567094
     serial_num:     987654321

Alternatively, Decoding is the default behavior so you can simply run:

$ imb ATTFAATTFTADFDATDDADAATTTTTTTTADFFFFFDFAFATTDAADATDDDTADAFFDFDTFT

Decoded output
	barcode_id:	12
	service_type:	234
	mailer_id:	567094
	serial_num:	987654321

Support

Hey,

I hope that you were able to find this module helpful. If so, let me know! Who doesn't love hearing that they made a difference, even if it's a little one. Don't worry, it's totally free - but if it really made a difference, you can send a little love using the link below :beers:!

Cheers!

Beerpay Beerpay