qsu 0.5.1 → 0.5.4

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.
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GitToolBoxProjectSettings">
4
+ <option name="commitMessageIssueKeyValidationOverride">
5
+ <BoolValueOverride>
6
+ <option name="enabled" value="true" />
7
+ </BoolValueOverride>
8
+ </option>
9
+ <option name="commitMessageValidationConfigOverride">
10
+ <CommitMessageValidationOverride>
11
+ <option name="enabled" value="true" />
12
+ </CommitMessageValidationOverride>
13
+ </option>
14
+ <option name="commitMessageValidationEnabledOverride">
15
+ <BoolValueOverride>
16
+ <option name="enabled" value="true" />
17
+ </BoolValueOverride>
18
+ </option>
19
+ </component>
20
+ </project>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptLibraryMappings">
4
+ <includedPredefinedLibrary name="Node.js Core" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/qsu.iml" filepath="$PROJECT_DIR$/.idea/qsu.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/qsu.iml ADDED
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
package/README.md CHANGED
@@ -70,13 +70,14 @@ qsu.{{Util}}.{{Method}}({{Params1}}, {{Params2}})
70
70
  ## qsu.array
71
71
  Utility to help process array type data.
72
72
 
73
- | Method | Params | Description | Example |
74
- | --- | --- | --- | --- |
75
- | .shuffle | array **{Array}** | Shuffle the order of the given array and return | `shuffle([1, 2, 3, 4]) // [4, 2, 3, 1]...` |
76
- | .setWithDefault | <li>defaultValue **{Any}**</li><li>arrayLength **{Number&#124;null}**</li> | Initialize an array with a default value of a specific length. | `setWithDefault('abc', 4) // ['abc', 'abc', 'abc', 'abc']`<br/>`setWithDefault(null, 3) // [null, null, null]` |
77
- | .unique | array **{Array}** | Remove duplicate values from array and two-dimensional array data. In the case of 2d arrays, json type data duplication is not removed. | `unique([1, 2, 2, 3]) // [1, 2, 3]`<br/>`unique([[1], [1], [2]) // [[1], [2]]` |
78
- | .setWithNumber | <li>start **{Number}**</li><li>end **{Number}**</li> | Creates and returns an Array in the order of start...end values. | `setWithNumber(1, 3) // [1, 2, 3]`<br/>`setWithNumber(0, 3) // [0, 1, 2, 3]` |
79
- | .average | <li>array **{Array}**</li> | Returns the average of all numeric values in an array. | `average([1, 5, 15, 50]) // 17.75` |
73
+ | Method | Params | Description | Example |
74
+ |-----------------| --- |-----------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
75
+ | .shuffle | array **{Array}** | Shuffle the order of the given array and return | `shuffle([1, 2, 3, 4]) // [4, 2, 3, 1]...` |
76
+ | .setWithDefault | <li>defaultValue **{Any}**</li><li>arrayLength **{Number&#124;null}**</li> | Initialize an array with a default value of a specific length. | `setWithDefault('abc', 4) // ['abc', 'abc', 'abc', 'abc']`<br/>`setWithDefault(null, 3) // [null, null, null]` |
77
+ | .unique | array **{Array}** | Remove duplicate values from array and two-dimensional array data. In the case of 2d arrays, json type data duplication is not removed. | `unique([1, 2, 2, 3]) // [1, 2, 3]`<br/>`unique([[1], [1], [2]) // [[1], [2]]` |
78
+ | .setWithNumber | <li>start **{Number}**</li><li>end **{Number}**</li> | Creates and returns an Array in the order of start...end values. | `setWithNumber(1, 3) // [1, 2, 3]`<br/>`setWithNumber(0, 3) // [0, 1, 2, 3]` |
79
+ | .average | <li>array **{Array}**</li> | Returns the average of all numeric values in an array. | `average([1, 5, 15, 50]) // 17.75` |
80
+ | .move | <li>array **{Array}**</li> | Moves the position of a specific element in an array to the specified position. (Position starts from 0.) | `move([1, 2, 3, 4], 1, 0) // [2, 1, 3, 4]` |
80
81
 
81
82
  ## qsu.string
82
83
  Utility to help process string type data.
package/array.js CHANGED
@@ -38,10 +38,20 @@ const average = (arr) => {
38
38
  return arr.reduce((p, c) => p + c, 0) / arr.length;
39
39
  };
40
40
 
41
+ const move = (arr, from, to) => {
42
+ const arrayLength = arr.length;
43
+ if (!arr || from === null || to === null || arrayLength <= from || arrayLength <= to) {
44
+ throw new Error('Invalid move params');
45
+ }
46
+ arr.splice(to, 0, arr.splice(from, 1)[0]);
47
+ return arr;
48
+ };
49
+
41
50
  module.exports = {
42
51
  shuffle,
43
52
  setWithDefault,
44
53
  unique,
45
54
  setWithNumber,
46
55
  average,
56
+ move,
47
57
  };
package/date.js CHANGED
@@ -13,7 +13,7 @@ const today = (dateType) => {
13
13
  if (dateType !== undefined && typeof dateType !== 'string') {
14
14
  return null;
15
15
  }
16
- return moment().format(dateType ? dateType.toUpperCase() : 'YYYY-MM-DD');
16
+ return moment().format(dateType || 'YYYY-MM-DD');
17
17
  };
18
18
 
19
19
  const isRealDate = (d) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "0.5.1",
3
+ "version": "0.5.4",
4
4
  "description": "Quick and Simple Utility for javascript",
5
5
  "scripts": {
6
6
  "test": "npm run lint && mocha --require @babel/register --parallel test/*.spec.js",
@@ -17,14 +17,20 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/jooy2/qsu"
19
19
  },
20
+ "keywords": [
21
+ "util",
22
+ "utility",
23
+ "tool",
24
+ "underscore"
25
+ ],
20
26
  "devDependencies": {
21
- "@babel/node": "^7.16.0",
22
- "@babel/preset-env": "^7.16.4",
23
- "@babel/register": "^7.16.0",
24
- "eslint": "^8.4.1",
25
- "eslint-config-airbnb": "^19.0.2",
26
- "eslint-plugin-import": "^2.25.3",
27
- "mocha": "^9.1.3"
27
+ "@babel/node": "^7.16.8",
28
+ "@babel/preset-env": "^7.16.11",
29
+ "@babel/register": "^7.17.7",
30
+ "eslint": "^8.11.0",
31
+ "eslint-config-airbnb": "^19.0.4",
32
+ "eslint-plugin-import": "^2.25.4",
33
+ "mocha": "^9.2.2"
28
34
  },
29
35
  "dependencies": {
30
36
  "moment": "^2.29.1"
package/string.js CHANGED
@@ -24,7 +24,7 @@ const capitalizeEachWords = (str, naturally) => {
24
24
  if (!naturally || !contains(splitStr[i], [
25
25
  'in', 'on', 'the', 'at', 'and', 'or', 'of', 'for', 'to', 'that',
26
26
  'a', 'by', 'it', 'is', 'as', 'are', 'were', 'was', 'nor', 'an',
27
- ])) {
27
+ ], true)) {
28
28
  splitStr[i] = capitalizeFirst(splitStr[i]);
29
29
  }
30
30
  }
@@ -1,42 +0,0 @@
1
- const assert = require('assert');
2
- const _ = require('../array');
3
-
4
- describe('Array', () => {
5
- it('shuffle', (done) => {
6
- assert(_.shuffle([1, 2, 3, 4, 5, 6, 7, 8]));
7
- assert(_.shuffle([[1, 2], [3, 4], [5, 6], [7, 8]]));
8
- assert(_.shuffle([{ A: 1 }, { B: 2 }, { C: 3 }, { D: 4 }]));
9
- done();
10
- });
11
-
12
- it('setWithDefault', (done) => {
13
- assert(_.setWithDefault());
14
- assert(_.setWithDefault('test'));
15
- assert(_.setWithDefault('test', 10));
16
- assert(_.setWithDefault(100, 5));
17
- done();
18
- });
19
-
20
- it('unique', (done) => {
21
- assert.deepStrictEqual(_.unique([1, 1, 2, 2, 3]), [1, 2, 3]);
22
- assert.deepStrictEqual(_.unique(['1', '2', '3', '3', '4']), ['1', '2', '3', '4']);
23
- assert.deepStrictEqual(_.unique([1, '1', 1, 'a', 2, 'b']), [1, '1', 'a', 2, 'b']);
24
- assert.deepStrictEqual(_.unique([[1, 2], [1, 2], [2, 3], [2, 4]]), [[1, 2], [2, 3], [2, 4]]);
25
- done();
26
- });
27
-
28
- it('setWithNumber', (done) => {
29
- assert.deepStrictEqual(_.setWithNumber(1, 2), [1, 2]);
30
- assert.deepStrictEqual(_.setWithNumber(2, 1), null);
31
- assert.deepStrictEqual(_.setWithNumber(0, 5), [0, 1, 2, 3, 4, 5]);
32
- assert.deepStrictEqual(_.setWithNumber(1, 1), [1]);
33
- done();
34
- });
35
-
36
- it('average', (done) => {
37
- assert.deepStrictEqual(_.average([1, 3, 5, 7, 9]), 5);
38
- assert.deepStrictEqual(_.average([1, 5, 15, 50]), 17.75);
39
- assert.deepStrictEqual(_.average([5, -5]), 0);
40
- done();
41
- });
42
- });
package/test/date.spec.js DELETED
@@ -1,36 +0,0 @@
1
- const assert = require('assert');
2
- const moment = require('moment');
3
- const _ = require('../date');
4
-
5
- describe('Date', () => {
6
- it('dayDiff', (done) => {
7
- assert.strictEqual(_.dayDiff('2021-01-01', '2021-01-02'), 1);
8
- assert.strictEqual(_.dayDiff('2021-01-01', '2021-02-28'), 55);
9
- done();
10
- });
11
-
12
- it('today', (done) => {
13
- assert.strictEqual(_.today(), moment().format('YYYY-MM-DD'));
14
- assert.strictEqual(_.today(1), null);
15
- assert.strictEqual(_.today('YYYY-MM-DD'), moment().format('YYYY-MM-DD'));
16
- assert.strictEqual(_.today('yyyy'), moment().format('YYYY'));
17
- done();
18
- });
19
-
20
- it('isRealDate', (done) => {
21
- assert.strictEqual(_.isRealDate('2021-01-01'), true);
22
- assert.strictEqual(_.isRealDate('2021-02-28'), true);
23
- assert.strictEqual(_.isRealDate('2021-02-29'), false);
24
- assert.strictEqual(_.isRealDate('2021-03-32'), false);
25
- assert.strictEqual(_.isRealDate('2021-13-01'), false);
26
- done();
27
- });
28
-
29
- it('convertDate', (done) => {
30
- assert.strictEqual(_.convertDate('20210101'), '2021-01-01');
31
- assert.strictEqual(_.convertDate('20210101', 'YYYY-MM-DD'), '2021-01-01');
32
- assert.strictEqual(_.convertDate('20210101', 'YYYY'), '2021');
33
- assert.strictEqual(_.convertDate('2021', 'YYYY-MM-DD'), '2021-01-01');
34
- done();
35
- });
36
- });
@@ -1,56 +0,0 @@
1
- const assert = require('assert');
2
- const _ = require('../format');
3
-
4
- describe('Format', () => {
5
- it('number', (done) => {
6
- assert.strictEqual(_.number('1234'), '1,234');
7
- assert.strictEqual(_.number(1234), '1,234');
8
- assert.strictEqual(_.number(12345678), '12,345,678');
9
- assert.strictEqual(_.number(null), '0');
10
- done();
11
- });
12
-
13
- it('fileName', (done) => {
14
- assert.strictEqual(_.fileName('C:\\Users\\test\\Desktop\\text.txt'), 'text');
15
- assert.strictEqual(_.fileName('/home/user/Desktop/example.txt'), 'example');
16
- assert.strictEqual(_.fileName('C:\\example.txt', true), 'example.txt');
17
- done();
18
- });
19
-
20
- it('fileSize', (done) => {
21
- assert.strictEqual(_.fileExt('C:\\Users\\test\\Desktop\\text.txt'), 'txt');
22
- assert.strictEqual(_.fileExt('hello.html'), 'html');
23
- assert.strictEqual(_.fileExt('this.is.file.PNG'), 'png');
24
- assert.strictEqual(_.fileExt('no-ext'), 'Unknown');
25
- done();
26
- });
27
-
28
- it('fileExt', (done) => {
29
- assert.strictEqual(_.fileSize(1), '1 Bytes');
30
- assert.strictEqual(_.fileSize(1000000), '976.56 KB');
31
- assert.strictEqual(_.fileSize(2000, 3), '1.953 KB');
32
- assert.strictEqual(_.fileSize(250000000), '238.42 MB');
33
- done();
34
- });
35
-
36
- it('msToTime', (done) => {
37
- assert.strictEqual(_.msToTime(100000), '00:01:40');
38
- assert.strictEqual(_.msToTime(100000, true), '00:01:40.0');
39
- assert.strictEqual(_.msToTime(100000, false, '-'), '00-01-40');
40
- assert.strictEqual(_.msToTime(123456789), '34:17:36');
41
- done();
42
- });
43
-
44
- it('secToTime', (done) => {
45
- assert.strictEqual(_.secToTime(60), '00:01:00');
46
- assert.strictEqual(_.secToTime(3800, '-'), '01-03-20');
47
- assert.strictEqual(_.secToTime(360000), '100:00:00');
48
- done();
49
- });
50
-
51
- it('license', (done) => {
52
- assert(_.license({ type: 'mit', author: 'example', yearStart: 2021 }));
53
- assert(_.license({ author: 'example', yearStart: 2021 }));
54
- done();
55
- });
56
- });
package/test/math.spec.js DELETED
@@ -1,30 +0,0 @@
1
- const assert = require('assert');
2
- const _ = require('../math');
3
-
4
- describe('Math', () => {
5
- it('rand', (done) => {
6
- assert(typeof _.rand() === 'number');
7
- assert(typeof _.rand(1) === 'number');
8
- assert(typeof _.rand(1, 2) === 'number');
9
- for (let i = 0; i < 50; i += 1) {
10
- assert(_.rand() <= 1);
11
- assert(_.rand(5) <= 5);
12
- const offsetTest = _.rand(5, 10);
13
- assert(offsetTest >= 5 && offsetTest <= 10);
14
- }
15
- done();
16
- });
17
-
18
- it('add', (done) => {
19
- assert.strictEqual(_.add(1, 2, 3, 4), 10);
20
- assert.strictEqual(_.add([1, 2, 3]), 6);
21
- done();
22
- });
23
-
24
- it('mul', (done) => {
25
- assert.strictEqual(_.mul(1, 2, 3, 4), 24);
26
- assert.strictEqual(_.mul([1, 2, 3]), 6);
27
- assert.strictEqual(_.mul(1, 5, 7, 0, 9), 0);
28
- done();
29
- });
30
- });
package/test/misc.spec.js DELETED
@@ -1,8 +0,0 @@
1
- const assert = require('assert');
2
- const _ = require('../misc');
3
-
4
- describe('Misc', () => {
5
- it('sleep', (done) => {
6
- assert(_.sleep(100).then(() => done()));
7
- });
8
- });
@@ -1,107 +0,0 @@
1
- const assert = require('assert');
2
- const _ = require('../string');
3
-
4
- describe('String', () => {
5
- it('removeSpecialChar', (done) => {
6
- assert.strictEqual(_.removeSpecialChar('1 2!3☆4@5+6─🌍'), '123456');
7
- assert.strictEqual(_.removeSpecialChar('Hello, World!'), 'HelloWorld');
8
- assert.strictEqual(_.removeSpecialChar('12 34-56,78=90'), '1234567890');
9
- assert.strictEqual(_.removeSpecialChar('ABC가나다ㄱㄴㄷㅏㅑㅓ天地人'), 'ABC가나다ㄱㄴㄷㅏㅑㅓ天地人');
10
- assert.strictEqual(_.removeSpecialChar('Hello World', true), 'Hello World');
11
- done();
12
- });
13
-
14
- it('removeNewLine', (done) => {
15
- assert.strictEqual(_.removeNewLine(`te
16
- st`), 'test');
17
- assert.strictEqual(_.removeNewLine('te\rst'), 'test');
18
- assert.strictEqual(_.removeNewLine('te\nst'), 'test');
19
- assert.strictEqual(_.removeNewLine('te\r\nst'), 'test');
20
- assert.strictEqual(_.removeNewLine('te\r\nst', '|'), 'te|st');
21
- assert.strictEqual(_.removeNewLine('t\ne\r\ns\rt', '-'), 't-e-s-t');
22
- done();
23
- });
24
-
25
- it('capitalizeFirst', (done) => {
26
- assert.strictEqual(_.capitalizeFirst('t'), 'T');
27
- assert.strictEqual(_.capitalizeFirst('test'), 'Test');
28
- assert.strictEqual(_.capitalizeFirst('tEST'), 'TEST');
29
- done();
30
- });
31
-
32
- it('capitalizeEachWords', (done) => {
33
- assert.strictEqual(_.capitalizeEachWords('hello, world!'), 'Hello, World!');
34
- assert.strictEqual(_.capitalizeEachWords('test'), 'Test');
35
- assert.strictEqual(_.capitalizeEachWords('this is the test sentence.', true), 'This is the Test Sentence.');
36
- done();
37
- });
38
-
39
- it('count', (done) => {
40
- assert.strictEqual(_.count('hello', 'l'), 2);
41
- assert.strictEqual(_.count('abcdABCD', 'a'), 1);
42
- assert.strictEqual(_.count('aaaaaa', 'a'), 6);
43
- assert.strictEqual(_.count('hello', 'll'), 1);
44
- done();
45
- });
46
-
47
- it('shuffle', (done) => {
48
- assert(_.shuffle('hi'));
49
- assert(_.shuffle('abc def ghi'));
50
- done();
51
- });
52
-
53
- it('createRandomCode', (done) => {
54
- assert(_.createRandom());
55
- assert(_.createRandom(5));
56
- assert(_.createRandom(10));
57
- done();
58
- });
59
-
60
- it('hideRandom', (done) => {
61
- assert(_.hideRandom('test'));
62
- assert(_.hideRandom('test', 2));
63
- assert(_.hideRandom('test', 2, '#'));
64
- done();
65
- });
66
-
67
- it('truncate', (done) => {
68
- assert.strictEqual(_.truncate('test', 2), 'te');
69
- assert.strictEqual(_.truncate('test', 1, '...'), 't...');
70
- done();
71
- });
72
-
73
- it('encrypt', (done) => {
74
- assert(_.encrypt('test', '12345678901234567890123456789012'));
75
- assert(_.encrypt('test', '12345678901234567890123456789012', 'aes-256-gcm', 16));
76
- done();
77
- });
78
-
79
- it('decrypt', (done) => {
80
- assert.strictEqual(_.decrypt('61ba43b65fc3fc2bdbd0d1ad8576344d:1831d7c37d12b3bf7ee73195d31af91b', '12345678901234567890123456789012'), 'test');
81
- done();
82
- });
83
-
84
- it('md5', (done) => {
85
- assert.strictEqual(_.md5('test'), '098f6bcd4621d373cade4e832627b4f6');
86
- assert.strictEqual(_.md5('qsu-md5'), '94af002364e42b514badb41b870ceb04');
87
- done();
88
- });
89
-
90
- it('sha1', (done) => {
91
- assert.strictEqual(_.sha1('test'), 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3');
92
- assert.strictEqual(_.sha1('qsu-md5'), 'e5c5dc3b2be3542475671d460f906c3b176bb5bf');
93
- done();
94
- });
95
-
96
- it('sha256', (done) => {
97
- assert.strictEqual(_.sha256('test'), '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08');
98
- assert.strictEqual(_.sha256('qsu-md5'), '8c4cfec3ec79dc572958ea7f0e3cfd24b90d174969df9a4773b37b68498871ed');
99
- done();
100
- });
101
-
102
- it('unique', (done) => {
103
- assert.strictEqual(_.unique('ababcdcd'), 'abcd');
104
- assert.strictEqual(_.unique('abc--11111'), 'abc-1');
105
- done();
106
- });
107
- });
@@ -1,74 +0,0 @@
1
- const assert = require('assert');
2
- const _ = require('../verify');
3
-
4
- describe('Verify', () => {
5
- it('empty', (done) => {
6
- assert.strictEqual(_.empty(''), true);
7
- assert.strictEqual(_.empty('1234'), false);
8
- assert.strictEqual(_.empty(1234), false);
9
- assert.strictEqual(_.empty(1.234), false);
10
- assert.strictEqual(_.empty(null), true);
11
- assert.strictEqual(_.empty([]), true);
12
- assert.strictEqual(_.empty([{}]), false);
13
- assert.strictEqual(_.empty([[]]), false);
14
- assert.strictEqual(_.empty(['1234']), false);
15
- assert.strictEqual(_.empty({}), true);
16
- assert.strictEqual(_.empty({ a: '1234' }), false);
17
- done();
18
- });
19
-
20
- it('isUrl', (done) => {
21
- assert.strictEqual(_.isUrl(''), false);
22
- assert.strictEqual(_.isUrl('https://'), false);
23
- assert.strictEqual(_.isUrl('www.google.com'), false);
24
- assert.strictEqual(_.isUrl('www.google.com', true), true);
25
- assert.strictEqual(_.isUrl('https://google.com'), true);
26
- assert.strictEqual(_.isUrl('https://google.com', true), true);
27
- assert.strictEqual(_.isUrl('https://google'), true);
28
- assert.strictEqual(_.isUrl('https://google', false, true), false);
29
- assert.strictEqual(_.isUrl('https://google.com?query=qsu'), true);
30
- done();
31
- });
32
-
33
- it('contains', (done) => {
34
- assert.strictEqual(_.contains('12345', '3'), true);
35
- assert.strictEqual(_.contains('12345', '10'), false);
36
- assert.strictEqual(_.contains('ABC', ['A', 'B', 'C']), true);
37
- assert.strictEqual(_.contains('ABC', ['D', 'E', 'F']), false);
38
- assert.strictEqual(_.contains('ABC', ['AB', 'C'], true), false);
39
- assert.strictEqual(_.contains('AB', ['AB', 'C', 'D'], true), true);
40
- done();
41
- });
42
-
43
- it('is2dArray', (done) => {
44
- assert.strictEqual(_.is2dArray([]), false);
45
- assert.strictEqual(_.is2dArray([[], []]), true);
46
- assert.strictEqual(_.is2dArray('A'), false);
47
- assert.strictEqual(_.is2dArray([{ a: 1 }, { b: 2 }]), false);
48
- assert.strictEqual(_.is2dArray([[1], [2]]), true);
49
- done();
50
- });
51
-
52
- it('between', (done) => {
53
- assert.strictEqual(_.between(1, [1, 10]), false);
54
- assert.strictEqual(_.between(1, [1, 10], true), true);
55
- assert.strictEqual(_.between(11, [10, 100]), true);
56
- done();
57
- });
58
-
59
- it('length', (done) => {
60
- assert.strictEqual(_.length('12345'), 5);
61
- assert.strictEqual(_.length(12345), 5);
62
- assert.strictEqual(_.length(() => '123'), 3);
63
- assert.strictEqual(_.length([1, 2, 3, 4]), 4);
64
- assert.strictEqual(_.length({ hello: 'world', lorem: 'ipsum' }), 2);
65
- assert.strictEqual(_.length([{ hello: 1, world: 2 }, { lorem: 3 }]), 2);
66
- done();
67
- });
68
-
69
- it('isBotAgent', (done) => {
70
- assert.strictEqual(_.isBotAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html'), true);
71
- assert.strictEqual(_.isBotAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'), false);
72
- done();
73
- });
74
- });