Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cbor-rn-prereqs

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor-rn-prereqs

React Native pre-requisites for cbor

  • 10.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
258
increased by77.93%
Maintainers
0
Weekly downloads
 
Created
Source

cbor-rn-prereqs

Make it easier to use the cbor package in React Native.

MOVE TO CBOR2

NOTE

All users of this library should move to the cbor2 library. It is where most maintenance and support and all new features are happening. This set of workarounds has always been lightly-maintained, since React Native's JS implementation is... not that similar to other modern runtimes.

Only catastrophic bugs will be fixed in this library going forward.

Installation:

$ npm install --save cbor cbor-rn-prereqs

Ensure you have a file named metro.config.js in your project root, and that it contains at least this:

module.exports = {
  resolver: {
    extraNodeModules: {
      stream: require.resolve('stream-browserify'),
    },
  },
};

require this package before importing or requiring cbor:

require('cbor-rn-prereqs');
const cbor = require('cbor');

What this does

This package bundles up a few additions to the JavaScript-like environment that React Native provides. In particular:

  • BigInt support using big-integer, which gets installed globally if React Native's version of JSC is too old to have BigInt support. IMO, this is fixing a React Native bug.
  • process.nextTick() from process. If there is no process in your environment, all of the process package gets installed globally. If there is, but it doesn't have nextTick, just nextTick will be added to the existing global process instance.
  • A small and non-full-featured implementation of TextDecoder from @cto.af/textdecoder, which gets installed globally. IMO this is also a React Native bug.
  • A few dependencies that replace functionality available in node, from buffer, events, and stream-browserify

stream-browserify needs to be made available when packages do require('stream'), which is enabled by the metro.config.js change above.

Keywords

FAQs

Package last updated on 06 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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