Socket
Socket
Sign inDemoInstall

@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.6.0 to 2.7.0

6

CHANGELOG.md
# @talend/utils
## 2.7.0
### Minor Changes
- 841be39f3: TDOPS-5386 - remove phone validation as not in use
## 2.6.0

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

13

lib/date/index.js

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

var generator = _interopRequireWildcard(require("./generator"));
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; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -187,3 +187,3 @@ /**

*/
const FORMAT = {
const FORMAT = exports.FORMAT = {
/** en: June 29, 2021 / fr: 29 juin 2020 / ja: 2020年6月29日 / de 29. Juni 2020 */

@@ -200,3 +200,2 @@ MDY_LONG: 'MDY_LONG',

};
exports.FORMAT = FORMAT;
const options = {

@@ -237,5 +236,4 @@ [FORMAT.MDY_LONG]: {

}
const buildWeeks = generator.buildWeeks;
exports.buildWeeks = buildWeeks;
var _default = {
const buildWeeks = exports.buildWeeks = generator.buildWeeks;
var _default = exports.default = {
convertToLocalTime,

@@ -251,3 +249,2 @@ convertToTimeZone,

};
exports.default = _default;
//# sourceMappingURL=index.js.map

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

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
//# sourceMappingURL=index.js.map

@@ -7,5 +7,4 @@ import * as REGEXP from './regexp';

validDomain: Function;
validPhone: Function;
REGEXP: typeof REGEXP;
};
export default _default;

@@ -9,9 +9,8 @@ "use strict";

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 = {
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var _default = exports.default = {
REGEXP,
...methods
};
exports.default = _default;
//# sourceMappingURL=index.js.map

@@ -25,7 +25,1 @@ /**

export declare const validDomain: Function;
/**
* Check that a given value is a valid phone number
* @param {string} value
* @returns {boolean}
*/
export declare const validPhone: Function;

@@ -6,3 +6,3 @@ "use strict";

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

@@ -23,3 +23,3 @@ /**

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

@@ -31,4 +31,3 @@ /**

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

@@ -40,4 +39,3 @@ /**

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

@@ -49,13 +47,3 @@ /**

*/
exports.validEmail = validEmail;
const validDomain = getValidationMethod(_regexp.DOMAIN);
/**
* Check that a given value is a valid phone number
* @param {string} value
* @returns {boolean}
*/
exports.validDomain = validDomain;
const validPhone = getValidationMethod(_regexp.PHONE);
exports.validPhone = validPhone;
const validDomain = exports.validDomain = getValidationMethod(_regexp.DOMAIN);
//# sourceMappingURL=methods.js.map

@@ -1,4 +0,3 @@

export declare const PHONE: RegExp;
export declare const EMAIL: RegExp;
export declare const NAME: RegExp;
export declare const DOMAIN: RegExp;

@@ -6,15 +6,6 @@ "use strict";

});
exports.PHONE = exports.NAME = exports.EMAIL = exports.DOMAIN = void 0;
/* 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})+)?)*;?)*)*)$/;
exports.PHONE = PHONE;
const EMAIL = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
exports.EMAIL = EMAIL;
const NAME = /^[^\~!@#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i;
exports.NAME = NAME;
const DOMAIN = /^[^\~!#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i;
/* eslint-enable no-useless-escape */
exports.DOMAIN = DOMAIN;
exports.NAME = exports.EMAIL = exports.DOMAIN = void 0;
const EMAIL = exports.EMAIL = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
const NAME = exports.NAME = /^[^\~!@#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i;
const DOMAIN = exports.DOMAIN = /^[^\~!#$%^&*()|+=?;:",<>\{\}\[\]\\\/¤€¨£°§]*$/i;
//# sourceMappingURL=regexp.js.map

@@ -5,3 +5,1 @@ export declare const validNames: Array<string>;

export declare const invalidEmails: Array<string>;
export declare const validPhones: Array<string>;
export declare const invalidPhones: Array<string>;

@@ -6,22 +6,12 @@ "use strict";

});
exports.validPhones = exports.validNames = exports.validEmails = exports.invalidPhones = exports.invalidNames = exports.invalidEmails = void 0;
exports.validNames = exports.validEmails = exports.invalidNames = exports.invalidEmails = void 0;
// 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'];
const validNames = exports.validNames = ['Sarah', 'sarah-bernard', 'John Doe', 'Charles the 3rd', 'John Sr.', 'Іванна', 'Αλέξης', '佐藤'];
const invalidNames = exports.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', 'sarah.connor@trmn.com'];
exports.validEmails = validEmails;
const invalidEmails = ['john', 'john@', 'john @', 'john\\@re'];
// Phones
exports.invalidEmails = invalidEmails;
const validPhones = ['+33102030405'];
exports.validPhones = validPhones;
const invalidPhones = ['john', 'john@', 'john @', 'sarah@something.fr', 'Fred'];
exports.invalidPhones = invalidPhones;
const validEmails = exports.validEmails = ['sarah@something', 'sarah@something.fr', 'sarah.connor@trmn.com'];
const invalidEmails = exports.invalidEmails = ['john', 'john@', 'john @', 'john\\@re'];
//# sourceMappingURL=testValues.js.map
{
"name": "@talend/utils",
"version": "2.6.0",
"version": "2.7.0",
"description": "Various utilities",

@@ -16,10 +16,10 @@ "main": "lib/index.js",

"lint": "talend-scripts lint",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage --silent",
"test:noisy": "cross-env TZ=Europe/Paris talend-scripts test",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test": "cross-env TZ=UTC talend-scripts test",
"test:cov": "cross-env TZ=UTC talend-scripts test --coverage --silent",
"test:noisy": "cross-env TZ=UTC talend-scripts test",
"test:watch": "cross-env TZ=UTC talend-scripts test --watch",
"extends": "talend-scripts extends"
},
"devDependencies": {
"@talend/scripts-core": "^14.0.0",
"@talend/scripts-core": "^16.0.0",
"cross-env": "^7.0.3"

@@ -26,0 +26,0 @@ },

@@ -45,3 +45,3 @@ import dateFnsFormat from 'date-fns/format';

// then
expect(localDate).toEqual(new Date('2020-05-13, 17:00'));
expect(localDate).toEqual(new Date('2020-05-13, 15:00'));
});

