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

final

v0.2.0

Published

A set of tools for writing JavaScript code once that runs on the command line, browser, and more.

Downloads

101

Readme

Final

npm version Build Status Dependency Status Code Climate Test Coverage js-standard-style

A set of tools for writing JavaScript code once that runs on the command line, browser, and more.

Project Status

Final is in early (pre-1.0) development. It is usable, but its API may change frequently until it reaches 1.0. Additionally, several core features (and runners) have not been implemented yet.

Examples

The examples below can be run in a Node.js script or shell.

Getting Started

First, create an instance of Command with a function implementing the Command's core. Skip to the Usage section for more information about how to write Commands.

var adder = new final.Command(options => {
  var first = parseInt(options.first, 10)
  var second = parseInt(options.second, 10)

  return first + second
})

This Command exposes a run() method which wraps the given core with some extra type conversion and validation. This is the recommended way of running Commands. Note that your core function should treat all options as Strings, since all inputs and outputs are converted to and from Strings by the run() method.

var result = adder.run({ first: 1, second: 2 }) // this returns a String
console.log(result)

API Runner

Final can generate callbacks for Node's http.Server class, allowing you to wrap Commands in web APIs. You can also embed Commands in larger Node web apps.

new final.API(adder).run()

Here, Final starts a web API at localhost:3000 that wraps your Command. You can call it with HTTP requests like GET localhost:3000?first=1&second=2, and you will get a plain text response with the result.

CLI Runner

Final can create command line interfaces around your Command.

new final.CLI(adder).run()

Final will read arguments from the shell command running this JavaScript code, and then it will immediately run the Command with the given options and print the result to STDOUT. For example, try putting this in add.js and running node add --first 1 --second 2 in the same directory.

Installation

  1. Install Node.js (version 4 or higher)
  2. npm install --save final
  3. var final = require ('final')

License

ISC (it's similar to MIT, but simpler)