Socket
Socket
Sign inDemoInstall

abstract-scheduler

Package Overview
Dependencies
95
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 2.0.0

license.md

134

index.js

@@ -1,8 +0,130 @@

const middleware = require('./src/middleware');
const api = require('./src/api');
'use strict'
module.exports = {
middleware,
api,
};
const test = require('tape')
const isObj = o => 'object' === typeof o && o !== null && !Array.isArray(o)
const testScheduler = (createScheduler) => {
test('createScheduler', (t) => {
t.plan(4)
t.equal(typeof createScheduler, 'function', 'createScheduler should be a function')
t.equal(createScheduler.length, 1, 'createScheduler.length should be 1')
const scheduler1 = createScheduler()
t.ok(isObj(scheduler1), 'createScheduler() should return an object')
const scheduler2 = createScheduler([])
t.ok(isObj(scheduler2), 'createScheduler([]) should return an object')
})
test('scheduler.add', (t) => {
const scheduler = createScheduler([])
t.plan(3)
t.equal(typeof scheduler.add, 'function', 'scheduler.add should be a function')
t.equal(scheduler.add.length, 1, 'scheduler.add.length should be 1')
t.doesNotThrow(() => {
scheduler.add('foo')
}, `scheduler.add('foo') should work`)
})
test('scheduler.remove', (t) => {
const scheduler = createScheduler([])
scheduler.add('foo')
t.plan(5)
t.equal(typeof scheduler.remove, 'function', 'scheduler.remove should be a function')
t.equal(scheduler.remove.length, 1, 'scheduler.remove.length should be 1')
let res1
t.doesNotThrow(() => {
res1 = scheduler.remove('foo')
}, `scheduler.remove('foo') should work`)
t.equal(res1, true, 'scheduler.remove should return true for a known item')
const res2 = scheduler.remove('bar')
t.equal(res2, false, 'scheduler.remove should return false for an unknown item')
})
test('scheduler.has', (t) => {
const scheduler = createScheduler([])
t.plan(4)
t.equal(typeof scheduler.has, 'function', 'scheduler.has should be a function')
t.equal(scheduler.has.length, 1, 'scheduler.has.length should be 1')
scheduler.add('foo')
const res1 = scheduler.has('foo')
t.equal(res1, true, 'scheduler.has should return true for a known item')
const res2 = scheduler.has('bar')
t.equal(res2, false, 'scheduler.has should return fals for an unknown item')
})
test('scheduler.get', (t) => {
const scheduler = createScheduler([])
const items = ['foo', 'bar', 'baz']
for (let item of items) scheduler.add(item)
t.plan(2 + 1000)
t.equal(typeof scheduler.get, 'function', 'scheduler.get should be a function')
t.equal(scheduler.get.length, 0, 'scheduler.get.length should be 0')
for (let i = 0; i < 1000; i++) {
const msg = `scheduler.get() call #${i} should return a known value`
const item = scheduler.get()
t.ok(items.includes(item), msg)
}
})
test('supports initial values', (t) => {
const scheduler = createScheduler(['foo', 'bar', 'baz'])
t.plan(4)
const hasFoo = scheduler.has('foo')
t.equal(hasFoo, true, `initial value 'foo' unknown`)
const hasBar = scheduler.has('bar')
t.equal(hasBar, true, `initial value 'bar' unknown`)
const hasBaz = scheduler.has('baz')
t.equal(hasBaz, true, `initial value 'baz' unknown`)
scheduler.add('qux')
const hasFoo2 = scheduler.has('foo')
t.equal(hasFoo2, true, `initial value 'foo' unknown after adding 'qux'`)
})
test('actually adds and removes', (t) => {
const scheduler = createScheduler([])
t.plan(3)
const has1 = scheduler.has('foo')
t.equal(has1, false, `'foo' should be unknown in the beginning`)
scheduler.add('foo')
const has2 = scheduler.has('foo')
t.equal(has2, true, `'foo' should be known after adding`)
scheduler.remove('foo')
const has3 = scheduler.has('foo')
t.equal(has3, false, `'foo' should be unknown after removing`)
})
test('works with objects, null and undefined', (t) => {
const scheduler = createScheduler([null])
t.plan(3)
const hasNull = scheduler.has(null)
t.equal(hasNull, true, 'null should be known')
scheduler.add(undefined)
const hasUndefined = scheduler.has(undefined)
t.equal(hasUndefined, true, 'undefined should be known')
const obj = {}
scheduler.add(obj)
const hasObj = scheduler.has(obj)
t.equal(hasObj, true, 'obj should be known')
})
}
module.exports = testScheduler