@@ -58,3 +58,3 @@

// then
expect(localDate).toEqual(new Date('2020-05-14, 01:00'));
expect(localDate).toEqual(new Date('2020-05-13, 23:00'));
});

@@ -73,3 +73,3 @@ });

// then
expect(localDate).toEqual(new Date('2020-05-13, 23:00'));
expect(localDate).toEqual(new Date('2020-05-14, 01:00'));
});

@@ -86,3 +86,3 @@

// then
expect(localDate).toEqual(new Date('2020-05-13, 15:00'));
expect(localDate).toEqual(new Date('2020-05-13, 17:00'));
});

@@ -127,3 +127,3 @@

// then
expect(localDate).toEqual('2020-05-13T23:00:00+0500');
expect(localDate).toEqual('2020-05-14T01:00:00+0500');
});

@@ -141,3 +141,3 @@

// then
expect(localDate).toEqual('2020-05-13T23:00:00Z');
expect(localDate).toEqual('2020-05-14T01:00:00Z');
});

@@ -144,0 +144,0 @@ it('should pass locale to datefns format method', () => {

@@ -1,10 +0,3 @@

import { validFirstName, validLastName, validEmail, validPhone } from './methods';
import {
validNames,
invalidNames,
validEmails,
invalidEmails,
validPhones,
invalidPhones,
} from './testValues';
import { validFirstName, validLastName, validEmail } from './methods';
import { validNames, invalidNames, validEmails, invalidEmails } from './testValues';

@@ -14,11 +7,9 @@ describe('methods', () => {

// Test valid values
test.each(validNames)(
'"%s" should be an acceptable first name',
(value: string) => expect(validFirstName(value)).toBe(true),
test.each(validNames)('"%s" should be an acceptable first name', (value: string) =>
expect(validFirstName(value)).toBe(true),
);
// Test invalid values
test.each(invalidNames)(
'"%s" should not be an acceptable first name',
(value: string) => expect(validFirstName(value)).toBe(false),
test.each(invalidNames)('"%s" should not be an acceptable first name', (value: string) =>
expect(validFirstName(value)).toBe(false),
);

@@ -29,11 +20,9 @@ });

// Test valid values
test.each(validNames)(
'"%s" should be an acceptable last name',
(value: string) => expect(validLastName(value)).toBe(true),
test.each(validNames)('"%s" should be an acceptable last name', (value: string) =>
expect(validLastName(value)).toBe(true),
);
// Test invalid values
test.each(invalidNames)(
'"%s" should not be an acceptable last name',
(value: string) => expect(validLastName(value)).toBe(false),
test.each(invalidNames)('"%s" should not be an acceptable last name', (value: string) =>
expect(validLastName(value)).toBe(false),
);

@@ -44,27 +33,11 @@ });

// Test valid values
test.each(validEmails)(
'"%s" should be an acceptable email',
(value: string) => expect(validEmail(value)).toBe(true),
test.each(validEmails)('"%s" should be an acceptable email', (value: string) =>
expect(validEmail(value)).toBe(true),
);
// Test invalid values
test.each(invalidEmails)(
'"%s" should not be an acceptable email',
(value: string) => expect(validEmail(value)).toBe(false),
test.each(invalidEmails)('"%s" should not be an acceptable email', (value: string) =>
expect(validEmail(value)).toBe(false),
);
});
describe('validPhone', () => {
// Test valid values
test.each(validPhones)(
'"%s" should be an acceptable phone',
(value: string) => expect(validPhone(value)).toBe(true),
);
// Test invalid values
test.each(invalidPhones)(
'"%s" should not be an acceptable phone',
(value: string) => expect(validPhone(value)).toBe(false),
);
});
});

@@ -1,2 +0,2 @@

import { NAME, EMAIL, DOMAIN, PHONE } from './regexp';
import { NAME, EMAIL, DOMAIN } from './regexp';

@@ -39,8 +39,1 @@ /**

export const validDomain: Function = getValidationMethod(DOMAIN);
/**
* Check that a given value is a valid phone number
* @param {string} value
* @returns {boolean}
*/
export const validPhone: Function = getValidationMethod(PHONE);

@@ -1,6 +0,1 @@

/* eslint-disable no-useless-escape */
export 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})+)?)*;?)*)*)$/;
export const EMAIL =

@@ -12,3 +7,1 @@ /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;

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

@@ -49,12 +49,1 @@ // List of values used in the tests

export const invalidEmails: Array<string> = ['john', 'john@', 'john @', 'john\\@re'];
// Phones
export const validPhones: Array<string> = ['+33102030405'];
export const invalidPhones: Array<string> = [
'john',
'john@',
'john @',
'sarah@something.fr',
'Fred',
];

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