UNPKG

carbon-custom-elements

Version:

A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.

1 lines 2.84 kB
{"version":3,"sources":["globals/internal/collection-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,MAAM,gJAIuC,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,SAAS,iJAIuC,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,IAAI,8IAIuC,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,OAAO,+IAIuC,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,OAAO,yEAAyG,CAAC","file":"collection-helpers.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * @param a A DOM collection.\n * @param predicate The callback function.\n * @param [thisObject] The context object for the given callback function.\n * @returns A new array with all elements where `predicate` returns truthy.\n */\nexport const filter = (\n a: NodeListOf<Node> | HTMLCollectionOf<Element>,\n predicate: (search: Node, index?: number) => boolean,\n thisObject?: any\n) => Array.prototype.filter.call(a, predicate, thisObject);\n\n/**\n * @param a A DOM collection.\n * @param predicate The callback function.\n * @param [thisObject] The context object for the given callback function.\n * @returns The index of the first item in the given collection where `predicate` returns `true`. `-1` if no such item is found.\n */\nexport const findIndex = (\n a: NodeListOf<Node> | HTMLCollectionOf<Element>,\n predicate: (search: Node, index?: number) => boolean,\n thisObject?: any\n) => Array.prototype.findIndex.call(a, predicate, thisObject);\n\n/**\n * @param a A DOM collection.\n * @param predicate The callback function.\n * @param [thisObject] The context object for the given callback function.\n * @returns The first item in the given collection where `predicate` returns `true`. `null` if no such item is found.\n */\nexport const find = (\n a: NodeListOf<Node> | HTMLCollectionOf<Element>,\n predicate: (search: Node, index?: number) => boolean,\n thisObject?: any\n) => Array.prototype.find.call(a, predicate, thisObject);\n\n/**\n * Walks through the given DOM collection and runs the given callback.\n * @param a A DOM collection.\n * @param predicate The callback function.\n * @param [thisObject] The context object for the given callback function.\n */\nexport const forEach = (\n a: NodeListOf<Node> | HTMLCollectionOf<Element>,\n predicate: (search: Element, index?: number) => void,\n thisObject?: any\n) => Array.prototype.forEach.call(a, predicate, thisObject);\n\n/**\n * @param a A DOM collection.\n * @param item An item in the DOM collection.\n * @returns The index of the first occurence of the given item in the given collection. `-1` if no such item is found.\n */\nexport const indexOf = (a: NodeListOf<Node> | HTMLCollectionOf<Element>, item: Node) => Array.prototype.indexOf.call(a, item);\n"]}