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

agree

v0.0.8

Published

Introspectable contracts programming for JavaScript

Downloads

8

Readme

Build Status

Agree: Contract programming for JavaScript

Agree is a library for implementing Contract Programming / Design by contract in JavaScript, including preconditions, postconditions and class invariants.

It is inspired by projects like contracts.coffee, but requires no build steps, no non-standard language features, and is introspectable.

Status

Experimental as of November 2016.

  • Functions, method and class invariants work
  • Support for asyncronous functions using Promise (ES6/A+ compatible)
  • Contracts can be reusable, and used to define interfaces (having multiple implementations)
  • Some proof-of-concept documentation and testing tools exists
  • Library has not been used in any real applications yet

TODO 0.1 "minimally useful"

  • Lock down the core contracts API
  • Add more tests for core functionality
  • Do use-case exploration of a browser/frontend example
  • Remove CoffeeScript as run-time dependency
  • Setup build automated tests for browser
  • Stabilize and document the testing and documentation tools

Future

  • Add support for more types of invariants, including on properties

For details see TODO/FIXME/XXX/MAYBE comments in the code.

Installing

Add Agree to your project using NPM

npm install --save agree
npm install --save-dev agree-tools

License

MIT, see LICENSE.md

Examples

HTTP server

See the tests under ./spec/ for full reference.

Tools

agree-tools uses the introspection features of Agree to provide support for testing and documentation, driven by the contracts/code.

Goals

  • No special dependencies, works anywhere (browser, node.js, etc), usable as library
  • That contracts are used is completely transparent to consuming code
  • Can start using contracts stepwise, starting with just some functions/methods
  • JavaScript-friendly fluent API (even if written with CoffeeScript)
  • Preconditions can, and are encouraged to, be used for input validation

Usecases

  • HTTP REST apis: specifying behavior, validating request, consistent error handling
  • NoFlo components: verifying data on inports, specifying component behavior
  • Interfaces: multiple implementations of same interface fully described

Introspection

Functions, classes and instances built with Agree know their associated contracts. This allows to query the code about its properties, to generate documentation, test-cases and aid in debugging of failures.

Agree is partially related other work by author on introspectable programming, including Finito (finite state machines) and NoFlo/MicroFlo (dataflow).