Skip to content

Commit

Permalink
fix: CommonJS Typescript compilation; upgrades semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
angelmeraz committed Nov 27, 2023
1 parent e17ad56 commit bfe6e6c
Show file tree
Hide file tree
Showing 5 changed files with 4,898 additions and 3,345 deletions.
24 changes: 16 additions & 8 deletions commonjs/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";
exports.__esModule = true;
/**
* Performs type check of a string
*/
Expand All @@ -20,7 +22,7 @@ function overrideValue(collection, overrides) {
if (instanceOfString(overrides) || instanceOfArray(overrides) || typeof overrides === 'boolean') {
return overrides;
}
for (const key in overrides) {
for (var key in overrides) {
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
if (collection[key]) {
collection[key] = overrideValue(collection[key], overrides[key]);
Expand All @@ -36,7 +38,7 @@ function overrideValue(collection, overrides) {
* Overrides parameter structure must correspond to that of the collection parameter targetted key structures.
*/
function setOverrides(collection, overrides) {
for (const key in overrides) {
for (var key in overrides) {
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
if (collection[key]) {
collection[key] = overrideValue(collection[key], overrides[key]);
Expand All @@ -51,33 +53,39 @@ function setOverrides(collection, overrides) {
* Recursively flattens the collection parameter into a single dimension object transforming each key value into a string.
* If the overrides parameter is present it will compare and replace the collection targetted key values before flattening.
*/
module.exports = function ClassGroup(collection = {}, ...overrides) {
module.exports = function ClassGroup(collection) {
if (collection === void 0) { collection = {}; }
var overrides = [];
for (var _i = 1; _i < arguments.length; _i++) {
overrides[_i - 1] = arguments[_i];
}
if (overrides === null || overrides === void 0 ? void 0 : overrides.length) {
overrides === null || overrides === void 0 ? void 0 : overrides.forEach((override) => (collection = setOverrides(collection, override)));
overrides === null || overrides === void 0 ? void 0 : overrides.forEach(function (override) { return (collection = setOverrides(collection, override)); });
}
const classGroup = {};
var classGroup = {};
function flatten(col, arr) {
if (instanceOfString(col)) {
arr.push(col);
return arr;
}
if (instanceOfArray(col)) {
for (const value of col) {
for (var _i = 0, col_1 = col; _i < col_1.length; _i++) {
var value = col_1[_i];
arr.push(value);
}
return arr;
}
if (typeof col === 'boolean') {
return arr;
}
for (const key in col) {
for (var key in col) {
if (Object.prototype.hasOwnProperty.call(col, key)) {
flatten(col[key], arr);
}
}
return arr;
}
for (const key in collection) {
for (var key in collection) {
if (Object.prototype.hasOwnProperty.call(collection, key)) {
classGroup[key] = flatten(collection[key], []).filter(Boolean).join(' ');
}
Expand Down
10 changes: 10 additions & 0 deletions commonjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"strict": true,
"moduleResolution": "node"
},
"include": ["../ClassGroup.d.ts"],
"exclude": ["node_modules", "**/__tests__/*"],
}
Loading

0 comments on commit bfe6e6c

Please sign in to comment.