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

bella-scheduler

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bella-scheduler - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

test/specs/builtTest.js

102

.eslintrc.json
{
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"binaryLiterals": true,
"blockBindings": true,
"defaultParams": true,
"forOf": true,
"generators": true,
"modules": true,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"octalLiterals": true,
"regexUFlag": true,
"regexYFlag": true,
"templateStrings": true,
"unicodeCodePointEscapes": true,
"jsx": true
}
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"globals": {
},
"plugins": [
],
"extends": "eslint:all",
"rules": {
"arrow-body-style": 0,
"dot-location": 0,
"global-require": 0,
"id-length": 0,
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"init-declarations": 0,
"max-len": [
"error",
{
"code": 120,
"ignoreTrailingComments": true,
"ignoreComments": true,
"ignoreUrls": true
}
],
"max-lines": 0,
"max-params": ["error", 5],
"max-statements": 0,
"newline-after-var": 0,
"newline-before-return": 0,
"newline-per-chained-call": 0,
"no-console": 0,
"no-inline-comments": 0,
"no-magic-numbers": 0,
"no-mixed-operators": 0,
"no-param-reassign": 0,
"no-plusplus": 0,
"no-prototype-builtins": 0,
"no-sync": 0,
"no-ternary": 0,
"no-underscore-dangle": 0,
"no-var": 0,
"object-curly-newline": 0,
"object-curly-spacing": 2,
"object-property-newline": 0,
"one-var": 0,
"padded-blocks": 0,
"prefer-const": 0,
"prefer-reflect": 0,
"prefer-template": 0,
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
"quote-props": [
"error", "as-needed"
],
"require-jsdoc": 0,
"space-before-function-paren": [
"error", "never"
],
"vars-on-top": 0
}
"extends": "eslint-config-ggc"
}
/**
* bella-scheduler
* v1.0.1
* built: Mon, 18 Jul 2016 07:20:39 GMT
* v1.1.0
* built: Fri, 30 Sep 2016 04:30:16 GMT
* git: https://github.com/ndaidong/bella-scheduler

@@ -9,7 +9,12 @@ * author: @ndaidong

**/
;(function(l,h){if("undefined"!==typeof module&&module.exports)module.exports=h();else{var q=window||{};q.define&&q.define.amd?q.define([],h):q.exports?q.exports=h():q[l]=h()}})("scheduler",function(){var l=new Map,h,q=function(c,f){for(var a=-1,b=0;b<c.length;b++)if(c[b]===f){a=b;break}return a},v=function(c,f){var a=c.match(/^(\d+)\s?(d|h|m|s)+$/i);if(a){var b=a,a=0,e=(new Date).getTime()-f;if(b){var n=parseInt(b[1],10),b=b[2];"s"===b?a=1E3:"m"===b?a=6E4:"h"===b?a=36E5:"d"===b&&(a=864E5);a=a*n-e}else a=
-1;return a}if(a=c.match(/^(sun|mon|tue|wed|thu|fri|sat)+\w*\s+(\d+)(:\d+)?(:\d+)?$/i)){var d=a,n="sun mon tue wed thu fri sat".split(" "),a=new Date,e=a.getDay(),e=q(n[e],n),b=d[1].toLowerCase(),l=q(b,n),h=b=n=0;d[2]&&(n=parseInt(d[2],10));d[3]&&(b=parseInt(d[3].replace(/\D/gi,""),10));d[4]&&(h=parseInt(d[4].replace(/\D/gi,""),10));a.setHours(n);a.setMinutes(b);a.setSeconds(h);var k=a.getTime(),d=(new Date).getTime(),r=a;if(l<e||d>k)a=new Date(a),a.setDate(a.getDate()+e+7-a.getDay()%7),r=a;r.setHours(n);
r.setMinutes(b);r.setSeconds(h);return r.getTime()-d}if(a=c.match(/^(\*|\d+)\s+(\*|\d+)\s+(\*|\d+)\s+(\*|\d+)\s+(\*|\d+)\s+(\d+)$/i)){var d=a,a="*"===d[1]?"*":parseInt(d[1],10),e="*"===d[2]?"*":parseInt(d[2],10),n="*"===d[3]?"*":parseInt(d[3],10),b="*"===d[4]?"*":parseInt(d[4],10),h="*"===d[5]?"*":parseInt(d[5],10),p="*"===d[6]?"*":parseInt(d[6],10),m=new Date,g=m.getFullYear();if("*"!==a&&a<g)a=-1;else{var d=a,l=e,k=n,r=b,t=h;"*"===a&&(d=g);g=m.getMonth()+1;"*"===e&&(l=g);g=m.getDate();"*"===n&&
(k=g);g=m.getHours();"*"===b&&(r=g);m=m.getMinutes();"*"===h&&(t=m);p=new Date(d,l-1,k,r,t,p);g=p.getTime();m=(new Date).getTime();g-=m;0>g&&"*"===h&&(p.setMinutes(t+1),g=p.getTime(),g-=m);0>g&&"*"===b&&(p.setHours(r+1),g=p.getTime(),g-=m);0>g&&"*"===n&&(p.setDate(k+1),g=p.getTime(),g-=m);0>g&&"*"===e&&(p.setMonth(l),g=p.getTime(),g-=m);0>g&&"*"===a&&(p.setFullYear(d+1),g=p.getTime(),g-=m);a=g}return a}return-1},w=function(c){c.fn();var f=c.id;if(!c.repeat)return l["delete"](f);var a=(new Date).getTime();
c.lastTick=a;l.set(f,c);return!0},u=function(){if(0<l.size){var c=2147483647,f=[];l.forEach(function(a){var b=a.id,e=v(a.time,a.lastTick);0>e?l["delete"](b):0===e?(a.delay=0,f.push(a)):(a.delay=e,l.set(b,a),e<=c&&(c=e,b=[],b=f.concat(a),f=b.filter(function(a){return a.delay<=c})))});h&&clearTimeout(h);f.length&&(h=setTimeout(function(){f.map(w);setTimeout(u,1)},c))}},k=function(c,f,a){a=a?0:1;var b=(new Date).getTime(),e;for(e=[];10>e.length;)e.push(Math.random().toString(36).slice(2));e=e.join("");
for(var h=e.length,d=Math.max(32,0),k="";k.length<d;)k+=e.charAt(Math.floor(Math.random()*h))||"";e=k;l.set(e,{id:e,fn:f,time:c,repeat:a,createdAt:b,lastTick:b,delay:0});u()};return{yearly:function(c,f){k("* "+c,f)},monthly:function(c,f){k("* * "+c,f)},daily:function(c,f){k("* * * "+c,f)},hourly:function(c,f){return k("* * * * "+c,f)},every:function(c,f){return k(c,f)},once:function(c,f){return k(c,f,1)}}});
;var $jscomp={scope:{},checkStringArgs:function(b,g,e){if(null==b)throw new TypeError("The 'this' value for String.prototype."+e+" must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype."+e+" must not be a regular expression");return b+""}};
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,g,e){if(e.get||e.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[g]=e.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(b,g,e,k){if(g){e=$jscomp.global;b=b.split(".");for(k=0;k<b.length-1;k++){var q=b[k];q in e||(e[q]={});e=e[q]}b=b[b.length-1];k=e[b];g=g(k);g!=k&&null!=g&&$jscomp.defineProperty(e,b,{configurable:!0,writable:!0,value:g})}};
$jscomp.polyfill("String.prototype.repeat",function(b){return b?b:function(b){var e=$jscomp.checkStringArgs(this,null,"repeat");if(0>b||1342177279<b)throw new RangeError("Invalid count value");b|=0;for(var g="";b;)if(b&1&&(g+=e),b>>>=1)e+=e;return g}},"es6-impl","es3");
(function(b,g){if("undefined"!==typeof module&&module.exports)module.exports=g();else{var e=window||{};e.define&&e.define.amd?e.define([],g):e.exports?e.exports=g():e[b]=g()}})("scheduler",function(){var b=function(a,f){if(!a||!f)return!1;var c=!0;void 0===a[f]&&(c=f in a);return c},g=function(){this.size=0;this.data={}};g.prototype.set=function(a,f){var c=this.data;b(c,a)||this.size++;c[a]=f;return this};g.prototype.get=function(a){return this.data[a]||null};g.prototype.all=function(){var a=this.data,
f=[],c;for(c in a)void 0!==a[c]&&f.push(a[c]);return f};g.prototype.delete=function(a){var f=this.data;if(!b(f,a))return!1;f[a]=null;delete f[a];this.size--;return!0};var e=new g,k,q=function(a,f){for(var c=-1,b=0;b<a.length;b++)if(a[b]===f){c=b;break}return c},t=function(a,f){var c=a.match(/^(\d+)\s?(d|h|m|s)+$/i);if(c){a=0;f=(new Date).getTime()-f;if(c){var b=parseInt(c[1],10),c=c[2];"s"===c?a=1E3:"m"===c?a=6E4:"h"===c?a=36E5:"d"===c&&(a=864E5);a=a*b-f}else a=-1;return a}if(c=a.match(/^(sun|mon|tue|wed|thu|fri|sat)+\w*\s+(\d+)(:\d+)?(:\d+)?$/i)){var d=
c,c="sun mon tue wed thu fri sat".split(" ");a=new Date;f=a.getDay();f=q(c[f],c);var b=d[1].toLowerCase(),e=q(b,c),g=b=c=0;d[2]&&(c=parseInt(d[2],10));d[3]&&(b=parseInt(d[3].replace(/\D/gi,""),10));d[4]&&(g=parseInt(d[4].replace(/\D/gi,""),10));a.setHours(c);a.setMinutes(b);a.setSeconds(g);var k=a.getTime(),d=(new Date).getTime(),p=a;if(e<f||d>k)a=new Date(a),a.setDate(a.getDate()+f+7-a.getDay()%7),p=a;p.setHours(c);p.setMinutes(b);p.setSeconds(g);return p.getTime()-d}if(c=a.match(/^(\*|\d+)\s+(\*|\d+)\s+(\*|\d+)\s+(\*|\d+)\s+(\*|\d+)\s+(\d+)$/i)){d=
c;a="*"===d[1]?"*":parseInt(d[1],10);f="*"===d[2]?"*":parseInt(d[2],10);var c="*"===d[3]?"*":parseInt(d[3],10),b="*"===d[4]?"*":parseInt(d[4],10),g="*"===d[5]?"*":parseInt(d[5],10),n="*"===d[6]?"*":parseInt(d[6],10),l=new Date,h=l.getFullYear();if("*"!==a&&a<h)a=-1;else{var d=a,e=f,k=c,p=b,m=g;"*"===a&&(d=h);h=l.getMonth()+1;"*"===f&&(e=h);h=l.getDate();"*"===c&&(k=h);h=l.getHours();"*"===b&&(p=h);l=l.getMinutes();"*"===g&&(m=l);n=new Date(d,e-1,k,p,m,n);h=n.getTime();l=(new Date).getTime();h-=l;
0>h&&"*"===g&&(n.setMinutes(m+1),h=n.getTime(),h-=l);0>h&&"*"===b&&(n.setHours(p+1),h=n.getTime(),h-=l);0>h&&"*"===c&&(n.setDate(k+1),h=n.getTime(),h-=l);0>h&&"*"===f&&(n.setMonth(e),h=n.getTime(),h-=l);0>h&&"*"===a&&(n.setFullYear(d+1),h=n.getTime(),h-=l);a=h}return a}return-1},u=function(a){a.fn();var b=a.id;if(!a.repeat)return e.delete(b);var c=(new Date).getTime();a.lastTick=c;e.set(b,a);return!0},r=function(){if(0<e.size){var a=2147483647,b=[];e.all().forEach(function(c){var f=c.id,d=t(c.time,
c.lastTick);0>d?e.delete(f):0===d?(c.delay=0,b.push(c)):(c.delay=d,e.set(f,c),d<=a&&(a=d,f=[],f=b.concat(c),b=f.filter(function(b){return b.delay<=a})))});k&&clearTimeout(k);b.length&&(k=setTimeout(function(){b.map(u);setTimeout(r,1)},a))}},m=function(a,b,c){c=c?0:1;var f=(new Date).getTime(),d;for(d=[];10>d.length;)d.push(Math.random().toString(36).slice(2));d=d.join("");for(var g=d.length,k=Math.max(32,0),m="";m.length<k;)m+=d.charAt(Math.floor(Math.random()*g))||"";d=m;e.set(d,{id:d,fn:b,time:a,
repeat:c,createdAt:f,lastTick:f,delay:0});r()};return{yearly:function(a,b){m("* "+a,b)},monthly:function(a,b){m("* * "+a,b)},daily:function(a,b){m("* * * "+a,b)},hourly:function(a,b){return m("* * * * "+a,b)},every:function(a,b){return m(a,b)},once:function(a,b){return m(a,b,1)}}});
{
"version": "1.0.1",
"version": "1.1.0",
"name": "bella-scheduler",

@@ -16,11 +16,16 @@ "description": "A useful helper for any javascript program",

"scripts": {
"test": "snyk test && tape test/start.js | tap-spec",
"coverage": "nyc tape test/start.js | tap-spec",
"report": "npm run coverage && nyc report --reporter=lcov",
"coveralls": "npm run report && cat ./coverage/lcov.info | coveralls",
"build": "gccmin src dist/scheduler.min.js",
"snyk": "snyk wizard"
"lint": "eslint .",
"snyk": "snyk test",
"tape": "nyc tape test/start.js | tap-spec",
"report": "nyc report --reporter=lcov",
"pretest": "npm run lint && npm run snyk",
"test": "npm run tape",
"posttest": "npm run report",
"coveralls": "npm test && cat ./coverage/lcov.info | coveralls",
"build": "gccmin src dist/scheduler.min.js"
},
"devDependencies": {
"coveralls": "latest",
"eslint": "latest",
"eslint-config-ggc": "latest",
"gcc-min": "latest",

@@ -41,12 +46,3 @@ "nyc": "latest",

],
"license": "MIT",
"maintainers": [
"ndaidong <ndaidong@gmail.com>"
],
"bugs": {
"url": "https://github.com/ndaidong/bella-scheduler/issues"
},
"directories": {
"test": "test"
}
"license": "MIT"
}

@@ -8,3 +8,3 @@ bella-scheduler

[![Coverage Status](https://coveralls.io/repos/github/ndaidong/bella-scheduler/badge.svg?branch=master)](https://coveralls.io/github/ndaidong/bella-scheduler?branch=master)
![devDependency Status](https://david-dm.org/ndaidong/bella-scheduler.svg)
[![Dependency Status](https://www.versioneye.com/user/projects/57e8df2abd6fa6004e122a81/badge.svg?style=flat)](https://www.versioneye.com/user/projects/57e8df2abd6fa6004e122a81)
[![Known Vulnerabilities](https://snyk.io/test/npm/bella-scheduler/badge.svg)](https://snyk.io/test/npm/bella-scheduler)

@@ -11,0 +11,0 @@

@@ -23,3 +23,61 @@ /**

var TaskList = new Map();
var isUndefined = (v) => {
return v === undefined; // eslint-disable-line no-undefined
};
var hasProperty = (ob, k) => {
if (!ob || !k) {
return false;
}
let r = true;
if (isUndefined(ob[k])) {
r = k in ob;
}
return r;
};
class BellaMap {
constructor() {
this.size = 0;
this.data = {};
}
set(k, v) {
let d = this.data;
if (!hasProperty(d, k)) {
this.size++;
}
d[k] = v;
return this;
}
get(k) {
let d = this.data;
return d[k] || null;
}
all() {
let d = this.data;
let a = [];
for (let k in d) {
if (!isUndefined(d[k])) {
a.push(d[k]);
}
}
return a;
}
delete(k) {
let d = this.data;
if (!hasProperty(d, k)) {
return false;
}
d[k] = null;
delete d[k];
this.size--;
return true;
}
}
var TaskList = new BellaMap();
var checkTimer;

@@ -268,3 +326,3 @@

let candidates = [];
TaskList.forEach((task) => {
TaskList.all().forEach((task) => {
let id = task.id;

@@ -271,0 +329,0 @@ let delay = getDelayTime(task.time, task.lastTick);

Sorry, the diff of this file is not supported yet

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