Registry / crm-productivity / amp-index-of

amp-index-of

JSON →
library1.1.0jsnpmunverified

The `amp-index-of` package provides a lightweight utility function for arrays, serving as an `indexOf` implementation similar to `Array.prototype.indexOf`. It is a component of the Ampersand.js ecosystem, a modular, non-frameworky framework for client-side JavaScript applications, initially popular in the mid-2010s. The package is at version 1.1.0 and has not seen active development or releases for several years, aligning with the broader inactivity of the Ampersand.js project. Its original purpose was to offer a consistent array utility within the Ampersand.js environment. However, in modern JavaScript development, direct use of native `Array.prototype.indexOf` is preferred due to universal browser support and native performance. Therefore, `amp-index-of` is considered abandoned and primarily serves historical contexts or legacy applications built with Ampersand.js. Its release cadence was tied to the now-inactive Ampersand.js development cycle.

npm install amp-index-of
INSTALL
IMPORT
SIG · AMP-INDEX-OF
A
amp-index-of
crm-productivityjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

indexOf
const indexOf = require('amp-index-of');
import { indexOf } from 'amp-index-of';
This package is CommonJS-only and does not provide an ESM export. Attempting to use `import` syntax will result in a runtime error in ESM environments.
* as indexOf
const indexOf = require('amp-index-of');
import * as indexOf from 'amp-index-of';
Only the default CommonJS export is available. Named or namespace imports are not supported.

Demonstrates how to import and use the `amp-index-of` function to find the index of an element in an array using CommonJS syntax.

const indexOf = require('amp-index-of'); const myArray = ['apple', 'banana', 'orange', 'grape', 'banana']; // Find the first occurrence of 'banana' const firstIndex = indexOf(myArray, 'banana'); console.log(`First 'banana' found at index: ${firstIndex}`); // Expected: 1 // Find an element that does not exist const notFoundIndex = indexOf(myArray, 'kiwi'); console.log(`'kiwi' found at index: ${notFoundIndex}`); // Expected: -1 // Demonstrating behavior similar to Array.prototype.indexOf const anotherArray = [10, 20, 30, 10, 40]; console.log(`Native indexOf of 10: ${anotherArray.indexOf(10)}`); // Expected: 0 console.log(`amp-index-of of 10: ${indexOf(anotherArray, 10)}`); // Expected: 0
Debug
Known issues
breakingThis package is part of the deprecated Ampersand.js ecosystem and is no longer actively maintained. No further updates, bug fixes, or security patches are expected. Consider migrating to native `Array.prototype.indexOf`.
fix
Replace `require('amp-index-of')(arr, val)` with `arr.indexOf(val)` in modern JavaScript environments.
affects: >=1.1.0
gotchaThe package is CommonJS-only. Using ES Module `import` syntax directly will cause a runtime error (`require is not defined` or similar) in environments configured for ESM.
fix
Ensure you are using CommonJS `require()` syntax for importing this package, or transpile your code if working in an ESM-first project.
affects: >=1.0.0
gotchaThis package provides identical functionality to the native `Array.prototype.indexOf` method, which is universally supported in modern browsers and Node.js. Using the native method avoids an unnecessary dependency.
fix
Prefer `Array.prototype.indexOf()` directly, e.g., `myArray.indexOf('element')`.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in an ES Module context without proper transpilation or configuration.
fix
If running in an ESM environment (e.g., Node.js with `"type": "module"` in package.json), you may need to use a CommonJS wrapper or switch to native `Array.prototype.indexOf`.
TypeError: indexOf is not a function
Incorrect import of the `amp-index-of` function, or the module being used incorrectly after import.
fix
Ensure you are using `const indexOf = require('amp-index-of');` and then calling `indexOf(myArray, item)`.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
58 hits · last 30 days
node
51
Perplexity
1
Resources
amp-index-of — npm install amp-index-of · libregistry