Buffer-shims is a JavaScript utility, currently at version 1.0.0, designed to provide polyfills for modern Node.js `Buffer` constructor methods like `Buffer.from`, `Buffer.alloc`, `Buffer.allocUnsafe`, and `Buffer.allocUnsafeSlow` in older Node.js environments and browsers. Released around 2014-2017 and last updated on npm about 7 years ago, its primary purpose was to bridge compatibility gaps before these methods became standard. The package does not patch the global `Buffer` object but exposes these methods via its own export. With modern Node.js versions and widely adopted browser standards, the need for this specific shim has largely diminished, making it mostly obsolete for new development.
npm install buffer-shimsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the `buffer-shims` module to create various types of buffers using its shims for `Buffer.from`, `alloc`, `allocUnsafe`, and `allocUnsafeSlow`.
Remove `buffer-shims` and use native `Buffer.from()`, `Buffer.alloc()`, etc., directly. Ensure your target environments support these methods or use a more comprehensive polyfill if targeting extremely old, unsupported runtimes.
Always invoke the methods on the object returned by `require('buffer-shims')`, e.g., `bufferShim.from('data')`, not `Buffer.from('data')`.Migrate to native Node.js `Buffer` APIs or an actively maintained, purpose-built polyfill if supporting extremely old environments is still a strict requirement. For most cases, simply remove this dependency.
Access the `from` method via the imported `bufferShim` object: `const bufferShim = require('buffer-shims'); bufferShim.from('data');`For browser environments, consider using a full `buffer` polyfill (e.g., from `buffer` npm package often bundled by tools like Browserify or Webpack) if global `Buffer` is required, or ensure your build tool handles Node.js `Buffer` APIs for browser compatibility.
No dependency data recorded yet.