-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Checks if string can parse as URL | ||
* | ||
* @param {any} str | ||
* @returns {boolean} | ||
*/ | ||
export default function isUrl(str) { | ||
let url; | ||
try { | ||
url = new URL(str); | ||
} | ||
catch (_) { | ||
return false; | ||
} | ||
return url.protocol === 'http:' || url.protocol === 'https:'; | ||
} | ||
//# sourceMappingURL=isUrl.mjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import isFunction from '../is/isFunction.mjs'; | ||
import toString from '../to/toString.mjs'; | ||
export class CollectionArray { | ||
constructor() { | ||
this.items = []; | ||
} | ||
push(item) { | ||
this.items.push(item); | ||
} | ||
pull() { | ||
return !this.isEmpty() ? this.items.pop() : undefined; | ||
} | ||
size() { | ||
return this.items.length; | ||
} | ||
isEmpty() { | ||
return this.size() === 0; | ||
} | ||
toArray() { | ||
return [...this.items]; | ||
} | ||
toString(callback) { | ||
const data = this.toArray(); | ||
if (callback && isFunction(callback)) { | ||
return data.map(item => callback(item)).toString(); | ||
} | ||
return data.toString(); | ||
} | ||
map(callback) { | ||
const data = this.toArray(); | ||
if (!isFunction(callback)) { | ||
throw Error('Invalid map-function: ' + toString(callback)); | ||
} | ||
return data.map(item => callback(item)); | ||
} | ||
} | ||
export default new CollectionArray(); | ||
//# sourceMappingURL=CollectionArray.mjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Checks if string can parse as URL | ||
* | ||
* @param {any} str | ||
* @returns {boolean} | ||
*/ | ||
export default function isUrl(str: any): boolean; | ||
//# sourceMappingURL=isUrl.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export declare class CollectionArray<T> { | ||
protected items: T[]; | ||
push(item: T): void; | ||
pull(): T | undefined; | ||
size(): number; | ||
isEmpty(): boolean; | ||
toArray(): T[]; | ||
toString(callback?: (i: T) => any): string; | ||
map<R extends any>(callback: (i: T) => any): R[]; | ||
} | ||
declare const _default: CollectionArray<unknown>; | ||
export default _default; | ||
//# sourceMappingURL=CollectionArray.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.