Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

join-string

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

join-string - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

5

dist/index.d.ts

@@ -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;

22

dist/index.js
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc