• Stars
    star
    204
  • Rank 192,063 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node core modules for React Native

node-libs-react-native

This package provides React Native compatible implementations of Node core modules like stream and http. This is a fork of node-libs-browser with a few packages swapped to be compatible in React Native.

Installation

npm install --save node-libs-react-native

Usage

This package exports a mapping of absolute paths to each module implementation, keyed by module name. Modules without React Native compatible implementations are null.

These modules can be used with React Native Packager's metro.config.js or Webpack's resolve.alias.

Usage with React Native Packager

Add a metro.config.js file in the root directory of your React Native project and set resolver.extraNodeModules:

// metro.config.js
module.exports = {
  resolver: {
    extraNodeModules: require('node-libs-react-native'),
  },
};

For more information, see this post on Node core modules in React Native.

Globals

Node has certain globals that modules may expect, such as Buffer or process. React Native does not provide these globals. The node-libs-react-native/globals module in this package will shim the global environment to add these globals. Just require (or import) this module in your app before anything else.

require('node-libs-react-native/globals');
// ...
require('./app.js');

Modules

The following are the module implementations provided by this package. Some modules also have a "mock" implementation provided in the mock directory. These are replacements with minimal functionality.

Module RN-compatible Mock
assert defunctzombie/commonjs-assert ---
buffer feross/buffer buffer.js
child_process --- ---
cluster --- ---
console Raynos/console-browserify console.js
constants juliangruber/constants-browserify ---
crypto mvayngrib/react-native-crypto ---
dgram --- ---
dns --- dns.js
domain bevry/domain-browser ---
events Gozala/events ---
fs --- ---
http jhiesey/stream-http ---
https substack/https-browserify ---
module --- ---
net --- net.js
os CoderPuppy/os-browserify ---
path substack/path-browserify ---
process shtylman/node-process process.js
punycode bestiejs/punycode.js ---
querystring mike-spainhower/querystring ---
readline --- ---
repl --- ---
stream nodejs/readable-stream ---
string_decoder rvagg/string_decoder ---
sys defunctzombie/node-util ---
timers jryans/timers-browserify ---
tls --- tls.js
tty substack/tty-browserify tty.js
url defunctzombie/node-url ---
util defunctzombie/node-util ---
vm --- vm.js
zlib devongovett/browserify-zlib ---

Other React Native Modules

These are other React Native packages that implement Node core related modules. They are not included in node-libs-react-native, but you may find them useful separately.

dgram

react-native-udp implements Node's dgram API, but is not included here due to its native implementation and need to use react-native link.

fs

react-native-fs implement's Node's fs API, but is not included here due to its native implementation and need to use react-native link.

react-native-level-fs provides an alternative pure JavaScript implementation, using AsyncStorage as the underlying storage mechanism.

net

react-native-tcp implement's Node's net API, but is not included here due to its native implementation and need to use react-native link.

Credit

This is a fork of node-libs-browser with minor modifications and packages swapped out for React Native implementations. Thanks to those package authors for doing the hard work.

License

MIT

More Repositories

1

node-sanitize-filename

Sanitize string for use as filename
JavaScript
337
star
2

node-ffmetadata

Read and write media metadata using ffmpeg
JavaScript
123
star
3

check-node-version

Check installed versions of node and npm
JavaScript
75
star
4

node-fpcalc

Calculate AcoustID audio fingerprint
JavaScript
68
star
5

css-eliminator

CSS dead code elimination
CSS
43
star
6

vtree-select

Select virtual-dom nodes using css selectors
JavaScript
31
star
7

node-acoustid

Get music metadata from AcoustID web service
JavaScript
28
star
8

node-stream-reduce

Reduce stream data to a single value
JavaScript
20
star
9

js-opc

Open Pixel Control protocol
JavaScript
16
star
10

truncate-utf8-bytes

Truncate string to length in bytes
JavaScript
15
star
11

js-is-integer

ES2015 (ES6) Number.isInteger polyfill
JavaScript
12
star
12

html-linkify

Turn plain text links into safe HTML anchor elements
JavaScript
11
star
13

html-escape

Escape string to be safe for use in html
JavaScript
7
star
14

nextcaltrain

Find the next Caltrain
JavaScript
7
star
15

music-organizer

Automated music metadata using MusicBrainz data
JavaScript
7
star
16

utf8-byte-length

Get byte length of utf8 string
JavaScript
5
star
17

node-stream-filter

Filter stream data
JavaScript
5
star
18

opc-simulator

Web-based Open Pixel Control simulator
JavaScript
5
star
19

nextcaltrain.com

Caltrain schedule web application
JavaScript
4
star
20

immutable-to-js

Convert immutable-js value to regular js value
JavaScript
4
star
21

spheron-accel

Stream accelerometer data from your Sphero
JavaScript
3
star
22

js-multi-compare

Compose array sort compare functions
JavaScript
3
star
23

window-scroll

Polyfill for window.scrollX and window.scrollY
JavaScript
3
star
24

devbox

Automated development machine configuration
Shell
2
star
25

bunyan-express-serializer

Bunyan serializer for Express objects
JavaScript
2
star
26

search-requires

Find require() calls to a given module
JavaScript
2
star
27

simple-passport

Minimal implementation of the PassportJS interface
JavaScript
2
star
28

boxjump

Multiplayer html5 game
CoffeeScript
2
star
29

js-map-values

Map object values, return a new object
JavaScript
2
star
30

map-stream-limit

Like map-stream but with concurrency limit
JavaScript
2
star
31

http-route

Functional HTTP routing
JavaScript
2
star
32

format-json-log

Human-readable json logs
JavaScript
1
star
33

set-input-value

Set input value and keep cursor position
JavaScript
1
star
34

jQuery-insertAt

Insert content as n-th child of element
JavaScript
1
star
35

data-uri-stream

Transform stream to create a data uri
JavaScript
1
star
36

node-stream-buffer

Buffer a stream and replay data at any time
JavaScript
1
star
37

dotfiles

My personal dotfiles
Shell
1
star
38

parse-binary-stream

Parse n-byte chunks from a binary stream
JavaScript
1
star
39

tote

Real-time networked 3D fighting game using Python and OGRE
Python
1
star
40

pageinfo

Get information (title, images, etc.) about a HTML document
JavaScript
1
star