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

@scoir/date

Package Overview
Dependencies
Maintainers
36
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scoir/date - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

17

dist/formatter.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _isCredibleDate = _interopRequireDefault(require("./is-credible-date"));
var DateFormatter = {
format: function format(date, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
defaultText = _ref.defaultText,
inputFormat = _ref.inputFormat,
_ref$outputFormat = _ref.outputFormat,
outputFormat = _ref$outputFormat === void 0 ? 'MMM DD, YYYY' : _ref$outputFormat;
defaultText = _ref.defaultText,
inputFormat = _ref.inputFormat,
_ref$outputFormat = _ref.outputFormat,
outputFormat = _ref$outputFormat === void 0 ? 'MMM DD, YYYY' : _ref$outputFormat;
if (!(0, _isCredibleDate["default"])(date)) {
return defaultText;
}
return (0, _momentTimezone["default"])(date, inputFormat).format(outputFormat);
}
};
var _default = DateFormatter;
exports["default"] = _default;
var _default = exports["default"] = DateFormatter;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _formatter = _interopRequireDefault(require("./formatter"));
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
var _isCredibleDate = _interopRequireDefault(require("./is-credible-date"));
jest.mock('./is-credible-date');

@@ -25,3 +21,2 @@ jest.mock('moment-timezone', function () {

_isCredibleDate["default"].mockReturnValueOnce(true);
(0, _momentTimezone["default"])().format.mockClear();

@@ -31,10 +26,6 @@ });

_isCredibleDate["default"].mockReset();
_isCredibleDate["default"].mockReturnValueOnce(false);
expect(_formatter["default"].format('my bad date')).toBeUndefined();
expect(_isCredibleDate["default"]).toHaveBeenCalledWith('my bad date');
_isCredibleDate["default"].mockClear();
expect(_formatter["default"].format('my bad date', {

@@ -41,0 +32,0 @@ defaultText: 'N/A'

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.isCredibleDate = exports.formatter = void 0;
var _formatter = _interopRequireDefault(require("./formatter"));
exports.formatter = _formatter["default"];
var _isCredibleDate = _interopRequireDefault(require("./is-credible-date"));
exports.isCredibleDate = _isCredibleDate["default"];
"use strict";
var _ = require(".");
it('should expose a formatter', function () {

@@ -6,0 +5,0 @@ expect(_.formatter).toEqual(expect.any(Object));

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _includes = _interopRequireDefault(require("lodash/includes"));
var EMPTY_FORMAT = [undefined, null, '', '0001-01-01', '0001-01-01T00:00:00Z'];
var _default = function _default(input) {
var _default = exports["default"] = function _default(input) {
return !(0, _includes["default"])(EMPTY_FORMAT, input);
};
exports["default"] = _default;
};
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _isCredibleDate = _interopRequireDefault(require("./is-credible-date"));
it('should return false for "invalid" dates', function () {

@@ -8,0 +6,0 @@ expect((0, _isCredibleDate["default"])(undefined)).toBe(false);

{
"name": "@scoir/date",
"version": "2.0.2",
"version": "2.0.3",
"description": "",

@@ -9,4 +9,4 @@ "author": "@scoir",

"scripts": {
"watch": "../../bundle.sh -w",
"prepublish": "../../bundle.sh"
"build": "../../bundle.sh",
"watch": "../../bundle.sh -w"
},

@@ -22,3 +22,3 @@ "publishConfig": {

},
"gitHead": "636235ae8af988470caa16473f36fa9e32817de7"
"gitHead": "b9c0faecaf06c1f08200b84e3f21a433801a2c24"
}
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