New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dhau/lang

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dhau/lang - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

dist/array/position.d.ts

3

dist/array/find.d.ts

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

declare function findOnlyIndex<T>(array: ReadonlyArray<T>, predicate: (item: T) => boolean, message?: string): number;
declare function findOnly<T>(array: ReadonlyArray<T>, predicate: (item: T) => boolean, message?: string): T;
export { findOnly };
export { findOnlyIndex, findOnly };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findOnly = void 0;
function findOnly(array, predicate, message) {
const found = array.filter(predicate);
if (found.length !== 1) {
throw new Error(message !== null && message !== void 0 ? message : `Expected exactly one item, found ${found.length}`);
exports.findOnly = exports.findOnlyIndex = void 0;
function findOnlyIndex(array, predicate, message) {
let foundIndex;
for (let i = 0; i < array.length; i++) {
if (predicate(array[i])) {
if (foundIndex !== undefined) {
throw new Error(message !== null && message !== void 0 ? message : `Expected exactly one item, found more than 1`);
}
foundIndex = i;
}
}
return found[0];
if (foundIndex === undefined) {
throw new Error(message !== null && message !== void 0 ? message : `Expected exactly one item, found 0`);
}
return foundIndex;
}
exports.findOnlyIndex = findOnlyIndex;
function findOnly(array, predicate, message) {
const index = findOnlyIndex(array, predicate, message);
return array[index];
}
exports.findOnly = findOnly;
export * from "./error/caught-result";
export * from "./array/find";
export * from "./array/position";
export * from "./number/format";

@@ -19,2 +19,3 @@ "use strict";

__exportStar(require("./array/find"), exports);
__exportStar(require("./array/position"), exports);
__exportStar(require("./number/format"), exports);
{
"name": "@dhau/lang",
"version": "0.0.8",
"version": "0.0.9",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Various language extensions for JS",

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