Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

annotate

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

annotate - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

.travis.yml

11

lib/annotate.js

@@ -27,5 +27,5 @@ (function(root, factory) {

if(typeof exports === 'object') {
module.exports = factory(require('is-js'), nodeColors);
module.exports = factory(require('annois'), nodeColors);
} else if(typeof define === 'function' && define.amd) {
define(['is-js'], function(is) {
define(['annois'], function(is) {
return (root.annotate = factory(is, browserColors));

@@ -90,3 +90,3 @@ });

var args = Array.prototype.slice.call(arguments);
var i, j, n, len1, len2, precondition, pre, allMatched, ret, failedPre;
var i, j, n, len1, len2, precondition, pre, allMatched, failedPre;

@@ -133,3 +133,5 @@ n = name || '<undefined>';

if(!postconditions.length) return res;
if(!postconditions.length) {
return res;
}

@@ -160,1 +162,2 @@ for(i = 0, len = postconditions.length; i < len; i++) {

}));
#!/usr/bin/env node
var suite = require('suite.js');
var is = require('is-js');
var is = require('annois');
var partial = require('funkit').partial;

@@ -77,3 +77,3 @@ var annotate = require('./annotate');

suite(clamp, function(op, a, min, max) {
var res = op(a, min, max);
op(a, min, max);

@@ -92,3 +92,3 @@ return min <= a && a <= max;

var failClamp = annotate('failClamp', 'Clamps given number between given bounds. Supposed to fail')
.on(is.number, is.number, is.number, function(a, min, max) {
.on(is.number, is.number, is.number, function(a, min) {
return Math.max(a, min);

@@ -95,0 +95,0 @@ })

@@ -5,5 +5,5 @@ {

"author": "Juho Vepsalainen <bebraw@gmail.com>",
"version": "0.7.0",
"version": "0.8.0",
"dependencies": {
"is-js": "== 0.1.1"
"annois": "~0.3.0"
},

@@ -39,2 +39,2 @@ "devDependencies": {

]
}
}

@@ -0,1 +1,2 @@

[![build status](https://secure.travis-ci.org/annojs/annotate)](http://travis-ci.org/annojs/annotate)
# annotate - Annotate your JavaScript function definitions

@@ -7,3 +8,3 @@

This metadata can be used by tools such as [suite.js](https://github.com/bebraw/suite.js)
This metadata can be used by tools such as [annofuzz](https://github.com/annojs/fuzz)
in order to generate tests. In addition you can access the metadata via REPL.

@@ -19,17 +20,17 @@

// type checkers from is-js (https://npmjs.org/package/is-js)
var addNumbers = annotate('addNumbers', 'Adds numbers')
.on(is.number, is.number, add);
var addStrings = annotate('addStrings', 'Adds strings')
.on(is.string, is.string, add);
// type checkers from annois (https://npmjs.org/package/annois)
var addNumbers = annotate('addNumbers', 'Adds numbers').
on(is.number, is.number, add);
var addStrings = annotate('addStrings', 'Adds strings').
on(is.string, is.string, add);
// you can assert invariants too
var addPositive = annotate('addPositive', 'Adds positive')
.on(isPositive, isPositive, add)
.satisfies(isPositive); // postcondition
var addPositive = annotate('addPositive', 'Adds positive').
on(isPositive, isPositive, add).
satisfies(isPositive); // postcondition
// it is possible to chain guards
var fib = annotate('fib', 'Calculates Fibonacci numbers')
.on(0, 0).on(1, 1)
.on(is.number, function(n) {
var fib = annotate('fib', 'Calculates Fibonacci numbers').
on(0, 0).on(1, 1).
on(is.number, function(n) {
return fib(n - 1) + fib(n - 2);

@@ -39,4 +40,4 @@ });

// invariants may depend on each other
var clamp = annotate('clamp', 'Clamps given number between given bounds')
.on(is.number, is.number, function(a, args) {
var clamp = annotate('clamp', 'Clamps given number between given bounds').
on(is.number, is.number, function(a, args) {
return is.number(a) && args[1] <= a;

@@ -48,4 +49,4 @@ }, function(a, min, max) {

// furthermore it is possible to pass a variable amount of args
var min = annotate('min', 'Returns minimum of the given numbers')
.on([is.number], Math.min);
var min = annotate('min', 'Returns minimum of the given numbers').
on([is.number], Math.min);

@@ -52,0 +53,0 @@ function isPositive(a) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc