Skip to content

Commit e220eab

Browse files
authored
Merge pull request #36 from zumba/ci-work
Updated dev dependencies and updated node list
2 parents 4c80079 + 8cd1456 commit e220eab

11 files changed

Lines changed: 2059 additions & 6202 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [10.x, 12.x, 14.x, 15.x]
19+
node-version: [14.x, 16.x, 18.x]
2020
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2121

2222
steps:
@@ -27,3 +27,4 @@ jobs:
2727
node-version: ${{ matrix.node-version }}
2828
- run: npm ci
2929
- run: npm test
30+
timeout-minutes: 5

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
node-version: [10.x, 12.x, 14.x, 15.x]
15+
node-version: [14.x, 16.x, 18.x]
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Use Node.js ${{ matrix.node-version }}
@@ -29,7 +29,7 @@ jobs:
2929
- uses: actions/checkout@v2
3030
- uses: actions/setup-node@v2
3131
with:
32-
node-version: 12
32+
node-version: 16
3333
registry-url: https://registry.npmjs.org/
3434
- run: npm ci
3535
- run: npm publish
@@ -46,7 +46,7 @@ jobs:
4646
- uses: actions/checkout@v2
4747
- uses: actions/setup-node@v2
4848
with:
49-
node-version: 12
49+
node-version: 16
5050
registry-url: https://npm.pkg.github.com/
5151
- run: npm ci
5252
- run: npm publish

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swiveljs",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Strategy driven, segmented feature toggles",
55
"main": "dist/swivel.js",
66
"license": "MIT",

dist/swivel.js

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
11
;(function SwivelJS(undefined) {
22
'use strict';
33
/**
4-
* SwivelJS v2.1.0 - 2018-05-29
4+
* SwivelJS v2.1.1 - 2022-07-24
55
* Strategy driven, segmented feature toggles
66
*
7-
* Copyright (c) 2018 Zumba®
7+
* Copyright (c) 2022 Zumba®
88
* Licensed MIT
99
*/
10-
/* jshint freeze: false */
11-
/* jshint maxcomplexity: 9 */
12-
1310
// Production steps of ECMA-262, Edition 5, 15.4.4.21
1411
// Reference: http://es5.github.io/#x15.4.4.21
1512
if (!Array.prototype.reduce) {
16-
Array.prototype.reduce = function(callback /*, initialValue*/) {
17-
if (this === null || this === undefined) {
18-
throw new TypeError('Array.prototype.reduce called on null or undefined');
19-
}
20-
if (typeof callback !== 'function') {
21-
throw new TypeError(callback + ' is not a function');
22-
}
23-
var t = Object(this), len = t.length >>> 0, k = 0, value;
24-
if (arguments.length === 2) {
25-
value = arguments[1];
26-
} else {
27-
while (k < len && !(k in t)) {
28-
k++;
13+
Object.defineProperty(Array.prototype, 'reduce', {
14+
value: function(callback /*, initialValue*/) {
15+
/* jshint maxcomplexity: 10 */
16+
if (this === null || this === undefined) {
17+
throw new TypeError('Array.prototype.reduce called on null or undefined');
2918
}
30-
if (k >= len) {
31-
throw new TypeError('Reduce of empty array with no initial value');
19+
if (typeof callback !== 'function') {
20+
throw new TypeError(callback + ' is not a function');
3221
}
33-
value = t[k++];
34-
}
35-
for (; k < len; k++) {
36-
if (k in t) {
37-
value = callback(value, t[k], k, t);
22+
var t = Object(this), len = t.length >>> 0, k = 0, value;
23+
if (arguments.length === 2) {
24+
value = arguments[1];
25+
} else {
26+
while (k < len && !(k in t)) {
27+
k++;
28+
}
29+
if (k >= len) {
30+
throw new TypeError('Reduce of empty array with no initial value');
31+
}
32+
value = t[k++];
3833
}
34+
for (; k < len; k++) {
35+
if (k in t) {
36+
value = callback(value, t[k], k, t);
37+
}
38+
}
39+
return value;
3940
}
40-
return value;
41-
};
41+
});
4242
}
4343

44-
/* jshint freeze: true */
45-
/* jshint maxcomplexity: 6 */
46-
4744
/**
4845
* Delimiter
4946
*
@@ -274,13 +271,16 @@
274271
};
275272

276273
/**
277-
* Used by reduceToBitmask
274+
* Used by parse reducer
278275
*
279276
* @param Number mask
280277
* @param Number index
281278
* @return Number
282279
*/
283280
var bitmaskIterator = function bitmaskIterator(mask, index) {
281+
if (!index || parseInt(index, 10) === 0) {
282+
return mask;
283+
}
284284
return mask | 1 << --index;
285285
};
286286

@@ -335,6 +335,25 @@
335335
return data;
336336
};
337337

338+
/**
339+
* Return the existent fields in base that are missing in compared
340+
*
341+
* @param Object base
342+
* @param Object compared
343+
* @returns Object
344+
*/
345+
var diffMissing = function(base, compared) {
346+
var data = {};
347+
var key;
348+
349+
for (key in base) {
350+
if (base.hasOwnProperty(key) && compared[key] === undefined) {
351+
data[key] = base[key];
352+
}
353+
}
354+
return data;
355+
};
356+
338357
/**
339358
* Merge this map with another map and return a new one.
340359
*
@@ -361,7 +380,7 @@
361380
FeatureMapPrototype.diff = function diff(featureMap) {
362381
var base = this.map;
363382
var compared = featureMap.map;
364-
var data = {};
383+
var data = Object.assign(diffMissing(compared, base), diffMissing(base, compared));
365384
var key;
366385

367386
for (key in compared) {
@@ -370,12 +389,6 @@
370389
}
371390
}
372391

373-
for (key in base) {
374-
if (base.hasOwnProperty(key) && compared[key] === undefined) {
375-
data[key] = base[key];
376-
}
377-
}
378-
379392
return new FeatureMap(data);
380393
};
381394

@@ -401,7 +414,7 @@
401414
key += key ? DELIMITER + child : child;
402415

403416
var isMissing = !this.slugExists(key);
404-
var isDisabled = isMissing || !(map[key] & index);
417+
var isDisabled = isMissing || !(parseInt(map[key], 10) & index);
405418

406419
if (isMissing || isDisabled) {
407420
return false;
@@ -575,6 +588,7 @@
575588
};
576589

577590
(function exportSwivel(root) {
591+
/* jshint maxcomplexity: false */
578592

579593
/**
580594
* Free variable exports

dist/swivel.min.js

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)