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

@hdsydsvenskan/utils

Package Overview
Dependencies
Maintainers
12
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hdsydsvenskan/utils - npm Package Compare versions

Comparing version 4.16.0 to 4.17.0

2

lib/array.d.ts

@@ -0,1 +1,2 @@

export type MaybeArray<T> = T | T[];
export function bisectLeft(sortedArray: number[], value: number): number;

@@ -6,1 +7,2 @@ export function bisectRight(sortedArray: number[], value: number): number;

export function arrayZip<T, U>(arr1: T[], arr2: U[]): [T, U][];
export function ensureArray<T>(value: T | T[]): T[];

@@ -108,2 +108,14 @@ // @ts-check

/**
* @template T
* @typedef {T|T[]} MaybeArray
*/
/**
* @template T
* @param {MaybeArray<T>} value
* @returns {T[]}
*/
const ensureArray = (value) => Array.isArray(value) ? value : (value === undefined ? [] : [value]);
module.exports = {

@@ -114,3 +126,4 @@ bisectLeft,

arrayIntersect,
arrayZip
arrayZip,
ensureArray
};

@@ -164,2 +164,3 @@ export type CacheStore = import("./types").BasicCacheStore & import("./types").CacheStoreExtras;

export const bisectRight: (sortedArray: number[], value: number) => number;
export const ensureArray: <T>(value: T | T[]) => T[];
export const insort: (sortedArray: number[], value: number) => number[];

@@ -166,0 +167,0 @@ export const inlineTemplateTag: (strings: TemplateStringsArray, ...values: (string | number)[]) => string;

@@ -27,2 +27,3 @@ // @ts-check

bisectRight,
ensureArray,
insort

@@ -190,2 +191,3 @@ } = require('./array');

bisectRight,
ensureArray,
insort,

@@ -192,0 +194,0 @@

16

package.json
{
"name": "@hdsydsvenskan/utils",
"version": "4.16.0",
"version": "4.17.0",
"license": "UNLICENSED",

@@ -49,3 +49,5 @@ "description": "Misc utility methods that's useful for our sites",

"@azure/abort-controller": "^1.0.0-preview.1",
"@hdsydsvenskan/eslint-config-hds": "^17.0.0",
"@hdsydsvenskan/eslint-config-hds": "^19.0.0",
"@hdsydsvenskan/eslint-config-hds-core": "^1.0.0",
"@hdsydsvenskan/eslint-config-hds-typescript": "^1.0.0",
"@types/chai": "^4.2.6",

@@ -57,3 +59,3 @@ "@types/chai-as-promised": "^7.1.2",

"@types/sinon-chai": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.24.0",

@@ -64,7 +66,7 @@ "chai": "^4.1.2",

"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard-with-typescript": "^15.0.0",
"eslint-config-standard": "^14.1.1",
"eslint-config-standard-with-typescript": "^15.0.1",
"eslint-plugin-es": "^3.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsdoc": "^22.0.0",
"eslint-plugin-jsdoc": "^22.1.0",
"eslint-plugin-mocha": "^6.2.2",

@@ -75,3 +77,3 @@ "eslint-plugin-node": "^11.0.0",

"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-unicorn": "^16.1.1",
"eslint-plugin-unicorn": "^17.2.0",
"husky": "^4.0.0",

@@ -78,0 +80,0 @@ "installed-check": "^3.0.0",

@@ -33,3 +33,2 @@ # Utils

* `recursiveObjectFilter(obj, [callback(value, key, i)])` – like `objectFilter()`, but better, since this one is recursive 💪
* `arrayIntersect(firstArray, secondArray)` – returns `true` or `false` dependening whether the two arrays intersect or not.
* `applyToDefaults(defaults, data)` – applies `data` to `defaults`. Mimicks the `applyToDefaults` from Hoek.

@@ -45,2 +44,11 @@ * `deepClone(obj)` – recursively clones `obj` and all objects and arrays it contains. `obj` should be either an object or an array.

### Array helpers
* `arrayIntersect(firstArray, secondArray)` – returns `true` or `false` dependening whether the two arrays intersect or not.
* `arrayZip(firstArray, secondArray)` – zips two arrays of the same length into one
* `bisectLeft(sortedArray, value)` – find the left-most index of a sorted array where a value can be inserted while maintaining sorted order
* `bisectRight(sortedArray, value)` – Similar to `bisectLeft`, but finds the right-most index instead.
* `ensureArray(maybeArray)` – always returns an array, either the array input, the input wrapped as an array, or if the input is `undefined`, then an empty array
* `insort(sortedArray, value)` – creates a new sorted array with the value inserted at the correct index
### Promise helpers

@@ -47,0 +55,0 @@

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