@wixc3/common
Advanced tools
Comparing version 12.0.1 to 12.0.3
@@ -292,17 +292,3 @@ "use strict"; | ||
function join(iterable, separator) { | ||
if (!iterable) { | ||
return ''; | ||
} | ||
let result = first(iterable) || ''; | ||
let prev = null; | ||
for (const v of skip(iterable, 1)) { | ||
if (prev) { | ||
result = result + separator + prev; | ||
} | ||
prev = v; | ||
} | ||
if (prev) { | ||
result = result + separator + prev; | ||
} | ||
return result; | ||
return reduce(iterable, (acc, item) => (acc === null ? item : acc + separator + item), null) || ''; | ||
} | ||
@@ -309,0 +295,0 @@ exports.join = join; |
@@ -267,17 +267,3 @@ import { isDefined } from './types'; | ||
export function join(iterable, separator) { | ||
if (!iterable) { | ||
return ''; | ||
} | ||
let result = first(iterable) || ''; | ||
let prev = null; | ||
for (const v of skip(iterable, 1)) { | ||
if (prev) { | ||
result = result + separator + prev; | ||
} | ||
prev = v; | ||
} | ||
if (prev) { | ||
result = result + separator + prev; | ||
} | ||
return result; | ||
return reduce(iterable, (acc, item) => (acc === null ? item : acc + separator + item), null) || ''; | ||
} | ||
@@ -284,0 +270,0 @@ /** |
{ | ||
"name": "@wixc3/common", | ||
"version": "12.0.1", | ||
"version": "12.0.3", | ||
"description": "Common utils, usable in all environments", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -293,17 +293,3 @@ import { isDefined, Nullable } from './types'; | ||
export function join<T extends string>(iterable: Nullable<Iterable<T>>, separator: string): string { | ||
if (!iterable) { | ||
return ''; | ||
} | ||
let result = first(iterable) || ''; | ||
let prev: string | null = null; | ||
for (const v of skip(iterable, 1)) { | ||
if (prev) { | ||
result = result + separator + prev; | ||
} | ||
prev = v; | ||
} | ||
if (prev) { | ||
result = result + separator + prev; | ||
} | ||
return result; | ||
return reduce(iterable, (acc, item) => (acc === null ? item : acc + separator + item), null as string | null) || ''; | ||
} | ||
@@ -310,0 +296,0 @@ |
@@ -132,2 +132,3 @@ import { expect } from 'chai'; | ||
expect(join(['0'], ',')).to.eql('0'); | ||
expect(join(unique(['0', '0', '1']), ',')).to.eql('0,1'); | ||
}); | ||
@@ -134,0 +135,0 @@ it('skip', () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
350933
5987