xcraft-core-utils 4.3.6 → 4.3.7

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/lib/string.js CHANGED
@@ -1,15 +1,15 @@
1
- 'use strict';
2
-
3
- exports.camelcasify = function (str) {
4
- return str.replace(/(\.[a-z])/g, function (match) {
5
- return match.replace('.', '').toUpperCase();
6
- });
7
- };
8
-
9
- exports.capitalize = function (str) {
10
- return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
11
- };
12
-
13
- exports.jsify = (str) => {
14
- return str.replace(/-([a-z])/g, (m, g1) => g1.toUpperCase());
15
- };
1
+ 'use strict';
2
+
3
+ exports.camelcasify = function (str) {
4
+ return str.replace(/(\.[a-z])/g, function (match) {
5
+ return match.replace('.', '').toUpperCase();
6
+ });
7
+ };
8
+
9
+ exports.capitalize = function (str) {
10
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
11
+ };
12
+
13
+ exports.jsify = (str) => {
14
+ return str.replace(/-([a-z])/g, (m, g1) => g1.toUpperCase());
15
+ };
package/lib/whereIs.js CHANGED
@@ -1,13 +1,13 @@
1
- const path = require('path');
2
- const fse = require('fs-extra');
3
-
4
- module.exports = function whereIs(bin) {
5
- var fullLocation = null;
6
-
7
- var exists = process.env.PATH.split(path.delimiter).some(function (location) {
8
- fullLocation = path.join(location, bin);
9
- return fse.existsSync(fullLocation);
10
- });
11
-
12
- return exists ? fullLocation : null;
13
- };
1
+ const path = require('path');
2
+ const fse = require('fs-extra');
3
+
4
+ module.exports = function whereIs(bin) {
5
+ var fullLocation = null;
6
+
7
+ var exists = process.env.PATH.split(path.delimiter).some(function (location) {
8
+ fullLocation = path.join(location, bin);
9
+ return fse.existsSync(fullLocation);
10
+ });
11
+
12
+ return exists ? fullLocation : null;
13
+ };
package/lib/yaml.js CHANGED
@@ -1,10 +1,10 @@
1
- 'use strict';
2
-
3
- var fs = require('fs');
4
-
5
- exports.fromFile = function (yamlFile) {
6
- var yaml = require('js-yaml');
7
-
8
- var data = fs.readFileSync(yamlFile, 'utf8');
9
- return yaml.safeLoad(data);
10
- };
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+
5
+ exports.fromFile = function (yamlFile) {
6
+ var yaml = require('js-yaml');
7
+
8
+ var data = fs.readFileSync(yamlFile, 'utf8');
9
+ return yaml.safeLoad(data);
10
+ };
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "xcraft-core-utils",
3
- "version": "4.3.6",
4
- "description": "Xcraft utils",
5
- "main": "index.js",
6
- "engines": {
7
- "node": ">=14"
8
- },
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- },
12
- "keywords": [
13
- "xcraft",
14
- "utils",
15
- "helpers"
16
- ],
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/Xcraft-Inc/xcraft-core-utils.git"
20
- },
21
- "author": "Mathieu Schroeter",
22
- "license": "MIT",
23
- "dependencies": {
24
- "ansi-regex": "^2.1.1",
25
- "cli-color": "^1.2.0",
26
- "escape-regexp": "0.0.1",
27
- "escape-string-regexp": "^1.0.5",
28
- "figlet": "^1.2.1",
29
- "fs-extra": "^9.1.0",
30
- "gigawatts": "^4.0.1",
31
- "js-yaml": "^3.9.0",
32
- "linked-list": "^1.0.4",
33
- "lodash": "^4.17.20",
34
- "locks": "^0.2.2",
35
- "prop-types": "^15.7.2",
36
- "uuid": "^8.3.2",
37
- "xcraft-core-busclient": "^5.0.0",
38
- "xcraft-core-fs": "^2.0.0",
39
- "xcraft-core-log": "^2.0.0",
40
- "xcraft-core-utils": "^4.0.0"
41
- },
42
- "bugs": {
43
- "url": "https://github.com/Xcraft-Inc/xcraft-core-utils/issues"
44
- },
45
- "homepage": "https://github.com/Xcraft-Inc/xcraft-core-utils#readme",
46
- "devDependencies": {
47
- "should": "^11.2.1",
48
- "prettier": "2.0.4",
49
- "xcraft-dev-prettier": "^2.0.0",
50
- "xcraft-dev-rules": "^2.0.0"
51
- },
52
- "prettier": "xcraft-dev-prettier"
53
- }
1
+ {
2
+ "name": "xcraft-core-utils",
3
+ "version": "4.3.7",
4
+ "description": "Xcraft utils",
5
+ "main": "index.js",
6
+ "engines": {
7
+ "node": ">=14"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "xcraft",
14
+ "utils",
15
+ "helpers"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Xcraft-Inc/xcraft-core-utils.git"
20
+ },
21
+ "author": "Mathieu Schroeter",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "ansi-regex": "^2.1.1",
25
+ "cli-color": "^1.2.0",
26
+ "escape-regexp": "0.0.1",
27
+ "escape-string-regexp": "^1.0.5",
28
+ "figlet": "^1.2.1",
29
+ "fs-extra": "^9.1.0",
30
+ "gigawatts": "^4.0.1",
31
+ "js-yaml": "^3.9.0",
32
+ "linked-list": "^1.0.4",
33
+ "lodash": "^4.17.20",
34
+ "locks": "^0.2.2",
35
+ "prop-types": "^15.7.2",
36
+ "uuid": "^8.3.2",
37
+ "xcraft-core-busclient": "^5.0.0",
38
+ "xcraft-core-fs": "^2.0.0",
39
+ "xcraft-core-log": "^2.0.0",
40
+ "xcraft-core-utils": "^4.0.0"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/Xcraft-Inc/xcraft-core-utils/issues"
44
+ },
45
+ "homepage": "https://github.com/Xcraft-Inc/xcraft-core-utils#readme",
46
+ "devDependencies": {
47
+ "should": "^11.2.1",
48
+ "prettier": "2.0.4",
49
+ "xcraft-dev-prettier": "^2.0.0",
50
+ "xcraft-dev-rules": "^2.0.0"
51
+ },
52
+ "prettier": "xcraft-dev-prettier"
53
+ }
package/test/index.js CHANGED
@@ -1,68 +1,68 @@
1
- 'use strict';
2
-
3
- var should = require('should'); /* jshint ignore:line */
4
- var xUtils = require('../index.js');
5
-
6
- describe('xcraft-core-utils', function () {
7
- describe('#string#camelcasify ()', function () {
8
- var topics = [
9
- {
10
- in: '',
11
- out: '',
12
- },
13
- {
14
- in: 'foo.bar',
15
- out: 'fooBar',
16
- },
17
- {
18
- in: 'fooBar',
19
- out: 'fooBar',
20
- },
21
- {
22
- in: 'f.o.o.b.a.r',
23
- out: 'fOOBAR',
24
- },
25
- {
26
- in: 'fo.ob.ar',
27
- out: 'foObAr',
28
- },
29
- ];
30
-
31
- topics.forEach(function (item) {
32
- it('camelcasify ' + item.in, function () {
33
- xUtils.string.camelcasify(item.in).should.be.equal(item.out);
34
- });
35
- });
36
- });
37
-
38
- describe('#string#capitalize ()', function () {
39
- var strings = [
40
- {
41
- in: '',
42
- out: '',
43
- },
44
- {
45
- in: 'foobar',
46
- out: 'Foobar',
47
- },
48
- {
49
- in: 'FOOBAR',
50
- out: 'Foobar',
51
- },
52
- {
53
- in: 'fOOBAR',
54
- out: 'Foobar',
55
- },
56
- {
57
- in: 'Foobar',
58
- out: 'Foobar',
59
- },
60
- ];
61
-
62
- strings.forEach(function (str) {
63
- it('capitalize ' + str.in, function () {
64
- xUtils.string.capitalize(str.in).should.be.equal(str.out);
65
- });
66
- });
67
- });
68
- });
1
+ 'use strict';
2
+
3
+ var should = require('should'); /* jshint ignore:line */
4
+ var xUtils = require('../index.js');
5
+
6
+ describe('xcraft-core-utils', function () {
7
+ describe('#string#camelcasify ()', function () {
8
+ var topics = [
9
+ {
10
+ in: '',
11
+ out: '',
12
+ },
13
+ {
14
+ in: 'foo.bar',
15
+ out: 'fooBar',
16
+ },
17
+ {
18
+ in: 'fooBar',
19
+ out: 'fooBar',
20
+ },
21
+ {
22
+ in: 'f.o.o.b.a.r',
23
+ out: 'fOOBAR',
24
+ },
25
+ {
26
+ in: 'fo.ob.ar',
27
+ out: 'foObAr',
28
+ },
29
+ ];
30
+
31
+ topics.forEach(function (item) {
32
+ it('camelcasify ' + item.in, function () {
33
+ xUtils.string.camelcasify(item.in).should.be.equal(item.out);
34
+ });
35
+ });
36
+ });
37
+
38
+ describe('#string#capitalize ()', function () {
39
+ var strings = [
40
+ {
41
+ in: '',
42
+ out: '',
43
+ },
44
+ {
45
+ in: 'foobar',
46
+ out: 'Foobar',
47
+ },
48
+ {
49
+ in: 'FOOBAR',
50
+ out: 'Foobar',
51
+ },
52
+ {
53
+ in: 'fOOBAR',
54
+ out: 'Foobar',
55
+ },
56
+ {
57
+ in: 'Foobar',
58
+ out: 'Foobar',
59
+ },
60
+ ];
61
+
62
+ strings.forEach(function (str) {
63
+ it('capitalize ' + str.in, function () {
64
+ xUtils.string.capitalize(str.in).should.be.equal(str.out);
65
+ });
66
+ });
67
+ });
68
+ });
package/test/jobqueue.js CHANGED
@@ -1,33 +1,33 @@
1
- const xUtils = require('../index.js');
2
- //const watt = require('gigawatts');
3
- const jobs1 = [
4
- {id: 1, gen: 0},
5
- {id: 1, gen: 1},
6
- {id: 1, gen: 4},
7
- {id: 1, gen: 5},
8
- {id: 2, gen: 1},
9
- {id: 2, gen: 2},
10
- {id: 2, gen: 3},
11
- {id: 4, gen: 0},
12
- {id: 1, gen: 2},
13
- {id: 1, gen: 3},
14
- {id: 1, gen: 6},
15
- {id: 1, gen: 7},
16
- {id: 1, gen: 8},
17
- {id: 1, gen: 9},
18
- {id: 1, gen: 10},
19
- {id: 3, gen: 0},
20
- ];
21
-
22
- const runner = (job, done) => {
23
- setTimeout(() => {
24
- console.log(`[id:${job.id}] gen:${job.gen}`);
25
- done();
26
- }, 1000);
27
- };
28
-
29
- const queue = new xUtils.JobQueue('test', runner, 1);
30
-
31
- for (const j of jobs1.values()) {
32
- queue.push(j);
33
- }
1
+ const xUtils = require('../index.js');
2
+ //const watt = require('gigawatts');
3
+ const jobs1 = [
4
+ {id: 1, gen: 0},
5
+ {id: 1, gen: 1},
6
+ {id: 1, gen: 4},
7
+ {id: 1, gen: 5},
8
+ {id: 2, gen: 1},
9
+ {id: 2, gen: 2},
10
+ {id: 2, gen: 3},
11
+ {id: 4, gen: 0},
12
+ {id: 1, gen: 2},
13
+ {id: 1, gen: 3},
14
+ {id: 1, gen: 6},
15
+ {id: 1, gen: 7},
16
+ {id: 1, gen: 8},
17
+ {id: 1, gen: 9},
18
+ {id: 1, gen: 10},
19
+ {id: 3, gen: 0},
20
+ ];
21
+
22
+ const runner = (job, done) => {
23
+ setTimeout(() => {
24
+ console.log(`[id:${job.id}] gen:${job.gen}`);
25
+ done();
26
+ }, 1000);
27
+ };
28
+
29
+ const queue = new xUtils.JobQueue('test', runner, 1);
30
+
31
+ for (const j of jobs1.values()) {
32
+ queue.push(j);
33
+ }