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

@talend/utils

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talend/utils - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

lib/uuid.d.ts

6

CHANGELOG.md
# @talend/utils
## 2.5.0
### Minor Changes
- f0a97113e: feat: add randomUUID function based on crypto
## 2.4.0

@@ -4,0 +10,0 @@

55

lib/date/index.js

@@ -16,9 +16,5 @@ "use strict";

exports.timeZoneExists = timeZoneExists;
var _format = _interopRequireDefault(require("date-fns/format"));
var _parse = _interopRequireDefault(require("date-fns/parse"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -42,15 +38,20 @@ * Get the offset between a timezone and the UTC time (in minutes)

const locale = 'en-US';
const utcFormat = new Intl.DateTimeFormat(locale, { ...formatOptions,
const utcFormat = new Intl.DateTimeFormat(locale, {
...formatOptions,
timeZone: 'Etc/UTC'
});
const timezoneFormat = new Intl.DateTimeFormat(locale, { ...formatOptions,
const timezoneFormat = new Intl.DateTimeFormat(locale, {
...formatOptions,
timeZone
}); // Create the same date in UTC timezone and the target timezone
});
// Create the same date in UTC timezone and the target timezone
const dateObj = date || new Date();
const utcDate = new Date(utcFormat.format(dateObj));
const timezoneDate = new Date(timezoneFormat.format(dateObj)); // Compute delta between dates
const timezoneDate = new Date(timezoneFormat.format(dateObj));
// Compute delta between dates
return (timezoneDate.getTime() - utcDate.getTime()) / (1000 * 60);
}
/**

@@ -62,4 +63,2 @@ * Format an UTC offset from minutes to [+/-][HH][separator][mm]

*/
function formatUTCOffset(offset, separator) {

@@ -74,2 +73,3 @@ const sign = offset >= 0 ? '+' : '-';

}
/**

@@ -80,7 +80,6 @@ * Format a human-readable UTC offset

*/
function formatReadableUTCOffset(offset) {
return formatUTCOffset(offset, ':');
}
/**

@@ -96,4 +95,2 @@ * Replace timezone token(s) in the date format pattern to a specific timezone's value(s).

*/
function formatTimeZoneTokens(dateFormat, timeZone) {

@@ -106,2 +103,3 @@ return dateFormat.replace(/(z|ZZ?)(?!\])/g, match => {

}
/**

@@ -115,4 +113,2 @@ * Converts the given date from the given time zone to the local time and returns a new Date object.

*/
function convertToLocalTime(date, options) {

@@ -123,2 +119,3 @@ const parsedDate = (0, _parse.default)(date);

}
/**

@@ -133,4 +130,2 @@ * Converts the given date from the local time (or from specified source timezone) to

*/
function convertToTimeZone(date, options) {

@@ -143,3 +138,2 @@ const {

let offset = getUTCOffset(timeZone, parsedDate) + parsedDate.getTimezoneOffset();
if (sourceTimeZone) {

@@ -149,5 +143,5 @@ offset -= parsedDate.getTimezoneOffset();

}
return new Date(parsedDate.getTime() + offset * 60 * 1000);
}
/**

@@ -162,10 +156,10 @@ * Returns the formatted date string in the given format, after converting it to the given time zone.

*/
function formatToTimeZone(date, formatString, options) {
const dateConvertedToTimezone = convertToTimeZone(date, options); // Replace timezone token(s) in the string format with timezone values, since format() will use local timezone
const dateConvertedToTimezone = convertToTimeZone(date, options);
// Replace timezone token(s) in the string format with timezone values, since format() will use local timezone
const dateFnsFormatWithTimeZoneValue = formatTimeZoneTokens(formatString, options.timeZone);
return (0, _format.default)(dateConvertedToTimezone, dateFnsFormatWithTimeZoneValue, options);
}
/**

@@ -177,7 +171,6 @@ * Convert a date in local TZ to UTC

*/
function convertToUTC(date) {
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
}
/**

@@ -188,4 +181,2 @@ * Check wether a timezone exists or not.

*/
function timeZoneExists(timeZone) {

@@ -202,2 +193,3 @@ try {

}
/**

@@ -207,17 +199,11 @@ * Date format options

*/
const FORMAT = {
/** en: June 29, 2021 / fr: 29 juin 2020 / ja: 2020年6月29日 / de 29. Juni 2020 */
MDY_LONG: 'MDY_LONG',
/** en: June 2020 / fr: juin 2020 / ja: 2020年6月 / Juni 2020 */
MY_LONG: 'MY_LONG',
/** en: 06/29/2020 / fr: 29/06/2020 / ja: 2020/06/29 / de: 29.06.2020 */
MDY: 'MDY',
/** en: 6/29 / fr: 29/06 / ja: 06/29 / de: 29.06 */
MD: 'MD',
/** en: 6/29/20, 10:00 PM / fr: 29/06/2020 22:00 / ja: 2020/06/29 22:00 / de: 29.06.20, 22:00 */

@@ -251,2 +237,3 @@ MDYHM: 'MDYHM'

};
/**

@@ -259,7 +246,5 @@ * Format a date using Intl.

*/
function format(date, dateOption, lang) {
return new Intl.DateTimeFormat(lang, options[dateOption]).format((0, _parse.default)(date));
}
var _default = {

@@ -266,0 +251,0 @@ convertToLocalTime,

import date from './date';
import validation from './validation';
export { date, validation };
import { randomUUID } from './uuid';
export { date, validation, randomUUID };

@@ -12,2 +12,8 @@ "use strict";

});
Object.defineProperty(exports, "randomUUID", {
enumerable: true,
get: function () {
return _uuid.randomUUID;
}
});
Object.defineProperty(exports, "validation", {

@@ -19,8 +25,6 @@ enumerable: true,

});
var _date = _interopRequireDefault(require("./date"));
var _validation = _interopRequireDefault(require("./validation"));
var _uuid = require("./uuid");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

@@ -7,11 +7,6 @@ "use strict";

exports.default = void 0;
var REGEXP = _interopRequireWildcard(require("./regexp"));
var methods = _interopRequireWildcard(require("./methods"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = {

@@ -18,0 +13,0 @@ REGEXP,

@@ -7,5 +7,3 @@ "use strict";

exports.validPhone = exports.validLastName = exports.validFirstName = exports.validEmail = exports.validDomain = void 0;
var _regexp = require("./regexp");
/**

@@ -19,2 +17,3 @@ * Build a validation method along a given regular expression

}
/**

@@ -25,5 +24,4 @@ * Check that a given value is a valid first name

*/
const validFirstName = getValidationMethod(_regexp.NAME);
const validFirstName = getValidationMethod(_regexp.NAME);
/**

@@ -34,5 +32,5 @@ * Check that a given value is a valid last name

*/
exports.validFirstName = validFirstName;
const validLastName = getValidationMethod(_regexp.NAME);
/**

@@ -43,5 +41,5 @@ * Check that a given value is a value email address

*/
exports.validLastName = validLastName;
const validEmail = getValidationMethod(_regexp.EMAIL);
/**

@@ -52,5 +50,5 @@ * Check that a given value is a valid domain

*/
exports.validEmail = validEmail;
const validDomain = getValidationMethod(_regexp.DOMAIN);
/**

@@ -61,3 +59,2 @@ * Check that a given value is a valid phone number

*/
exports.validDomain = validDomain;

@@ -64,0 +61,0 @@ const validPhone = getValidationMethod(_regexp.PHONE);

@@ -7,4 +7,4 @@ "use strict";

exports.PHONE = exports.NAME = exports.EMAIL = exports.DOMAIN = void 0;
/* eslint-disable no-useless-escape */
/* eslint-disable no-useless-escape */
const PHONE = /^((?:\+[\d().-]*\d[\d().-]*|[0-9A-F*#().-]*[0-9A-F*#][0-9A-F*#().-]*(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*;phone-context=(?:\+[\d().-]*\d[\d().-]*|(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*(?:[a-z]|[a-z][a-z0-9-]*[a-z0-9])))(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*(?:,(?:\+[\d().-]*\d[\d().-]*|[0-9A-F*#().-]*[0-9A-F*#][0-9A-F*#().-]*(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*;?)*)*)$/;

@@ -17,5 +17,5 @@ exports.PHONE = PHONE;

const DOMAIN = /^[^\~!#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i;
/* eslint-enable no-useless-escape */
exports.DOMAIN = DOMAIN;
//# sourceMappingURL=regexp.js.map

@@ -8,12 +8,15 @@ "use strict";

// List of values used in the tests
// Names
const validNames = ['Sarah', 'sarah-bernard', 'John Doe', 'Charles the 3rd', 'John Sr.', 'Іванна', 'Αλέξης', '佐藤'];
exports.validNames = validNames;
const invalidNames = ['Jo@hn', 'Jo#hn', 'Jo$hn', 'Jo%hn', 'Jo^hn', 'Jo&hn', 'Jo(hn', 'Jo)hn', 'Jo|hn', 'Jo=hn', 'Jo?hn', 'Jo;hn', 'Sa:ra', 'Sa,ra', 'Sa&ra', 'Sa¤ra', 'Sa€ra', 'Sa¨ra', 'Sa£ra', 'Sa"ra', 'Sa°ra', 'Sa§ra', 'Sa*ra']; // Emails
const invalidNames = ['Jo@hn', 'Jo#hn', 'Jo$hn', 'Jo%hn', 'Jo^hn', 'Jo&hn', 'Jo(hn', 'Jo)hn', 'Jo|hn', 'Jo=hn', 'Jo?hn', 'Jo;hn', 'Sa:ra', 'Sa,ra', 'Sa&ra', 'Sa¤ra', 'Sa€ra', 'Sa¨ra', 'Sa£ra', 'Sa"ra', 'Sa°ra', 'Sa§ra', 'Sa*ra'];
// Emails
exports.invalidNames = invalidNames;
const validEmails = ['sarah@something', 'sarah@something.fr'];
exports.validEmails = validEmails;
const invalidEmails = ['john', 'john@', 'john @']; // Phones
const invalidEmails = ['john', 'john@', 'john @'];
// Phones
exports.invalidEmails = invalidEmails;

@@ -20,0 +23,0 @@ const validPhones = ['+33102030405'];

{
"name": "@talend/utils",
"version": "2.4.0",
"version": "2.5.0",
"description": "Various utilities",

@@ -23,4 +23,4 @@ "main": "lib/index.js",

"devDependencies": {
"@talend/scripts-core": "^11.7.1",
"@talend/scripts-preset-react-lib": "^11.0.3",
"@talend/scripts-core": "^12.0.0",
"@talend/scripts-preset-react-lib": "^14.0.1",
"cross-env": "^7.0.3"

@@ -27,0 +27,0 @@ },

import date from './date';
import validation from './validation';
import { randomUUID } from './uuid';
export { date, validation };
export { date, validation, randomUUID };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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