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

date-duration

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-duration - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.eslintrc.json

56

dist/duration.js

@@ -9,3 +9,3 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -18,4 +18,4 @@ exports.default = createDuration;

return parseInt(value || '0', 10);
},
clone = function clone(value) {
};
var clone = function clone(value) {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.toDate === 'function') {

@@ -26,26 +26,21 @@ return value.toDate();

return new Date(+value);
},
parser = /P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?/,
dateMethods = new Map([['year', 'FullYear'], ['month', 'Month'], ['week', 'Date'], ['day', 'Date'], ['hour', 'UTCHours'], ['minute', 'UTCMinutes'], ['second', 'UTCSeconds']]);
};
var parser = /P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?/;
var dateMethods = new Map([['year', 'FullYear'], ['month', 'Month'], ['week', 'Date'], ['day', 'Date'], ['hour', 'UTCHours'], ['minute', 'UTCMinutes'], ['second', 'UTCSeconds']]);
function createDuration(iso) {
var _iso$match = iso.match(parser);
var _iso$match = iso.match(parser),
_iso$match2 = _toArray(_iso$match),
parts = _iso$match2.slice(1);
var _iso$match2 = _toArray(_iso$match);
var _parts$map = parts.map(toInt),
_parts$map2 = _slicedToArray(_parts$map, 7),
year = _parts$map2[0],
month = _parts$map2[1],
week = _parts$map2[2],
day = _parts$map2[3],
hour = _parts$map2[4],
minute = _parts$map2[5],
second = _parts$map2[6];
var parts = _iso$match2.slice(1);
var _parts$map = parts.map(toInt);
var _parts$map2 = _slicedToArray(_parts$map, 7);
var year = _parts$map2[0];
var month = _parts$map2[1];
var week = _parts$map2[2];
var day = _parts$map2[3];
var hour = _parts$map2[4];
var minute = _parts$map2[5];
var second = _parts$map2[6];
if (week) {

@@ -61,3 +56,2 @@ week = week * 7;

},
addTo: function addTo(date) {

@@ -72,7 +66,6 @@ var d = clone(date);

for (var _iterator = dateMethods[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = _slicedToArray(_step.value, 2);
var _step$value = _slicedToArray(_step.value, 2),
key = _step$value[0],
method = _step$value[1];
var key = _step$value[0];
var method = _step$value[1];
if (parts[key]) {

@@ -108,7 +101,6 @@ d['set' + method](d['get' + method]() + parts[key]);

for (var _iterator2 = dateMethods[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _step2$value = _slicedToArray(_step2.value, 2);
var _step2$value = _slicedToArray(_step2.value, 2),
key = _step2$value[0],
method = _step2$value[1];
var key = _step2$value[0];
var method = _step2$value[1];
if (parts[key]) {

@@ -115,0 +107,0 @@ d['set' + method](d['get' + method]() - parts[key]);

{
"name": "date-duration",
"version": "1.0.0",
"version": "1.0.1",
"description": "Manipulate Date objects with ISO 8601-formatted durations",

@@ -9,8 +9,9 @@ "main": "dist/duration.js",

"build": "babel --source-maps -d dist/ src/",
"mocha": "TZ=Europe/Brussels mocha --compilers js:babel-register test && TZ=America/New_York mocha --compilers js:babel-register test",
"test": "npm run lint && npm run build && npm run mocha",
"test-timezone1": "TZ=Europe/Brussels mocha --compilers js:babel-register test",
"test-timezone2": "TZ=America/New_York mocha --compilers js:babel-register test",
"test": "npm run lint && npm run build && npm run test-timezone1 && npm run test-timezone2",
"clean": "rm -rf dist",
"preversion": "npm run test",
"postversion": "git push && git push --tags",
"prepublish": "npm run test",
"prepublishOnly": "npm run test",
"postpublish": "npm run clean"

@@ -38,8 +39,11 @@ },

"devDependencies": {
"babel-cli": "6.10.1",
"babel-preset-es2015": "6.9.0",
"babel-register": "6.9.0",
"eslint": "3.0.1",
"mocha": "2.5.3"
"babel-cli": "6.18.0",
"babel-preset-es2015": "6.18.0",
"babel-register": "6.18.0",
"eslint": "3.13.1",
"eslint-config-standard": "6.2.1",
"eslint-plugin-promise": "3.4.0",
"eslint-plugin-standard": "2.0.1",
"mocha": "3.2.0"
}
}

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