Skip to content

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantiago committed Mar 7, 2018
1 parent 5f962e3 commit dfb6f6e
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 40 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

# [1.2.0] - 2018-03-07
### Added
- `toVttTime` and `stringifyVtt` functions #24
### Changed
- Fix broken tests #21

# [1.1.1] - 2018-02-16
### Added
- Webpack instead of Browserify.
Expand All @@ -15,21 +21,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Support for both SRT and WebVTT input strings #21

## [1.0.1] - 2017-13-10
## [1.0.1] - 2017-10-13
### Changed
- Fix parsing of 00:00:00,000 timestamp #17

## [1.0.0] - 2017-18-09
## [1.0.0] - 2017-09-18
### Changed
- Almost everything. Subtitle.js has a new API now.
- Code rewritten to ES6.
- Tests improved.

## [0.1.5] - 2017-27-02
## [0.1.5] - 2017-02-27
### Changed
- Ensure `text` is an empty string instead of `null` or `undefined`, #15

## [0.1.4] - 2017-27-02
## [0.1.4] - 2017-02-27
### Changed
- Normalize extra newlines, #44

Expand Down
161 changes: 126 additions & 35 deletions dist/subtitle.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ })
/************************************************************************/
/******/ ([
Expand Down Expand Up @@ -121,7 +121,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = toSrtTime;

var _zeroFill = __webpack_require__(4);
var _zeroFill = __webpack_require__(2);

var _zeroFill2 = _interopRequireDefault(_zeroFill);

Expand Down Expand Up @@ -152,6 +152,71 @@ function toSrtTime(timestamp) {

/***/ }),
/* 2 */
/***/ (function(module, exports) {

/**
* Given a number, return a zero-filled string.
* From http://stackoverflow.com/questions/1267283/
* @param {number} width
* @param {number} number
* @return {string}
*/
module.exports = function zeroFill (width, number, pad) {
if (number === undefined) {
return function (number, pad) {
return zeroFill(width, number, pad)
}
}
if (pad === undefined) pad = '0'
width -= number.toString().length
if (width > 0) return new Array(width + (/\./.test(number) ? 2 : 1)).join(pad) + number
return number + ''
}


/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = toVttTime;

var _zeroFill = __webpack_require__(2);

var _zeroFill2 = _interopRequireDefault(_zeroFill);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* Return the given milliseconds as WebVTT timestamp.
* @param timestamp
* @returns {string}
*/

function toVttTime(timestamp) {
if (isNaN(timestamp)) {
return timestamp;
}

var date = new Date(0, 0, 0, 0, 0, 0, timestamp);

var hours = (0, _zeroFill2.default)(2, date.getHours());
var minutes = (0, _zeroFill2.default)(2, date.getMinutes());
var seconds = (0, _zeroFill2.default)(2, date.getSeconds());
var ms = timestamp - (hours * 3600000 + minutes * 60000 + seconds * 1000);

return hours + ':' + minutes + ':' + seconds + '.' + (0, _zeroFill2.default)(3, ms);
} /**
* Module dependencies.
*/

/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -198,7 +263,7 @@ function parseTimestamps(value) {
}

/***/ }),
/* 3 */
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -226,7 +291,16 @@ Object.defineProperty(exports, 'toSrtTime', {
}
});

var _parse = __webpack_require__(5);
var _toVttTime = __webpack_require__(3);

Object.defineProperty(exports, 'toVttTime', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_toVttTime).default;
}
});

var _parse = __webpack_require__(6);

Object.defineProperty(exports, 'parse', {
enumerable: true,
Expand All @@ -235,7 +309,7 @@ Object.defineProperty(exports, 'parse', {
}
});

var _stringify = __webpack_require__(6);
var _stringify = __webpack_require__(7);

Object.defineProperty(exports, 'stringify', {
enumerable: true,
Expand All @@ -244,7 +318,16 @@ Object.defineProperty(exports, 'stringify', {
}
});

var _resync = __webpack_require__(7);
var _stringifyVtt = __webpack_require__(8);

Object.defineProperty(exports, 'stringifyVtt', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_stringifyVtt).default;
}
});

var _resync = __webpack_require__(9);

Object.defineProperty(exports, 'resync', {
enumerable: true,
Expand All @@ -253,7 +336,7 @@ Object.defineProperty(exports, 'resync', {
}
});

var _parseTimestamps = __webpack_require__(2);
var _parseTimestamps = __webpack_require__(4);

Object.defineProperty(exports, 'parseTimestamps', {
enumerable: true,
Expand All @@ -265,31 +348,7 @@ Object.defineProperty(exports, 'parseTimestamps', {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/***/ }),
/* 4 */
/***/ (function(module, exports) {

/**
* Given a number, return a zero-filled string.
* From http://stackoverflow.com/questions/1267283/
* @param {number} width
* @param {number} number
* @return {string}
*/
module.exports = function zeroFill (width, number, pad) {
if (number === undefined) {
return function (number, pad) {
return zeroFill(width, number, pad)
}
}
if (pad === undefined) pad = '0'
width -= number.toString().length
if (width > 0) return new Array(width + (/\./.test(number) ? 2 : 1)).join(pad) + number
return number + ''
}


/***/ }),
/* 5 */
/* 6 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand All @@ -300,7 +359,7 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = parse;

var _parseTimestamps = __webpack_require__(2);
var _parseTimestamps = __webpack_require__(4);

var _parseTimestamps2 = _interopRequireDefault(_parseTimestamps);

Expand Down Expand Up @@ -348,7 +407,7 @@ function parse(srtOrVtt) {
*/

/***/ }),
/* 6 */
/* 7 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -380,7 +439,39 @@ function stringify(captions) {
*/

/***/ }),
/* 7 */
/* 8 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = stringifyVtt;

var _toVttTime = __webpack_require__(3);

var _toVttTime2 = _interopRequireDefault(_toVttTime);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* Stringify the given array of captions to WebVTT format.
* @param {Array} captions
* @return {String} webVtt
*/

function stringifyVtt(captions) {
return 'WEBVTT\n\n' + captions.map(function (caption, index) {
return (index > 0 ? '\n' : '') + [index + 1, (0, _toVttTime2.default)(caption.start) + ' --> ' + (0, _toVttTime2.default)(caption.end) + (caption.settings ? ' ' + caption.settings : ''), caption.text].join('\n');
}).join('\n') + '\n';
} /**
* Module dependencies.
*/

/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "subtitle",
"version": "1.1.1",
"version": "1.2.0",
"description": "Parse and manipulate SRT (SubRip)",
"repository": {
"type": "git",
Expand Down

0 comments on commit dfb6f6e

Please sign in to comment.