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

co-rethinkdb

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-rethinkdb - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

39

index.js

@@ -0,8 +1,40 @@

// When installing co-rethinkdb for an application that uses the same version
// of rethinkdb, they share the same installation of rethinkdb:
// - your application
// |- node_modules
// |- rethinkdb
// |- co-rethinkdb
// |- * no node_modules/rethinkdb because it uses the parent one
//
// Therefore, the following workaround is used to not overwrite the parents
// rethinkdb behavior.
var toReset = ['rethinkdb', 'rethinkdb/ast', 'rethinkdb/net', 'rethinkdb/cursor'].map(function(name) {
return require.resolve(name)
})
// remove parts of rethinkdb from cache
var cache = toReset.map(function(path) {
var cache = require.cache[path]
delete require.cache[path]
return cache
})
var r = require('rethinkdb')
, co = require('co')
// restore cache
toReset.forEach(function(path, i) {
require.cache[path] = cache[i]
})
var co = require('co')
// Object, most of rethinkdb's objects inherit from
var RDBOp = r.table('mock').constructor.__super__.constructor
// the original run method
var run = RDBOp.prototype.run
// Since every rethinkdb method call, e.g., r.table('...') retuns a
// function, `co` is going to call their `.call()` method making it
// the perfect place to execute the `.run()` method instead.
RDBOp.prototype.call = function(_, done) {

@@ -16,2 +48,3 @@ var query = this

// Wrap the original `.run()` method.
RDBOp.prototype.run = function(conn) {

@@ -24,2 +57,3 @@ var query = this

// Wrap the original `.connect()` method.
var connect = r.connect

@@ -32,2 +66,3 @@ r.connect = function(opts) {

// Wrap the original `.next()` method.
var next = Cursor.prototype.next

@@ -38,2 +73,3 @@ Cursor.prototype.next = function() {

// Wrap the original `.each()` method.
var each = Cursor.prototype.each

@@ -45,2 +81,3 @@ Cursor.prototype.each = function(cb) {

// Wrap the original `.toArray()` method.
var toArray = Cursor.prototype.toArray

@@ -47,0 +84,0 @@ Cursor.prototype.toArray = function() {

2

package.json
{
"name": "co-rethinkdb",
"version": "0.1.1",
"version": "0.2.0",
"author": "Markus Ast <npm.m@rkusa.st>",

@@ -5,0 +5,0 @@ "description": "Generator based querying goodness for RethinkDB",

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