smpte-timecode
Advanced tools
Comparing version
{ | ||
"name": "smpte-timecode", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "JavaScript implementation of SMPTE timecode type", | ||
@@ -5,0 +5,0 @@ "main": "smpte-timecode.js", |
@@ -38,7 +38,6 @@ # smpte-timecode | ||
- `frameRate`: number or array, optional | ||
if a non-integer number is passed that is near 24, 30 or 60, (i.e. 23.97 or 29.97 for example) the | ||
fractional 24000/1001, 30000/1001 or 60000/1001 rates will be assumed. If an array is passed, the | ||
framerate is assumed to be a natural fraction, with first element the numerator and second the denominator (for example, [60000,10001]). | ||
The framerate of 30000/1001 (29.97) is assumed if the parameter is omitted. | ||
- `frameRate`: number (frames per second) or Array ([numerator,denominator]), optional | ||
- if a non-integer number is passed that is near 24, 30 or 60, (i.e. 23.97 or 29.97 for example) the fractional 24000/1001, 30000/1001 or 60000/1001 rates will be assumed. | ||
- If an array is passed, the framerate is assumed to be a natural fraction, with first element the numerator and second the denominator (for example, [60000,10001]). | ||
- 30000/1001 (29.97) is assumed if the parameter is omitted. | ||
@@ -55,3 +54,3 @@ - `dropFrame`: boolean, optional | ||
var eightHundredFrames = new Timecode(800,29.97,true); | ||
var nineHundredFrames = new (Timecode(900,[60000,1001]),true); | ||
var nineHundredFrames = new Timecode(900,[60000,1001],true); | ||
var wallClock = new Timecode(new Date()); | ||
@@ -93,5 +92,5 @@ ``` | ||
## Running Tests | ||
To run tests, make sure you install `expect.js`, `mocha`, `codecov` and `istanbul` NPMs **locally**. | ||
To run tests, make sure you run | ||
npm install expect.js mocha istanbul codecov | ||
npm ci | ||
@@ -101,2 +100,3 @@ The tests can be run in Node using: | ||
npm test | ||
npm run coverage | ||
@@ -107,3 +107,5 @@ To run the tests in a browser environment, open the `test/smpte-timecode-test.html` file | ||
## Update History | ||
- 1.3 | ||
- 1.3.2 | ||
- fixed to browser-based tests, documentation. | ||
- 1.3.1 | ||
- Coverage tests changed to nyc | ||
@@ -110,0 +112,0 @@ - Support for fractional framerates and framerates above 60fps |
@@ -1,3 +0,1 @@ | ||
var sinon = require('sinon'); | ||
const isEqual = require('lodash.isequal'); | ||
@@ -7,4 +5,10 @@ // If we are running under Node, we need to add expect and load our module | ||
global.expect = require('expect.js'); | ||
global.isEqual = require('lodash.isequal'); | ||
global.Timecode = require('../smpte-timecode.js'); | ||
global.sinon = require('sinon'); | ||
var runInBrowser = false; | ||
} | ||
else { | ||
var runInBrowser = true; | ||
} | ||
@@ -225,48 +229,52 @@ describe('Constructor tests', function(){ | ||
describe('DST handling', function() { | ||
var clock; | ||
var clock; | ||
function clearDate(d) { | ||
d.setYear(0); | ||
d.setMonth(0); | ||
d.setDate(1); | ||
} | ||
function clearDate(d) { | ||
d.setYear(0); | ||
d.setMonth(0); | ||
d.setDate(1); | ||
} | ||
function checkDst(d) { | ||
// we need to fake out 'new Date()', since this issue only happens day of. | ||
clock = sinon.useFakeTimers(d); | ||
var t = new Timecode(d, 29.97, true); | ||
var o = t.toDate(); | ||
// console.log(d.toString(), '->', o.toString()); | ||
clearDate(d); | ||
clearDate(o); | ||
expect(o.toString()).to.be(d.toString()); | ||
} | ||
afterEach(function() { | ||
if (!runInBrowser) clock.restore(); | ||
}); | ||
it ('handles DST start 1am', function() { | ||
if (runInBrowser) this.skip(); | ||
checkDst(new Date(2018,2,11,1,0,0,200)); | ||
checkDst(new Date(2018,2,11,1,59,59,200)); | ||
}); | ||
it ('handles DST start 2am', function() { | ||
if (runInBrowser) this.skip(); | ||
checkDst(new Date(2018,2,11,2,0,0,200)); | ||
checkDst(new Date(2018,2,11,2,59,59,200)); | ||
checkDst(new Date(2018,2,11,3,0,0,200)); | ||
}); | ||
it ('handles DST end 1am', function() { | ||
if (runInBrowser) this.skip(); | ||
checkDst(new Date(2018,10,4,1,0,0,200)); | ||
checkDst(new Date(2018,10,4,1,59,59,200)); | ||
}); | ||
it ('handles DST end 2am', function() { | ||
if (runInBrowser) this.skip(); | ||
checkDst(new Date(2018,10,4,2,0,0,200)); | ||
checkDst(new Date(2018,10,4,2,59,59,200)); | ||
checkDst(new Date(2018,10,4,3,0,0,200)); | ||
}); | ||
function checkDst(d) { | ||
// we need to fake out 'new Date()', since this issue only happens day of. | ||
clock = sinon.useFakeTimers(d); | ||
var t = new Timecode(d, 29.97, true); | ||
var o = t.toDate(); | ||
// console.log(d.toString(), '->', o.toString()); | ||
clearDate(d); | ||
clearDate(o); | ||
expect(o.toString()).to.be(d.toString()); | ||
} | ||
afterEach(function() { | ||
clock.restore(); | ||
}); | ||
it ('handles DST start 1am', function() { | ||
checkDst(new Date(2018,2,11,1,0,0,200)); | ||
checkDst(new Date(2018,2,11,1,59,59,200)); | ||
}); | ||
it ('handles DST start 2am', function() { | ||
checkDst(new Date(2018,2,11,2,0,0,200)); | ||
checkDst(new Date(2018,2,11,2,59,59,200)); | ||
checkDst(new Date(2018,2,11,3,0,0,200)); | ||
}); | ||
it ('handles DST end 1am', function() { | ||
checkDst(new Date(2018,10,4,1,0,0,200)); | ||
checkDst(new Date(2018,10,4,1,59,59,200)); | ||
}); | ||
it ('handles DST end 2am', function() { | ||
checkDst(new Date(2018,10,4,2,0,0,200)); | ||
checkDst(new Date(2018,10,4,2,59,59,200)); | ||
checkDst(new Date(2018,10,4,3,0,0,200)); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
31748
1.84%484
1.68%130
1.56%