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

@ichabodcole/ticker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ichabodcole/ticker - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.babelrc

36

karma.conf.js

@@ -13,18 +13,9 @@ // Karma configuration

// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'browserify', 'phantomjs-shim'],
frameworks: ['jasmine', 'phantomjs-shim', 'browserify'],
browserify: {
debug: true,
transform: ['babelify'],
configure: function(bundle) {
bundle.on('prebundle', function() {
bundle.add(__dirname + '/node_modules/babelify/polyfill')
})
}
},
// list of files / patterns to load in the browser
files: [
'lib/**/*.js',
'node_modules/babel-polyfill/dist/polyfill.js',
'src/**/*.js',
'test/**/*.spec.js'

@@ -35,4 +26,3 @@ ],

// list of files to exclude
exclude: [
],
exclude: [],

@@ -43,7 +33,6 @@

preprocessors: {
'lib/**/*.js': ['browserify'],
'test/**/*.spec.js': ['browserify']
'src/**/*.js': ['jshint', 'browserify'],
'test/**/*.spec.js': ['jshint', 'browserify']
},
// test results reporter to use

@@ -79,4 +68,15 @@ // possible values: 'dots', 'progress'

// if true, Karma captures browsers, runs the tests and exits
singleRun: false
singleRun: false,
// Custom preprocessor configuration
jshintPreprocessor: {
jshintrc: './.jshintrc'
},
browserify: {
debug: true,
transform: [['babelify', { 'presets': ['es2015'] }]]
}
});
};

@@ -0,1 +1,15 @@

'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var EventEmitter = require('events').EventEmitter;

@@ -10,67 +24,85 @@

class Ticker extends EventEmitter {
constructor(options={}) {
// Allow option to override events object if desired.
this.model = Object.assign({}, options.model || {});
// Initialize Model
this.tickInterval = null;
this.interval = options.interval || 50;
this.state = Ticker.STOPPED;
}
var Ticker = (function (_EventEmitter) {
_inherits(Ticker, _EventEmitter);
start () {
this.state = Ticker.TICKING;
this.createInterval();
this.emit(TickerEvent.START);
}
function Ticker() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
stop () {
this.state = Ticker.STOPPED;
this.destroyInterval();
this.emit(TickerEvent.STOP);
}
_classCallCheck(this, Ticker);
tick () {
this.emit(TickerEvent.TICK);
}
// Allow option to override events object if desired.
createInterval () {
this.destroyInterval();
this.tickInterval = setInterval(this.tick.bind(this), this.interval);
}
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Ticker).call(this));
destroyInterval() {
if (this.tickInterval) {
clearInterval(this.tickInterval);
this.tickInterval = null;
}
_this.model = Object.assign({}, options.model || {});
// Initialize Model
_this.tickInterval = null;
_this.interval = options.interval || 50;
_this.state = Ticker.STOPPED;
return _this;
}
set interval(milliseconds) {
this.model.interval = milliseconds;
if(this.state === Ticker.TICKING) {
_createClass(Ticker, [{
key: 'start',
value: function start() {
this.state = Ticker.TICKING;
this.createInterval();
this.emit(TickerEvent.START);
}
}
}, {
key: 'stop',
value: function stop() {
this.state = Ticker.STOPPED;
this.destroyInterval();
this.emit(TickerEvent.STOP);
}
}, {
key: 'tick',
value: function tick() {
this.emit(TickerEvent.TICK);
}
}, {
key: 'createInterval',
value: function createInterval() {
this.destroyInterval();
this.tickInterval = setInterval(this.tick.bind(this), this.interval);
}
}, {
key: 'destroyInterval',
value: function destroyInterval() {
if (this.tickInterval) {
clearInterval(this.tickInterval);
this.tickInterval = null;
}
}
}, {
key: 'interval',
set: function set(milliseconds) {
this.model.interval = milliseconds;
if (this.state === Ticker.TICKING) {
this.createInterval();
}
},
get: function get() {
return this.model.interval;
}
}, {
key: 'state',
set: function set(state) {
this.model.state = state;
},
get: function get() {
return this.model.state;
}
}]);
get interval() {
return this.model.interval;
}
return Ticker;
})(EventEmitter);
// Ticker states
set state(state) {
this.model.state = state;
}
get state() {
return this.model.state;
}
}
// Ticker states
Ticker.STOPPED = 'stopped';
Ticker.TICKING = 'ticking';
export default Ticker;
export {
TickerEvent,
Ticker
};
exports.default = Ticker;
exports.TickerEvent = TickerEvent;
exports.Ticker = Ticker;
{
"name": "@ichabodcole/ticker",
"version": "0.0.2",
"version": "0.0.3",
"author": "Cole Reed",

@@ -8,10 +8,7 @@ "description": "Fire a tick event every X milliseconds",

"main": "lib/ticker.js",
"browserify": {
"transform": [
"babelify"
]
},
"scripts": {
"start": "gulp tdd",
"test": "gulp test"
"compile": "babel src -o lib/ticker.js",
"prepublish": "npm test && npm run compile",
"start": "karma start karma.conf.js --auto-watch",
"test": "karma start karma.conf.js --single-run"
},

@@ -23,21 +20,19 @@ "keywords": [

"devDependencies": {
"babelify": "^5.0.4",
"beepbeep": "^1.2.0",
"browserify": "^9.0.4",
"gulp": "^3.8.11",
"gulp-jshint": "^1.8.4",
"gulp-load-plugins": "^0.9.0",
"babel-cli": "^6.1.18",
"babel-polyfill": "^6.1.19",
"babel-preset-es2015": "^6.1.18",
"babelify": "^7.2.0",
"jasmine-core": "^2.0.4",
"jshint-stylish": "^1.0.0",
"karma": "^0.12.31",
"karma-browserify": "^4.1.2",
"karma": "^0.13.0",
"karma-browserify": "^4.4.0",
"karma-chrome-launcher": "^0.1.7",
"karma-jasmine": "^0.3.5",
"karma-jshint-preprocessor": "0.0.6",
"karma-nyan-reporter": "0.0.60",
"karma-osx-reporter": "^0.2.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-phantomjs-shim": "^1.0.0",
"watchify": "^2.0.0"
"karma-phantomjs-shim": "^1.0.0"
},
"dependencies": {}
}

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

import { Ticker, TickerEvent } from '../lib/ticker';
import { Ticker, TickerEvent } from '../src/Ticker';

@@ -11,5 +11,7 @@

};
options = {
interval: 50
}
};
tk = new Ticker(options);

@@ -32,4 +34,4 @@ });

expect(tk.state).toBe(Ticker.STOPPED);
})
})
});
});

@@ -82,3 +84,3 @@ describe ('after calling ticker.stop', function() {

expect(tk.createInterval.calls.count()).toBe(2);
})
});

@@ -85,0 +87,0 @@ it ('should not update the setInterval period if the Ticker is not TICKING', function() {

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