RaptorJS Utilities
This library, `raptor-util`, is a collection of core utility functions designed for the RaptorJS framework, an end-to-end JavaScript toolkit initially developed by eBay for building adaptive modules and UI components. The package provides various common helpers, likely including object manipulation, type checking, and other foundational utilities to support the broader RaptorJS ecosystem. The current version is 3.2.0. However, the RaptorJS framework and its associated packages, including `raptor-util`, appear to be abandoned, with the last notable activity around 2017 and related npm packages last published around 2014-2015. It is no longer actively maintained or developed, making it unsuitable for new projects.
Common errors
-
ReferenceError: require is not defined
cause Attempting to use `require()` in an ECMAScript Module (ESM) context (e.g., in a `.mjs` file or when `"type": "module"` is set in `package.json`).fixThis package is designed for CommonJS. You either need to run your code in a CommonJS environment or configure a bundler to handle CommonJS modules within an ESM project. Direct ESM `import` statements for `raptor-util` are unlikely to work without extensive build tooling. -
TypeError: Cannot destructure property 'someFunction' of require(...) as it is undefined.
cause Attempting to import a function that does not exist or has a different name than expected from the `raptor-util` module.fixDouble-check the exact export names of the utility functions you intend to use. Without official documentation, this may require inspecting the package's source code if you truly need to use it. Many common utility functions have standard names, but this package's specific exports are not publicly documented.
Warnings
- breaking The `raptor-util` package and the broader RaptorJS framework are abandoned. The last activity on the GitHub repository was in 2017, and related npm packages were last published in 2014-2015. It is not maintained and may contain unpatched vulnerabilities or incompatibilities with modern JavaScript runtimes.
- gotcha `raptor-util` was developed primarily for CommonJS environments (Node.js versions prevalent before 2017). Using it in modern ESM-only projects or environments without proper transpilation/bundling can lead to 'require is not defined' errors or other module resolution failures.
- gotcha This library does not ship with TypeScript type definitions. Using it in a TypeScript project will require manually creating declaration files (e.g., `raptor-util.d.ts`) to provide type safety and avoid compiler errors.
Install
-
npm install raptor-util -
yarn add raptor-util -
pnpm add raptor-util
Imports
- extend
import { extend } from 'raptor-util';const { extend } = require('raptor-util'); - isObject
const isObject = require('raptor-util').isObject;const { isObject } = require('raptor-util'); - forEach
import forEach from 'raptor-util';
const { forEach } = require('raptor-util');
Quickstart
const { extend, isObject, forEach } = require('raptor-util');
// Example: Extending an object
const obj1 = { a: 1, b: 2 };
const obj2 = { b: 3, c: 4 };
const merged = extend({}, obj1, obj2);
console.log('Extended object:', merged); // Expected: { a: 1, b: 3, c: 4 }
// Example: Checking if a variable is an object
console.log('Is {}:', isObject({})); // Expected: true
console.log('Is null:', isObject(null)); // Expected: false
// Example: Iterating over an array or object
const items = ['apple', 'banana', 'cherry'];
console.log('Iterating over items:');
forEach(items, (item, index) => {
console.log(` ${index}: ${item}`);
});
const data = { name: 'Alice', age: 30 };
console.log('Iterating over data:');
forEach(data, (value, key) => {
console.log(` ${key}: ${value}`);
});