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

jour

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jour - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

939

dist/index.js

@@ -1,938 +0,1 @@

(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Jour"] = factory();
else
root["Jour"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* @module Jour
*/
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; };
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _require = __webpack_require__(2);
var DATE = _require.DATE;
var LOCALE = _require.LOCALE;
/**
* Check if given value is an object
*
* @private
* @param {*} value Value to check
* @return {bool} True if it is an Object, false otherwise
*/
var isObject = function isObject(value) {
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
};
/**
* Loosely check if given value is a Date instance
*
* @private
* @param {*} value Value to check
* @return {bool} True if it is a Date, false otherwise
*/
var isDate = function isDate(value) {
return isObject(value) && typeof value.toUTCString === 'function' && typeof value.setFullYear === 'function';
};
/**
* Create a new Jour object, either pointing on
* now or on the given Date object
*
* @param {Date} [date=now] Native Date object to wrap
* @param {Object} [options={}] Options for the jour object
* @param {string} [options.locale='default'] The Jour locale,
* or 'default' to follow the value of Jour.getDefaultLocale
* @return {Jour} A Jour object
*/
var Jour = function Jour(date, options) {
var _Object$create;
if (isObject(date) && !isDate(date)) {
// a no-op on already-wrapped dates
if (isDate(date[DATE])) {
return date;
}
// first argument is a non-Date object, treat is as options
options = date;
date = undefined;
}
if (!isDate(date)) {
// default date is now
date = new Date();
}
if (!isObject(options)) {
// default options is empty
options = {};
}
return Object.create(timePrototype, (_Object$create = {}, _defineProperty(_Object$create, DATE, {
writable: false,
enumerable: false,
configurable: false,
value: date
}), _defineProperty(_Object$create, LOCALE, {
writable: true,
enumerable: false,
configurable: false,
// the default locale is 'default' meaning it follows
// the value of Jour.getDefaultLocale
value: typeof options.locale === 'string' ? options.locale : 'default'
}), _Object$create));
};
// export the factory before importing the submodules
// for circular dependencies
module.exports = Jour;
// load the prototype from the submodules
var timePrototype = Object.assign({}, __webpack_require__(3), __webpack_require__(4), __webpack_require__(5), __webpack_require__(6), __webpack_require__(7), __webpack_require__(8));
// load the static properties
__webpack_require__(9)(Jour);
/***/ },
/* 2 */
/***/ function(module, exports) {
'use strict';
/**
* @private
* @const {Symbol} DATE Symbol for the internal Date property
* referring to the wrapped Date() object
*/
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; };
exports.DATE = Symbol('internal date');
/**
* @private
* @const {Symbol} LOCALE Symbol for the internal Locale property
*/
exports.LOCALE = Symbol('internal locale');
/**
* Normalize the given unit to its canonical form
* (without plural mark, resolving all aliases)
*
* @private
* @param {string} unit The unit to normalize
* @return {string} The unit's canonical form
*/
exports.normalizeUnit = function () {
var aliases = Object.create(null);
aliases.y = 'year';
aliases.m = 'month';
aliases.d = 'day';
aliases.date = 'day';
aliases.h = 'hour';
aliases.mn = 'minute';
aliases.min = 'minute';
aliases.s = 'second';
aliases.ms = 'millisecond';
return function (unit) {
// if not a string, report a problem
if (typeof unit !== 'string') {
var stringUnit = void 0;
if ((typeof unit === 'undefined' ? 'undefined' : _typeof(unit)) === 'object' && unit !== null) {
stringUnit = 'an object (' + JSON.stringify(unit) + ')';
} else if (unit === undefined || unit === null) {
stringUnit = String(unit);
} else {
stringUnit = 'a ' + (typeof unit === 'undefined' ? 'undefined' : _typeof(unit)) + ' (' + unit + ')';
}
throw new TypeError('Invalid unit. Units are strings, but got ' + stringUnit);
}
unit = unit.trim();
// resolve unit aliases
if (unit in aliases) {
unit = aliases[unit];
}
// remove terminating 's'
if (unit.slice(-1) === 's') {
unit = unit.slice(0, -1);
}
return unit;
};
}();
/**
* Normalize a list of locales to a single locale,
* defaulting to en-US
*
* @private
* @param {string|Array.<string>} locales One or several locales,
* the first supported one will be returned, or en-US if none is supported
* @throws {RangeError} If one of the locales is invalid
* @return {string} The first supported locale, or en-US
*/
exports.normalizeLocales = function (locales) {
locales = Array.isArray(locales) ? locales : [locales];
var supported = Intl.DateTimeFormat.supportedLocalesOf(locales);
if (supported.length === 0) {
return 'en-US';
}
return supported[0];
};
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _require = __webpack_require__(2);
var DATE = _require.DATE;
/**
* Get this instance's year. Note that this returns
* a 4-digit year just like Date#getFullYear()
*
* @memberof Jour#
* @example <caption>Get a two-digit year</caption>
* Jour().getYear().toString().slice(-2);
*
* @return {number}
*/
exports.getYear = function () {
return this[DATE].getFullYear();
};
/**
* Get this instance's month. Note that the month
* is not zero-indexed, January is 1 and December is 12
*
* @memberof Jour#
* @return {number}
*/
exports.getMonth = function () {
return this[DATE].getMonth() + 1;
};
/**
* Get this instance's day of month
*
* @memberof Jour#
* @return {number}
*/
exports.getDay = function () {
return this[DATE].getDate();
};
/**
* @memberof Jour#
* @borrows Jour#getDay as getDate
*/
exports.getDate = exports.getDay;
/**
* Get this instance's hour
*
* @memberof Jour#
* @return {number}
*/
exports.getHour = function () {
return this[DATE].getHours();
};
/**
* Get this instance's minute
*
* @memberof Jour#
* @return {number}
*/
exports.getMinute = function () {
return this[DATE].getMinutes();
};
/**
* Get this instance's second
*
* @memberof Jour#
* @return {number}
*/
exports.getSecond = function () {
return this[DATE].getSeconds();
};
/**
* Get this instance's millisecond
*
* @memberof Jour#
* @return {number}
*/
exports.getMillisecond = function () {
return this[DATE].getMilliseconds();
};
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _require = __webpack_require__(2);
var normalizeUnit = _require.normalizeUnit;
/**
* Check whether this Jour is the same as given Jour,
* comparing up to the given unit
*
* @memberof Jour#
* @example <caption>Check whether given date is on the same month</caption>
* christmasDay.isSame(newYear, 'month');
*
* @example <caption>Check whether two dates are exactly the same</caption>
* date1.isSame(date2);
* date1.valueOf() === date2.valueOf(); // equivalent
*
* @param {Jour|Date} Second date to check
* @param {string} [unit='ms'] Unit precision
* @return {bool} Result of the check (true/false)
*/
exports.isSame = function (date) {
var unit = arguments.length <= 1 || arguments[1] === undefined ? 'millisecond' : arguments[1];
return this.startOf(unit).valueOf() === date.startOf(unit).valueOf();
};
/**
* Check whether this Jour is strictly before given Jour,
* comparing up to the given unit
*
* @memberof Jour#
* @param {Jour|Date} Second date to check
* @param {string} [unit='ms'] Unit precision
* @return {bool} Result of the check (true/false)
*/
exports.isBefore = function (date) {
var unit = arguments.length <= 1 || arguments[1] === undefined ? 'millisecond' : arguments[1];
return this.startOf(unit) < date.startOf(unit);
};
/**
* Check whether this Jour is before or equal to given Jour,
* comparing up to the given unit
*
* @memberof Jour#
* @param {Jour|Date} Second date to check
* @param {string} [unit='ms'] Unit precision
* @return {bool} Result of the check (true/false)
*/
exports.isSameOrBefore = function (date) {
var unit = arguments.length <= 1 || arguments[1] === undefined ? 'millisecond' : arguments[1];
return this.startOf(unit) <= date.startOf(unit);
};
/**
* Check whether this Jour is strictly after given Jour,
* comparing up to the given unit
*
* @memberof Jour#
* @param {Jour|Date} Second date to check
* @param {string} [unit='ms'] Unit precision
* @return {bool} Result of the check (true/false)
*/
exports.isAfter = function (date) {
var unit = arguments.length <= 1 || arguments[1] === undefined ? 'millisecond' : arguments[1];
return this.startOf(unit) > date.startOf(unit);
};
/**
* Check whether this Jour is after or equal to given Jour,
* comparing up to the given unit
*
* @memberof Jour#
* @param {Jour|Date} Second date to check
* @param {string} [unit='ms'] Unit precision
* @return {bool} Result of the check (true/false)
*/
exports.isSameOrAfter = function (date) {
var unit = arguments.length <= 1 || arguments[1] === undefined ? 'millisecond' : arguments[1];
return this.startOf(unit) >= date.startOf(unit);
};
/**
* Compute the difference between this Jour and the given one
* (`this - date`) expressed in the given unit
*
* @param {Jour} date The right part of the diff
* @param {string} [unit='ms'] The unit in which to express it
*/
exports.diff = function (date) {
var unit = arguments.length <= 1 || arguments[1] === undefined ? 'millisecond' : arguments[1];
unit = normalizeUnit(unit);
// handle month-based units
if (unit === 'year' || unit === 'month') {
var leftStart = this.startOf('month').valueOf();
var leftExtent = this.endOf('month').valueOf() - leftStart;
var rightStart = date.startOf('month').valueOf();
// count the number of months between given date and this
var wholeDiff = this.getMonth() - date.getMonth() + (this.getYear() - date.getYear()) * 12;
// diff the two ms progressions in their respective months
var fracDiff = (this.valueOf() - leftStart - (date.valueOf() - rightStart)) / leftExtent;
var monthDiff = wholeDiff + fracDiff;
// for years, just divide by 12
if (unit === 'year') {
return monthDiff / 12;
}
return monthDiff;
}
// handle millisecond-based units
var diff = this.valueOf() - date.valueOf();
var numericUnit = 1;
switch (unit) {
case 'day':
numericUnit *= 24;
// fallthrough
case 'hour':
numericUnit *= 60;
// fallthrough
case 'minute':
numericUnit *= 60;
// fallthrough
case 'second':
numericUnit *= 1000;
}
return diff / numericUnit;
};
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _require = __webpack_require__(2);
var DATE = _require.DATE;
/**
* Convert this Jour instance to a native Date object
* pointing at the same instant
*
* @memberof Jour#
* @return {Date}
*/
exports.toDate = function () {
return new Date(this[DATE]);
};
// for NodeJS inspection
exports.inspect = exports.toDate;
/**
* Get the time value of this Jour instance
* (the number of milliseconds since 1 January, 1970 UTC)
*
* @memberof Jour#
* @return {Number}
*/
exports.valueOf = function () {
return this[DATE].valueOf();
};
/**
* Stringify this Jour like a native Date. Note that
* the output format cannot be controlled with this method.
* Use {@link Jour#format} for more control
*
* @memberof Jour#
* @return {string}
*/
exports.toString = function () {
return this[DATE].toString();
};
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _require = __webpack_require__(2);
var normalizeUnit = _require.normalizeUnit;
// list of options accepted by the Jour#format() method,
// after resolving aliases. Other options will be ignored
var acceptedOptions = ['timeZone', 'hour12', 'formatMatcher', 'weekday', 'era', 'year', 'month', 'day', 'hour', 'minute', 'second', 'timeZoneName'];
/**
* Format this Jour to a locale-aware string
*
* @param {Object} [options={}] Formatting options. If omitted,
* defaults to numeric year, month and day. Accepts the usual
* key aliases
* @param {string} [options.timeZone=current] The timezone in which to
* format the date
* @param {bool} [options.hour12=locale-dependent] Whether to display
* the time in 12-hour format or 24-hour
* @param {string} [options.formatMatcher='best fit'] The formatting
* algorithm to use. 'best fit' for browser-dependent and 'basic'
* for spec-dependent format
* @param {string} [options.weekday=undefined] How to display the weekday.
* Possible values are 'narrow', 'short', 'long' or undefined to hide
* the weekday
* @param {string} [options.era=undefined] How to display the era.
* Possible values are 'narrow', 'short', 'long' or undefined to hide
* the era
* @param {string} [options.year=undefined] How to display the year.
* Possible values are 'numeric', '2-digit' or undefined to hide
* the year
* @param {string} [options.month=undefined] How to display the month.
* Possible values are 'numeric', '2-digit', 'narrow', 'short', 'long'
* or undefined to hide the month
* @param {string} [options.day=undefined] How to display the day.
* Possible values are 'numeric', '2-digit' or undefined to hide
* the day
* @param {string} [options.hour=undefined] How to display the hour.
* Possible values are 'numeric', '2-digit' or undefined to hide
* the hour
* @param {string} [options.minute=undefined] How to display the minute.
* Possible values are 'numeric', '2-digit' or undefined to hide
* the minute
* @param {string} [options.second=undefined] How to display the second.
* Possible values are 'numeric', '2-digit' or undefined to hide
* the second
* @param {string} [options.timeZoneName=undefined] How to display the timezone
* Possible values are 'short', 'long' or undefined to hide
* the timezone
* @return {string} The formatted date
*/
exports.format = function () {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
options = Object.keys(options).reduce(function (map, key) {
var normal = normalizeUnit(key);
// ignore options that are not accepted
if (acceptedOptions.indexOf(normal) === -1) {
return map;
}
map[normal] = options[key];
return map;
}, {});
var formatter = new Intl.DateTimeFormat(this.getLocale(), options);
return formatter.format(this.toDate());
};
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _require = __webpack_require__(2);
var LOCALE = _require.LOCALE;
var normalizeLocales = _require.normalizeLocales;
var Jour = __webpack_require__(1);
/**
* Retrieve the current locale
*
* @memberof Jour#
* @return {string} The current locale
*/
exports.getLocale = function () {
if (this[LOCALE] === 'default') {
return Jour.getDefaultLocale();
}
return this[LOCALE];
};
/**
* Set the locale
*
* @memberof Jour#
* @param {string|Array.<string>} locales One or several locales,
* the first supported one will be applied, or en-US if none is supported
* @throws {RangeError} If one of the locales is invalid
* @return {string} The new default locale
*/
exports.setLocale = function (locales) {
if (locales === 'default') {
this[LOCALE] = locales;
} else {
this[LOCALE] = normalizeLocales(locales);
}
return this.getLocale();
};
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _require = __webpack_require__(2);
var DATE = _require.DATE;
var normalizeUnit = _require.normalizeUnit;
var Jour = __webpack_require__(1);
/**
* Make a copy of this Jour instance, shifted
* at the given units
*
* @memberof Jour#
* @example <caption>Today, at noon.</caption>
* Jour().at({hour: 12});
*
* @param {Object.<string, Number>} values Map of new values.
* Pluralized keys and aliases are accepted
* @return {Jour} A Jour shifted by the given values
*/
exports.at = function (values) {
var date = new Date(this[DATE]);
// normalize `values`'s keys
values = Object.keys(values).reduce(function (map, unit) {
map[normalizeUnit(unit)] = values[unit];
return map;
}, {});
// apply the new values to the cloned date
if ('year' in values) {
date.setFullYear(values.year);
}
if ('month' in values) {
date.setMonth(values.month - 1);
}
if ('day' in values) {
date.setDate(values.day);
}
if ('hour' in values) {
date.setHours(values.hour);
}
if ('minute' in values) {
date.setMinutes(values.minute);
}
if ('second' in values) {
date.setSeconds(values.second);
}
if ('millisecond' in values) {
date.setMilliseconds(values.millisecond);
}
return Jour(date);
};
/**
* Make a copy of this Jour instance, adding
* given units
*
* @memberof Jour#
* @example <caption>Tomorrow at the same time as now.</caption>
* Jour().add({day: 1});
*
* @param {Object.<string, Number>} values Map of values to add.
* Pluralized keys and aliases are accepted
* @return {Jour} A Jour with given values added
*/
exports.add = function (diff) {
var _this = this;
// add each unit's current value to the `values` diff,
// then apply the diff using Jour#at
return this.at(Object.keys(diff).reduce(function (map, unit) {
var norm = normalizeUnit(unit);
var accessor = 'get' + norm[0].toUpperCase() + norm.slice(1);
map[norm] = diff[unit] + _this[accessor]();
return map;
}, {}));
};
/**
* Make a copy of this Jour instance, subtracting
* given units
*
* @memberof Jour#
* @example <caption>Two hours ago.</caption>
* Jour().subtract({hours: 2});
*
* @param {Object.<string, Number>} values Map of values to subtract.
* Pluralized keys and aliases are accepted
* @return {Jour} A Jour with given values subtracted
*/
exports.subtract = function (diff) {
// Jour#subtract is just an alias to a negative Jour#add
return this.add(Object.keys(diff).reduce(function (map, unit) {
map[unit] = -diff[unit];
return map;
}, {}));
};
/**
* Make a copy if this Jour instance, positioned at
* the start of given unit
*
* @memberof Jour#
* @example <caption>Start of the current month.</caption>
* Jour().startOf('month');
*
* @param {string} unit The unit to get to the start of.
* Pluralized units and aliases are accepted
* @return {Jour} A Jour at the start of given unit
*/
exports.startOf = function (unit) {
var values = {};
unit = normalizeUnit(unit);
switch (unit) {
case 'year':
values.month = 1;
// fallthrough
case 'month':
values.day = 1;
// fallthrough
case 'day':
values.hour = 0;
// fallthrough
case 'hour':
values.minute = 0;
// fallthrough
case 'minute':
values.second = 0;
// fallthrough
case 'second':
values.millisecond = 0;
break;
case 'millisecond':
// start of millisecond is a no-op
return this;
}
return this.at(values);
};
/**
* Make a copy if this Jour instance, positioned at
* the end of given unit
*
* @memberof Jour#
* @example <caption>Count the days in current month.</caption>
* Jour().endOf('month').getDay();
*
* @param {string} unit The unit to get to the end of.
* Pluralized units and aliases are accepted
* @return {Jour} A Jour at the end of given unit
*/
exports.endOf = function (unit) {
// to go to the end, get to the start, advance one unit
// and go back one millisecond
return this.startOf(unit).add(_defineProperty({}, unit, 1)).subtract({ millisecond: 1 });
};
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _require = __webpack_require__(2);
var normalizeUnit = _require.normalizeUnit;
var normalizeLocales = _require.normalizeLocales;
module.exports = function (Jour) {
var defaultLocale = 'en-US';
/**
* Retrieve the module-wide default locale, that is applied
* on all new Jour instances unless they are manually set
*
* @memberof Jour
* @return {string} The current default locale
*/
Jour.getDefaultLocale = function () {
return defaultLocale;
};
/**
* Set the module-wide default locale
*
* @memberof Jour
* @param {string|Array.<string>} locales One or several locales,
* the first supported one will be applied, or en-US if none is supported
* @throws {RangeError} If one of the locales is invalid
* @return {string} The new default locale
*/
Jour.setDefaultLocale = function (locales) {
return defaultLocale = normalizeLocales(locales);
};
/**
* Generate a range of dates between the start and
* end dates (included)
*
* @memberof Jour
* @example <caption>Get the list of days in the month, reversed</caption>
* Jour.range(Jour().endOf('month'), Jour().startOf('month'), '-1 day');
*
* @example <caption>Get all even years in the 21st century</caption>
* Jour.range(Jour().at({year: 2000}), Jour().at({year: 2098}), '2 years');
*
* @param {Jour} Starting date of the range (included)
* @param {Jour} Ending date of the range (included)
* @param {string} [unit='1 day'] The range's step. An optional integer
* (assumed to be '1' if omitted) that may be negative or positive,
* followed by an unit
* @return {Array<Jour>} All dates in the range
*/
Jour.range = function (start, end) {
var unit = arguments.length <= 2 || arguments[2] === undefined ? '1 day' : arguments[2];
var list = [];
// normalize the unit and extract the multiplier
var multiplier = 1;
if (!isNaN(parseInt(unit, 10))) {
multiplier = parseInt(unit, 10);
unit = unit.replace(multiplier, '');
}
if (multiplier === 0) {
throw new TypeError('The multiplier cannot be zero.');
}
unit = normalizeUnit(unit);
var method = multiplier > 0 ? 'isSameOrBefore' : 'isSameOrAfter';
// move the boundaries to the start of their unit
start = start.startOf(unit);
end = end.startOf(unit);
while (start[method](end)) {
list.push(start);
start = start.add(_defineProperty({}, unit, multiplier));
}
return list;
};
};
/***/ }
/******/ ])
});
;
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Jour=t():e.Jour=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(4)},function(e,t){"use strict";var n=Symbol("internal date"),r=Symbol("internal locale");e.exports={DATE:n,LOCALE:r}},function(e,t){"use strict";var n=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,u=e[Symbol.iterator]();!(r=(o=u.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(s){i=!0,a=s}finally{try{!r&&u["return"]&&u["return"]()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r={ad:{d:1,w:4},ae:{d:6},af:{d:6},ag:{d:0},ai:{d:1},al:{d:1},am:{d:1},an:{d:1,w:4},ar:{d:0},as:{d:0},at:{d:1,w:4},au:{d:0},ax:{d:1,w:4},az:{d:1},ba:{d:1},bd:{d:5},be:{d:1,w:4},bg:{d:1,w:4},bh:{d:6},bm:{d:1},bn:{d:1},br:{d:0},bs:{d:0},bt:{d:0},bw:{d:0},by:{d:1},bz:{d:0},ca:{d:0},ch:{d:1,w:4},cl:{d:1},cm:{d:1},cn:{d:0},co:{d:0},cr:{d:1},cy:{d:1},cz:{d:1,w:4},de:{d:1,w:4},dj:{d:6},dk:{d:1,w:4},dm:{d:0},"do":{d:0},dz:{d:6},ec:{d:1},ee:{d:1,w:4},eg:{d:6},es:{d:1,w:4},et:{d:0},fi:{d:1,w:4},fj:{d:1,w:4},fo:{d:1,w:4},fr:{d:1,w:4},gb:{d:1,w:4},ge:{d:1},gf:{d:1,w:4},gg:{w:4},gi:{w:4},gp:{d:1,w:4},gr:{d:1,w:4},gt:{d:0},gu:{d:0,w:1},hk:{d:0},hn:{d:0},hr:{d:1},hu:{d:1,w:4},id:{d:0},ie:{d:0,w:4},il:{d:0},im:{w:4},"in":{d:0},iq:{d:6},ir:{d:6},is:{d:1,w:4},it:{d:1,w:4},je:{w:4},jm:{d:0},jo:{d:6},jp:{d:0},ke:{d:0},kg:{d:1},kh:{d:0},kr:{d:0},kw:{d:6},kz:{d:1},la:{d:0},lb:{d:1},li:{d:1,w:4},lk:{d:1},lt:{d:1,w:4},lu:{d:1,w:4},lv:{d:1},ly:{d:6},ma:{d:6},mc:{d:1,w:4},md:{d:1},me:{d:1},mh:{d:0},mk:{d:1},mm:{d:0},mn:{d:1},mo:{d:0},mq:{d:1,w:4},mt:{d:0},mv:{d:5},mx:{d:0},my:{d:1},mz:{d:0},ni:{d:0},nl:{d:1,w:4},no:{d:1,w:4},np:{d:0},nz:{d:0},om:{d:6},pa:{d:0},pe:{d:0},ph:{d:0},pk:{d:0},pl:{d:1,w:4},pr:{d:0},pt:{d:1,w:4},py:{d:0},qa:{d:6},re:{d:1,w:4},ro:{d:1},rs:{d:1},ru:{d:1},sa:{d:0},sd:{d:6},se:{d:1,w:4},sg:{d:0},si:{d:1},sj:{w:4},sk:{d:1,w:4},sm:{d:1,w:4},sv:{d:0},sy:{d:6},th:{d:0},tj:{d:1},tm:{d:1},tn:{d:0},tr:{d:1},tt:{d:0},tw:{d:0},ua:{d:1},um:{d:0,w:1},us:{d:0,w:1},uy:{d:1},uz:{d:1},va:{d:1,w:4},ve:{d:0},vi:{d:0,w:1},vn:{d:1},ws:{d:0},xk:{d:1},ye:{d:0},za:{d:0},zw:{d:0},"default":{d:1,w:1}},i=function(e,t){var i=e.split("-"),a=n(i,2),o=a[0],u=a[1];return o=(o||"").trim().toLowerCase(),u=(u||"").trim().toLowerCase(),u in r?r[u][t]:o in r?r[o][t]:r["default"][t]},a=function(e){return i(e,"d")},o=function(e){return i(e,"w")},u=function(e){e=Array.isArray(e)?e:[e];var t=Intl.DateTimeFormat.supportedLocalesOf(e);return 0===t.length?"en-US":t[0]};e.exports={getFirstDayOfWeek:a,getMinimalDaysInWeek:o,normalizeLocales:u}},function(e,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},r=Object.create(null);r.y="year",r.m="month",r.d="day",r.date="day",r.w="week",r.iw="isoWeek",r.doy="dayOfYear",r.dow="dayOfWeek",r.idow="isoDayOfWeek",r.h="hour",r.mn="minute",r.min="minute",r.s="second",r.ms="millisecond";var i=function(e){if("string"!=typeof e){var t=void 0;throw t="object"===("undefined"==typeof e?"undefined":n(e))&&null!==e?"an object ("+JSON.stringify(e)+")":void 0===e||null===e?String(e):"a "+("undefined"==typeof e?"undefined":n(e))+" ("+e+")",new TypeError("Invalid unit. Units are strings, but got "+t)}return e=e.trim(),e in r&&(e=r[e]),"s"===e.slice(-1)&&(e=e.slice(0,-1)),e};e.exports={normalizeUnit:i}},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=n(1),a=i.DATE,o=i.LOCALE,u=n(14),s=u.isObject,d=u.isDate,f=function(e,t){var n;if(s(e)&&!d(e)){if(d(e[a]))return e;t=e,e=void 0}return d(e)||(e=new Date),s(t)||(t={}),Object.create(c,(n={},r(n,a,{writable:!1,enumerable:!1,configurable:!1,value:e}),r(n,o,{writable:!0,enumerable:!1,configurable:!1,value:"string"==typeof t.locale?t.locale:"default"}),n))};e.exports=f;var c=Object.assign({},n(6),n(7),n(8),n(9),n(10),n(11));n(12)(f),n(13)(f)},function(e,t){"use strict";var n=function(e){return e%4===0&&(e%100!==0||e%400===0)},r=function(e,t){return(e+7-t)%7},i=function(e,t,n){return n-r(new Date(e,0,n).getDay(),t)},a=function(e,t,r){return(365+n(e)+i(e+1,t,r)-i(e,t,r))/7},o=function(e,t,n,r,o){var s=i(e,r,o),d=u(e,t,n),f=Math.floor((d-s)/7)+1;if(f<1)return f+a(e-1,r,o);var c=a(e,r,o);return f>c?f-c:f},u=function(e,t,r){if(0===t)return r;if(1===t)return r+31;var i=Number(n(e));if(2===t)return r+59+i;if(3===t)return r+90+i;if(4===t)return r+120+i;if(5===t)return r+151+i;if(6===t)return r+181+i;if(7===t)return r+212+i;if(8===t)return r+243+i;if(9===t)return r+273+i;if(10===t)return r+304+i;if(11===t)return r+334+i;throw new RangeError(t+" is not a month number")},s=function(e,t){if(t>0&&t<=31)return[0,t];var r=Number(n(e));if(t>31&&t<=59+r)return[1,t-31];if(t>59+r&&t<=90+r)return[2,t-59-r];if(t>90+r&&t<=120+r)return[3,t-90-r];if(t>120+r&&t<=151+r)return[4,t-120-r];if(t>151+r&&t<=181+r)return[5,t-151-r];if(t>181+r&&t<=212+r)return[6,t-181-r];if(t>212+r&&t<=243+r)return[7,t-212-r];if(t>243+r&&t<=273+r)return[8,t-243-r];if(t>273+r&&t<=304+r)return[9,t-273-r];if(t>304+r&&t<=334+r)return[10,t-304-r];if(t>334+r&&t<=365+r)return[11,t-334-r];throw new RangeError(t+" is not a day of the year "+e)};e.exports={testLeapYear:n,convertDayOfWeek:r,computeWeeksInYear:a,computeWeekNumber:o,computeDayOfYear:u,computeFromDayOfYear:s}},function(e,t,n){"use strict";var r=n(1),i=r.DATE,a=n(2),o=a.getFirstDayOfWeek,u=a.getMinimalDaysInWeek,s=n(5),d=s.testLeapYear,f=s.computeWeekNumber,c=s.computeWeeksInYear,l=s.computeDayOfYear,y=s.convertDayOfWeek;t.getYear=function(){return this[i].getFullYear()},t.getMonth=function(){return this[i].getMonth()+1},t.getDay=function(){return this[i].getDate()},t.getHour=function(){return this[i].getHours()},t.getMinute=function(){return this[i].getMinutes()},t.getSecond=function(){return this[i].getSeconds()},t.getMillisecond=function(){return this[i].getMilliseconds()},t.isLeapYear=function(){return d(this[i].getFullYear())},t.getWeek=function(){var e=this.getLocale();return f(this[i].getFullYear(),this[i].getMonth(),this[i].getDate(),o(e),u(e))},t.getWeeksInYear=function(){var e=this.getLocale();return c(this[i].getFullYear(),o(e),u(e))},t.getIsoWeek=function(){return f(this[i].getFullYear(),this[i].getMonth(),this[i].getDate(),1,4)},t.getIsoWeeksInYear=function(){return c(this[i].getFullYear(),1,4)},t.getDayOfWeek=function(){return y(this[i].getDay(),o(this.getLocale()))+1},t.getIsoDayOfWeek=function(){return y(this[i].getDay(),1)+1},t.getDayOfYear=function(){return l(this[i].getFullYear(),this[i].getMonth(),this[i].getDate())}},function(e,t,n){"use strict";var r=n(3),i=r.normalizeUnit;t.isSame=function(e){var t=arguments.length<=1||void 0===arguments[1]?"millisecond":arguments[1];return this.startOf(t).valueOf()===e.startOf(t).valueOf()},t.isBefore=function(e){var t=arguments.length<=1||void 0===arguments[1]?"millisecond":arguments[1];return this.startOf(t)<e.startOf(t)},t.isSameOrBefore=function(e){var t=arguments.length<=1||void 0===arguments[1]?"millisecond":arguments[1];return this.startOf(t)<=e.startOf(t)},t.isAfter=function(e){var t=arguments.length<=1||void 0===arguments[1]?"millisecond":arguments[1];return this.startOf(t)>e.startOf(t)},t.isSameOrAfter=function(e){var t=arguments.length<=1||void 0===arguments[1]?"millisecond":arguments[1];return this.startOf(t)>=e.startOf(t)},t.diff=function(e){var t=arguments.length<=1||void 0===arguments[1]?"millisecond":arguments[1];if(t=i(t),"year"===t||"month"===t){var n=this.startOf("month").valueOf(),r=this.endOf("month").valueOf()-n,a=e.startOf("month").valueOf(),o=this.getMonth()-e.getMonth()+12*(this.getYear()-e.getYear()),u=(this.valueOf()-n-(e.valueOf()-a))/r,s=o+u;return"year"===t?s/12:s}var d=this.valueOf()-e.valueOf(),f=1;switch(t){case"isoWeek":case"week":f*=7;case"isoWeekday":case"weekday":case"day":f*=24;case"hour":f*=60;case"minute":f*=60;case"second":f*=1e3}return d/f}},function(e,t,n){"use strict";var r=n(1),i=r.DATE;t.toDate=function(){return new Date(this[i])},t.inspect=t.toDate,t.valueOf=function(){return this[i].valueOf()},t.toString=function(){return this[i].toString()}},function(e,t,n){"use strict";var r=n(3),i=r.normalizeUnit,a=["timeZone","hour12","formatMatcher","weekday","era","year","month","day","hour","minute","second","timeZoneName"];t.format=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];e=Object.keys(e).reduce(function(t,n){var r=i(n);return a.indexOf(r)===-1?t:(t[r]=e[n],t)},{});var t=new Intl.DateTimeFormat(this.getLocale(),e);return t.format(this.toDate())}},function(e,t,n){"use strict";var r=n(1),i=r.LOCALE,a=n(2),o=a.normalizeLocales,u=n(4);t.getLocale=function(){return"default"===this[i]?u.getDefaultLocale():this[i]},t.setLocale=function(e){return"default"===e?this[i]=e:this[i]=o(e),this.getLocale()}},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,u=e[Symbol.iterator]();!(r=(o=u.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(s){i=!0,a=s}finally{try{!r&&u["return"]&&u["return"]()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=n(1),o=a.DATE,u=n(2),s=u.getFirstDayOfWeek,d=u.getMinimalDaysInWeek,f=n(3),c=f.normalizeUnit,l=n(5),y=l.convertDayOfWeek,m=l.computeWeekNumber,h=l.computeFromDayOfYear,g=n(4);t.at=function(e){if("number"==typeof e)return g(new Date(e));var t=new Date(this[o]);if(e=Object.keys(e).reduce(function(t,n){return t[c(n)]=e[n],t},{}),"year"in e&&t.setFullYear(e.year),"month"in e&&t.setMonth(e.month-1),"day"in e&&t.setDate(e.day),"dayOfYear"in e){var n=h(t.getFullYear(),e.dayOfYear),r=i(n,2),a=r[0],u=r[1];t.setMonth(a),t.setDate(u)}if("week"in e||"isoWeek"in e||"dayOfWeek"in e||"isoDayOfWeek"in e){var f=0,l=this.getLocale();"week"in e?f+=7*(e.week-m(t.getFullYear(),t.getMonth(),t.getDate(),s(l),d(l))):"isoWeek"in e&&(f+=7*(e.isoWeek-m(t.getFullYear(),t.getMonth(),t.getDate(),1,4))),"dayOfWeek"in e?f+=e.dayOfWeek-y(t.getDay(),s(l))-1:"isoDayOfWeek"in e&&(f+=e.isoDayOfWeek-y(t.getDay(),1)-1),t.setDate(t.getDate()+f)}return"hour"in e&&t.setHours(e.hour),"minute"in e&&t.setMinutes(e.minute),"second"in e&&t.setSeconds(e.second),"millisecond"in e&&t.setMilliseconds(e.millisecond),g(t)},t.add=function(e){if("number"==typeof e)return g(new Date(this.valueOf()+e));var t=new Date(this[o]);if(e=Object.keys(e).reduce(function(t,n){return t[c(n)]=e[n],t},{}),"year"in e&&t.setFullYear(t.getFullYear()+e.year),"month"in e&&t.setMonth(t.getMonth()+e.month),"dayOfWeek"in e&&(e.day=e.dayOfWeek),"isoDayOfWeek"in e&&(e.day=e.isoDayOfWeek),"dayOfYear"in e&&(e.day=e.dayOfYear),"week"in e||"isoWeek"in e){var n=void 0;n="week"in e?7*e.week:7*e.isoWeek,"day"in e?e.day+=n:e.day=n}return"day"in e&&t.setDate(t.getDate()+e.day),"hour"in e&&t.setHours(t.getHours()+e.hour),"minute"in e&&t.setMinutes(t.getMinutes()+e.minute),"second"in e&&t.setSeconds(t.getSeconds()+e.second),"millisecond"in e&&t.setMilliseconds(t.getMilliseconds()+e.millisecond),g(t)},t.subtract=function(e){return"number"==typeof e?e*=-1:e=Object.keys(e).reduce(function(t,n){return t[n]=-e[n],t},{}),this.add(e)},t.startOf=function(e){var t={};switch(e=c(e)){case"year":t.month=1;case"month":t.day=1;case"week":case"isoWeek":case"dayOfWeek":case"isoDayOfWeek":case"dayOfYear":case"day":t.hour=0;case"hour":t.minute=0;case"minute":t.second=0;case"second":t.millisecond=0;break;case"millisecond":return this}return"week"===e&&(t.day=this.getDay()-this.getDayOfWeek()+1),"isoWeek"===e&&(t.day=this.getDay()-this.getIsoDayOfWeek()+1),this.at(t)},t.endOf=function(e){return this.startOf(e).add(r({},e,1)).subtract({millisecond:1})}},function(e,t,n){"use strict";var r=n(2),i=r.normalizeLocales;e.exports=function(e){var t="en-US";e.getDefaultLocale=function(){return t},e.setDefaultLocale=function(e){return t=i(e)}}},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=n(3),a=i.normalizeUnit;e.exports=function(e){e.range=function(e,t){var n=arguments.length<=2||void 0===arguments[2]?"1 day":arguments[2],i=[],o=1;if(isNaN(parseInt(n,10))||(o=parseInt(n,10),n=n.replace(o,"")),0===o)throw new TypeError("The multiplier cannot be zero.");n=a(n);var u=o>0?"isSameOrBefore":"isSameOrAfter";for(e=e.startOf(n),t=t.startOf(n);e[u](t);)i.push(e),e=e.add(r({},n,o));return i}}},function(e,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},r=function(e){return"object"===("undefined"==typeof e?"undefined":n(e))&&null!==e},i=function(e){return r(e)&&"function"==typeof e.toUTCString&&"function"==typeof e.setFullYear};e.exports={isObject:r,isDate:i}}])});

6

package.json
{
"name": "jour",
"description": "W.I.P.",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",

@@ -12,6 +12,6 @@ "main": "dist/index.js",

"scripts": {
"build": "webpack --progress --colors",
"build": "webpack -p --progress --colors",
"prepublish": "npm run build",
"lint": "eslint .",
"tape": "tape -r babel-register -r babel-polyfill 'lib/*.test.js'",
"tape": "tape -r babel-register -r babel-polyfill 'lib/**/*.test.js'",
"test": "npm run --silent tape | faucet",

@@ -18,0 +18,0 @@ "coverage": "nyc --reporter=html --reporter=text npm --silent run tape",

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