114

package.json
{
"name": "abstract-scheduler",
"version": "0.6.0",
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "npm run docs:api",
"start": "node src/server.js",
"dev": "cross-env NODE_ENV=development node src/server.js",
"docs:api": "apidoc -i src/routes -o api-doc",
"test": "NODE_ENV=development mocha --require co-mocha --ui bdd 'src/**/*.spec.js'",
"coverage:prototype": "nyc npm run test:prototype",
"commit": "git cz",
"lint": "eslint src/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rhinobuccaneers/abstract-scheduler.git"
},
"author": "oleksijfomin",
"license": "MIT",
"bugs": {
"url": ""
},
"pre-push": [
"lint",
"test",
"coverage"
],
"dependencies": {
"apidoc": "0.16.1",
"async": "2.0.1",
"aws-sdk": "2.6.3",
"bluebird": "3.4.6",
"co": "4.6.0",
"dotenv": "2.0.0",
"http-status": "0.2.3",
"joi": "9.0.4",
"joi-objectid": "2.0.0",
"koa": "2.0.0",
"koa-66": "1.0.0",
"koa-body": "1.5.0",
"koa-convert": "1.2.0",
"koa-cors": "0.0.16",
"koa-helmet": "2.0.0",
"koa-static": "2.0.0",
"levee": "1.2.1",
"lodash": "4.17.4",
"mime-kind": "2.0.0",
"mongoose": "4.7.7",
"nconf": "0.8.4",
"node-schedule": "1.2.0",
"request": "2.79.0",
"shortid": "2.2.6",
"winston": "2.2.0"
},
"devDependencies": {
"chai": "3.5.0",
"co-mocha": "1.1.3",
"commitizen": "2.8.6",
"cross-env": "2.0.1",
"cz-conventional-changelog": "1.2.0",
"eslint": "3.5.0",
"eslint-config-udosoft": "github:oleksijfomin/eslint-config-udosoft#0.1",
"istanbul": "0.4.5",
"js-image-generator": "1.0.2",
"mocha": "3.1.2",
"mocha-junit-reporter": "1.12.0",
"nock": "8.0.0",
"nodemon": "1.10.2",
"nyc": "8.3.0",
"pre-push": "0.1.1",
"sinon": "1.17.5",
"sinon-chai": "2.8.0",
"slack-shippable": "1.1.1",
"supertest": "2.0.0"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"engines": {
"node": "6.5.0",
"npm": "3.10.3"
}
"name": "abstract-scheduler",
"description": "An interface and test suite to implement various scheduling algorithms.",
"version": "2.0.0",
"main": "index.js",
"files": [
"index.js"
],
"keywords": [
"scheduling",
"scheduler",
"interface",
"spec",
"algorithm",
"test suite"
],
"author": "Jannis R <mail@jannisr.de>",
"homepage": "https://github.com/derhuerst/abstract-scheduler",
"repository": "derhuerst/abstract-scheduler",
"bugs": "https://github.com/derhuerst/abstract-scheduler/issues",
"license": "ISC",
"engines": {
"node": ">=6"
},
"dependencies": {
"tape": "^4.9.1"
},
"devDependencies": {
"square-batman": "^1.0.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc