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

tarry

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tarry - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

18

index.d.ts
/**
Push each item in `items` onto the end of `array`.
Uses `Array#push`.
@param {Array} array: the array to extend with new items
@param {Array} items: array of new items
Similar to:
target = target.concat(items);
Calls Array#push with Function.apply to unpack a single input array into
multiple arguments.
Equivalent to `array.push(...items)`
*/

@@ -10,3 +20,4 @@ export declare function pushAll<T>(array: T[], items: T[]): void;

Uses `Array#concat`.
Uses `Array#concat` with Function.apply to unpack the given array into a bunch
of arrays, combining them all into a newly created array. Not recursive.
*/

@@ -117,1 +128,4 @@ export declare function flatten<T>(arrays: T[][]): T[];

export declare function groups<T>(items: T[], size: number): T[][];
export declare function assign<T, U>(target: T, source: U): T & U;
export declare function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
export declare function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
Push each item in `items` onto the end of `array`.
Uses `Array#push`.
@param {Array} array: the array to extend with new items
@param {Array} items: array of new items
Similar to:
target = target.concat(items);
Calls Array#push with Function.apply to unpack a single input array into
multiple arguments.
Equivalent to `array.push(...items)`
*/

@@ -13,3 +23,4 @@ function pushAll(array, items) {

Uses `Array#concat`.
Uses `Array#concat` with Function.apply to unpack the given array into a bunch
of arrays, combining them all into a newly created array. Not recursive.
*/

@@ -102,9 +113,10 @@ function flatten(arrays) {

function median(xs) {
var sorted_xs = xs.slice(0).sort();
var middle = sorted_xs.length / 2;
// sort without a predicate does lexicographic sort
xs = xs.slice(0).sort(function (a, b) { return a - b; });
// if xs is even, average the two middle items
if (sorted_xs.length % 2 === 0) {
return (sorted_xs[middle - 1] + sorted_xs[middle]) / 2.0;
if (xs.length % 2 === 0) {
var middle = xs.length / 2;
return (xs[middle - 1] + xs[middle]) / 2.0;
}
return sorted_xs[middle - 0.5];
return xs[(xs.length - 1) / 2];
}

@@ -202,1 +214,25 @@ exports.median = median;

exports.groups = groups;
/**
Copy each source's own enumerable properties into the target object.
@param {Object} target - The target object to copy into.
@param {Object[]} sources - One or more source objects from which to copy enumerable properties.
@returns {Object} - Returns the target object.
*/
function assign(target) {
var sources = [];
for (var _i = 1; _i < arguments.length; _i++) {
sources[_i - 1] = arguments[_i];
}
if (target === null || target === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
target = Object(target);
sources.forEach(function (source) {
Object.keys(source).forEach(function (key) {
target[key] = source[key];
});
});
return target;
}
exports.assign = assign;
{
"name": "tarry",
"version": "0.1.1",
"version": "0.2.0",
"description": "Utility library for manipulating JavaScript Arrays",

@@ -19,4 +19,9 @@ "keywords": [

"devDependencies": {
"babel-core": "^5.0.0",
"coveralls": "*",
"istanbul": "*",
"mocha": "*",
"mocha-lcov-reporter": "*",
"typescript": "next"
}
}
# tarry
[![npm version](https://badge.fury.io/js/tarry.svg)](https://www.npmjs.com/package/tarry)
[![Travis CI Build Status](https://travis-ci.org/chbrown/tarry.svg)](https://travis-ci.org/chbrown/tarry)
[![Coverage Status](https://coveralls.io/repos/chbrown/tarry/badge.svg)](https://coveralls.io/github/chbrown/tarry)
npm install --save tarry

@@ -4,0 +8,0 @@

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