join-string
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,3 +0,4 @@ | ||
export declare const joinString: (delimiter: string) => (...items: any[]) => string; | ||
declare type JoinFunction = (...items: any[]) => string; | ||
export declare const joinString: (delimiter: string) => JoinFunction; | ||
export default joinString; | ||
export declare const joinClassName: (...items: any[]) => string; | ||
export declare const joinClassName: JoinFunction; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var typesafe_is_1 = require("typesafe-is"); | ||
exports.joinString = function (delimiter) { | ||
return function joinFn() { | ||
var items = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
items[_i] = arguments[_i]; | ||
} | ||
var results = []; | ||
for (var index = 0; index < items.length; index++) { | ||
var item = items[index]; | ||
if (typesafe_is_1.isNumber(item) || typesafe_is_1.isFilledString(item)) { | ||
for (var index = 0; index < arguments.length; index++) { | ||
var item = arguments[index]; | ||
if (!item && item !== 0) | ||
continue; | ||
var itemType = typeof item; | ||
if (itemType == 'string' || itemType == 'number') { | ||
results.push(item); | ||
continue; | ||
} | ||
if (typesafe_is_1.isArray(item)) { | ||
results.push(joinFn.apply(void 0, item)); | ||
continue; | ||
if (Array.isArray(item) && item.length > 0) { | ||
var innerResult = joinFn.apply(null, item); | ||
if (innerResult) { | ||
results.push(innerResult); | ||
} | ||
} | ||
@@ -21,0 +21,0 @@ } |
{ | ||
"name": "join-string", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A utility for joining strings", | ||
@@ -27,5 +27,3 @@ "main": "dist/index.js", | ||
}, | ||
"dependencies": { | ||
"typesafe-is": "^1.0.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -32,0 +30,0 @@ "@types/jest": "^23.3.9", |
@@ -1,11 +0,15 @@ | ||
import { isFilledString, isArray, isNumber } from 'typesafe-is'; | ||
type JoinFunction = (...items: any[]) => string; | ||
export const joinString = (delimiter: string) => | ||
function joinFn(...items: Array<any>): string { | ||
export const joinString = (delimiter: string): JoinFunction => | ||
function joinFn(): string { | ||
const results: Array<string | number> = []; | ||
for (let index = 0; index < items.length; index++) { | ||
const item = items[index]; | ||
for (let index = 0; index < arguments.length; index++) { | ||
const item = arguments[index]; | ||
if (isNumber(item) || isFilledString(item)) { | ||
if (!item && item !== 0) continue; | ||
const itemType = typeof item; | ||
if (itemType == 'string' || itemType == 'number') { | ||
results.push(item); | ||
@@ -15,5 +19,7 @@ continue; | ||
if (isArray(item)) { | ||
results.push(joinFn(...item)); | ||
continue; | ||
if (Array.isArray(item) && item.length > 0) { | ||
const innerResult = joinFn.apply(null, item); | ||
if (innerResult) { | ||
results.push(innerResult); | ||
} | ||
} | ||
@@ -20,0 +26,0 @@ } |
@@ -21,3 +21,5 @@ import { joinString, joinClassName } from '../src'; | ||
const joinFn = joinString(', '); | ||
expect(joinFn('x', false, undefined, 'y', [false, null, 'z', ''])).toBe('x, y, z'); | ||
expect(joinFn('x', false, undefined, [false], 'y', [false, null, 'z', ''])).toBe( | ||
'x, y, z' | ||
); | ||
}); | ||
@@ -24,0 +26,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159877
0
145
- Removedtypesafe-is@^1.0.1
- Removedtypesafe-is@1.1.3(transitive)