@perfective/array
Advanced tools
Comparing version 0.2.0-alpha.3 to 0.2.0-beta
@@ -12,2 +12,3 @@ import { Unary } from '@perfective/fp'; | ||
export declare function sorted<T>(array: T[], order?: Compare<T>): T[]; | ||
export declare function unique<T>(array: T[]): T[]; | ||
export declare function isArray<T, V = unknown>(value: T[] | V): value is T[]; | ||
@@ -14,0 +15,0 @@ export declare function isNotArray<T, V = unknown>(value: T[] | V): value is V; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.length = exports.isNotEmpty = exports.isEmpty = exports.isNotArray = exports.isArray = exports.sorted = exports.reversed = exports.flatten = exports.concatenated = exports.copy = exports.arrayFromArrayLike = exports.arrayFromIterable = exports.array = void 0; | ||
exports.length = exports.isNotEmpty = exports.isEmpty = exports.isNotArray = exports.isArray = exports.unique = exports.sorted = exports.reversed = exports.flatten = exports.concatenated = exports.copy = exports.arrayFromArrayLike = exports.arrayFromIterable = exports.array = void 0; | ||
function array(...elements) { | ||
@@ -39,2 +39,6 @@ return Array.of(...elements); | ||
exports.sorted = sorted; | ||
function unique(array) { | ||
return array.filter((value, index, values) => index === values.indexOf(value)); | ||
} | ||
exports.unique = unique; | ||
function isArray(value) { | ||
@@ -41,0 +45,0 @@ return Array.isArray(value); |
@@ -1,2 +0,2 @@ | ||
export { array, arrayFromArrayLike, arrayFromIterable, concatenated, copy, flatten, isArray, isEmpty, isNotArray, isNotEmpty, length, reversed, sorted, } from './array/array'; | ||
export { array, arrayFromArrayLike, arrayFromIterable, concatenated, copy, flatten, isArray, isEmpty, isNotArray, isNotEmpty, length, reversed, sorted, unique, } from './array/array'; | ||
export { Element, append, element, first, head, insert, last, prepend, remove, replace, tail, } from './array/element'; | ||
@@ -3,0 +3,0 @@ export { Compare, Reducer, concat, copyWithin, entries, every, fill, filter, find, findIndex, forEach, includes, indexOf, join, keys, lastIndexOf, map, pop, push, reduce, reduceRight, reduceRightTo, reduceTo, reverse, shift, slice, some, sort, splice, spliceWith, unshift, values, } from './array/lift'; |
@@ -17,2 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "sorted", { enumerable: true, get: function () { return array_1.sorted; } }); | ||
Object.defineProperty(exports, "unique", { enumerable: true, get: function () { return array_1.unique; } }); | ||
var element_1 = require("./array/element"); | ||
@@ -19,0 +20,0 @@ Object.defineProperty(exports, "append", { enumerable: true, get: function () { return element_1.append; } }); |
@@ -12,2 +12,3 @@ import { Unary } from '@perfective/fp'; | ||
export declare function sorted<T>(array: T[], order?: Compare<T>): T[]; | ||
export declare function unique<T>(array: T[]): T[]; | ||
export declare function isArray<T, V = unknown>(value: T[] | V): value is T[]; | ||
@@ -14,0 +15,0 @@ export declare function isNotArray<T, V = unknown>(value: T[] | V): value is V; |
@@ -28,2 +28,5 @@ export function array(...elements) { | ||
} | ||
export function unique(array) { | ||
return array.filter((value, index, values) => index === values.indexOf(value)); | ||
} | ||
export function isArray(value) { | ||
@@ -30,0 +33,0 @@ return Array.isArray(value); |
@@ -1,2 +0,2 @@ | ||
export { array, arrayFromArrayLike, arrayFromIterable, concatenated, copy, flatten, isArray, isEmpty, isNotArray, isNotEmpty, length, reversed, sorted, } from './array/array'; | ||
export { array, arrayFromArrayLike, arrayFromIterable, concatenated, copy, flatten, isArray, isEmpty, isNotArray, isNotEmpty, length, reversed, sorted, unique, } from './array/array'; | ||
export { Element, append, element, first, head, insert, last, prepend, remove, replace, tail, } from './array/element'; | ||
@@ -3,0 +3,0 @@ export { Compare, Reducer, concat, copyWithin, entries, every, fill, filter, find, findIndex, forEach, includes, indexOf, join, keys, lastIndexOf, map, pop, push, reduce, reduceRight, reduceRightTo, reduceTo, reverse, shift, slice, some, sort, splice, spliceWith, unshift, values, } from './array/lift'; |
@@ -1,2 +0,2 @@ | ||
export { array, arrayFromArrayLike, arrayFromIterable, concatenated, copy, flatten, isArray, isEmpty, isNotArray, isNotEmpty, length, reversed, sorted, } from './array/array'; | ||
export { array, arrayFromArrayLike, arrayFromIterable, concatenated, copy, flatten, isArray, isEmpty, isNotArray, isNotEmpty, length, reversed, sorted, unique, } from './array/array'; | ||
export { append, element, first, head, insert, last, prepend, remove, replace, tail, } from './array/element'; | ||
@@ -3,0 +3,0 @@ export { concat, copyWithin, entries, every, fill, filter, find, findIndex, forEach, includes, indexOf, join, keys, lastIndexOf, map, pop, push, reduce, reduceRight, reduceRightTo, reduceTo, reverse, shift, slice, some, sort, splice, spliceWith, unshift, values, } from './array/lift'; |
{ | ||
"name": "@perfective/array", | ||
"version": "0.2.0-alpha.3", | ||
"version": "0.2.0-beta", | ||
"description": "Functions to work with the Array type", | ||
@@ -47,4 +47,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@perfective/real": "^0.4.0-alpha.2" | ||
"@perfective/real": "^0.4.0-beta" | ||
} | ||
} |
@@ -18,2 +18,4 @@ # Array | ||
— creates a shallow _sorted_ copy of an array | ||
* `unique<T>(array: T[]): T[]` | ||
— creates a shallow copy with all duplicate elements removed | ||
* Type guards: | ||
@@ -20,0 +22,0 @@ * `isArray<T, V = unknown>(value: T[] | V): value is T[]` |
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
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
75563
643
91