Catalog npm
Back to packageRELEASE DETAILS

0.2.2

npm

@0x1eef/postman

Delivers the assets of a web page asynchronously

Published29 Mar 2025
Direct dependencies6
Transitive dependenciesNot calculated

README

Current package documentation

About

Postman is a lightweight library that can download the assets of a web page asynchronously. A classic use-case might be a progress bar that is updated as assets are downloaded.

Example

Postman

Deliver

The "deliver" method initiates the download of a parcel that includes fonts, stylesheets and scripts. Each time an item is downloaded, the progress event is dispatched. When all items have been downloaded, the parcel is ready to be inserted into the DOM. Typically document.fonts is used to append fonts, document.head is used to append styles, and document.body is used to append scripts:

import { Postman, item } from "postman";

const items = [
  item.font("Roboto Regular", "/fonts/roboto-regular.ttf"),
  item.css("/css/main.css"),
  item.script("/js/main.js")
]

const postman = Postman(...items)
postman.addEventListener("progress", (event) => {
  const { progress, parcel } = event.detail
  console.info("progress", progress)
  if (progress === 100) {
    parcel.fonts.forEach((font) => document.fonts.add(font))
    parcel.css.forEach((style) => document.head.appendChild(style))
    parcel.scripts.forEach((script) => document.body.appendChild(script))
  }
})
postman.deliver()

Error

An "error" event is dispatched when an item fails to download, and that includes any item that was fetched with a response code other than 200. The dispatched event provides access to an instance of AbortController that can be used to cancel the download of the remaining items, otherwise the download will continue:

import { Postman, item } from "postman";

const items = [
  item.font("Roboto Regular", "/fonts/roboto-regular.ttf"),
  item.css("/css/main.css"),
  item.script("/js/main.js")
]

const postman = Postman(...items)
postman.addEventListener("error", (event) => {
  const { controller } = event.detail
  controller.abort()
  console.error("error encountered, download cancelled")
})
postman.deliver()

See also

Sources

License

BSD Zero Clause
See LICENSE

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 6

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
jsdoc
Environment
{
  "local_name": "jsdoc",
  "alias": false,
  "peer_metadata": null
}
^4.0.4development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.57.0development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^16.18development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^9.1.0development
eslint-config-standard
Environment
{
  "local_name": "eslint-config-standard",
  "alias": false,
  "peer_metadata": null
}
^17.1.0development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^5.1.3development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "658aebaf069a695c3e6068bef9145972cf300ba3",
  "tarball": "https://registry.npmjs.org/@0x1eef/postman/-/postman-0.2.2.tgz",
  "fileCount": 9,
  "integrity": "sha512-8RiCIlvKY4cHR/M8Wu4ihgoxRpK4iCcAfHpMB837yRSMbbu6YK2yw3JVL4Fzt2Koseq2qzVHDhbu6KKMhzkxHw==",
  "signatures": [
    {
      "sig": "MEUCIQCi6ThWIKfYc/PuUS8bKn8eZGY/zj4U06XCS+hDdbYrkgIgB65O5FeBBEL1knxdffHEyjJch9ItUHpIZF6UErDkOrU=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 7874
}

Repository

PENDING
0x1eef/postman

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:33 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:eeaf7d408be4cf2b8215f392bf3fed74933ed3daef9e6379512fcfa13284cd6e

Other collected versions

0.4.017 May0.3.016 May0.2.329 Mar0.2.129 Mar0.2.029 Mar0.1.029 MarView all collected versions →