@softwear/latestcollectioncore 1.0.59 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hasOnlyDigits.d.ts +6 -0
- package/dist/hasOnlyDigits.js +13 -0
- package/dist/index.d.ts +8 -7
- package/dist/index.js +5 -3
- package/package.json +1 -1
- package/src/hasOnlyDigits.ts +9 -0
- package/src/index.ts +8 -7
- package/test/hasOnlyDigits.js +30 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param value string or number
|
|
6
|
+
* @returns true if input contains only digits
|
|
7
|
+
*/
|
|
8
|
+
function default_1(value) {
|
|
9
|
+
if (typeof value != 'string' && typeof value != 'number')
|
|
10
|
+
return false;
|
|
11
|
+
return /^\d+$/.test('' + value);
|
|
12
|
+
}
|
|
13
|
+
exports.default = default_1;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { default as buildPropertyMappingFn } from
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as getPreferedPropertyMappings } from
|
|
5
|
-
export { default as hashBrand } from
|
|
6
|
-
export
|
|
7
|
-
export * from
|
|
1
|
+
export { default as buildPropertyMappingFn } from './buildPropertyMappingFn';
|
|
2
|
+
export { default as deepCopy } from './deepCopy';
|
|
3
|
+
export { default as ean13 } from './ean13';
|
|
4
|
+
export { default as getPreferedPropertyMappings } from './getPreferedPropertyMappings';
|
|
5
|
+
export { default as hashBrand } from './hashBrand';
|
|
6
|
+
export { default as hasOnlyDigits } from './hasOnlyDigits';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './consts';
|
package/dist/index.js
CHANGED
|
@@ -17,16 +17,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.hashBrand = exports.getPreferedPropertyMappings = exports.
|
|
20
|
+
exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
|
|
21
21
|
var buildPropertyMappingFn_1 = require("./buildPropertyMappingFn");
|
|
22
22
|
Object.defineProperty(exports, "buildPropertyMappingFn", { enumerable: true, get: function () { return __importDefault(buildPropertyMappingFn_1).default; } });
|
|
23
|
-
var ean13_1 = require("./ean13");
|
|
24
|
-
Object.defineProperty(exports, "ean13", { enumerable: true, get: function () { return __importDefault(ean13_1).default; } });
|
|
25
23
|
var deepCopy_1 = require("./deepCopy");
|
|
26
24
|
Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return __importDefault(deepCopy_1).default; } });
|
|
25
|
+
var ean13_1 = require("./ean13");
|
|
26
|
+
Object.defineProperty(exports, "ean13", { enumerable: true, get: function () { return __importDefault(ean13_1).default; } });
|
|
27
27
|
var getPreferedPropertyMappings_1 = require("./getPreferedPropertyMappings");
|
|
28
28
|
Object.defineProperty(exports, "getPreferedPropertyMappings", { enumerable: true, get: function () { return __importDefault(getPreferedPropertyMappings_1).default; } });
|
|
29
29
|
var hashBrand_1 = require("./hashBrand");
|
|
30
30
|
Object.defineProperty(exports, "hashBrand", { enumerable: true, get: function () { return __importDefault(hashBrand_1).default; } });
|
|
31
|
+
var hasOnlyDigits_1 = require("./hasOnlyDigits");
|
|
32
|
+
Object.defineProperty(exports, "hasOnlyDigits", { enumerable: true, get: function () { return __importDefault(hasOnlyDigits_1).default; } });
|
|
31
33
|
__exportStar(require("./types"), exports);
|
|
32
34
|
__exportStar(require("./consts"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param value string or number
|
|
4
|
+
* @returns true if input contains only digits
|
|
5
|
+
*/
|
|
6
|
+
export default function (value: string | number): boolean {
|
|
7
|
+
if (typeof value != 'string' && typeof value != 'number') return false
|
|
8
|
+
return /^\d+$/.test('' + value)
|
|
9
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { default as buildPropertyMappingFn } from
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as getPreferedPropertyMappings } from
|
|
5
|
-
export { default as hashBrand } from
|
|
6
|
-
export
|
|
7
|
-
export * from
|
|
1
|
+
export { default as buildPropertyMappingFn } from './buildPropertyMappingFn'
|
|
2
|
+
export { default as deepCopy } from './deepCopy'
|
|
3
|
+
export { default as ean13 } from './ean13'
|
|
4
|
+
export { default as getPreferedPropertyMappings } from './getPreferedPropertyMappings'
|
|
5
|
+
export { default as hashBrand } from './hashBrand'
|
|
6
|
+
export { default as hasOnlyDigits } from './hasOnlyDigits'
|
|
7
|
+
export * from './types'
|
|
8
|
+
export * from './consts'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { hasOnlyDigits } = require('../dist/index')
|
|
2
|
+
const { expect } = require('chai')
|
|
3
|
+
|
|
4
|
+
describe('hasOnlyDigits function', function () {
|
|
5
|
+
it('should return false on strings with non-digits', function () {
|
|
6
|
+
expect(hasOnlyDigits('123456789012abc')).to.equal(false)
|
|
7
|
+
expect(hasOnlyDigits('abc')).to.equal(false)
|
|
8
|
+
expect(hasOnlyDigits('')).to.equal(false)
|
|
9
|
+
})
|
|
10
|
+
it('should return true on strings with digits', function () {
|
|
11
|
+
expect(hasOnlyDigits('123456789012')).to.equal(true)
|
|
12
|
+
expect(hasOnlyDigits('0')).to.equal(true)
|
|
13
|
+
expect(hasOnlyDigits('1')).to.equal(true)
|
|
14
|
+
})
|
|
15
|
+
it('should return false on floats', function () {
|
|
16
|
+
expect(hasOnlyDigits(3.14)).to.equal(false)
|
|
17
|
+
})
|
|
18
|
+
it('should return true on integers', function () {
|
|
19
|
+
expect(hasOnlyDigits(123)).to.equal(true)
|
|
20
|
+
expect(hasOnlyDigits(0)).to.equal(true)
|
|
21
|
+
})
|
|
22
|
+
it('should return false on non numbers and non strings', function () {
|
|
23
|
+
expect(hasOnlyDigits(true)).to.equal(false)
|
|
24
|
+
expect(hasOnlyDigits(false)).to.equal(false)
|
|
25
|
+
expect(hasOnlyDigits([1, 2, 3])).to.equal(false)
|
|
26
|
+
expect(hasOnlyDigits([1, 2, 'a'])).to.equal(false)
|
|
27
|
+
expect(hasOnlyDigits({ key: 'value' })).to.equal(false)
|
|
28
|
+
expect(hasOnlyDigits(new Date())).to.equal(false)
|
|
29
|
+
})
|
|
30
|
+
})
|