Skip to content

Commit

Permalink
Merge pull request #2 from yonivy/support-node-v20
Browse files Browse the repository at this point in the history
[PAN-3058] Support node v20
  • Loading branch information
yonivy authored Jan 4, 2024
2 parents 7e4fff3 + b4c8ccb commit 57f3077
Show file tree
Hide file tree
Showing 5 changed files with 1,035 additions and 231 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: 'npm'

- run: npm ci

- run: npm test
54 changes: 27 additions & 27 deletions dbstream.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
var stream = require( "stream" );
var util = require( "util" );
const stream = require("stream");
const util = require("util");

// Functional API
util.inherits( Cursor, stream.Duplex );
function Cursor () {
Cursor.super_.call( this, { objectMode: true } );
util.inherits(Cursor, stream.Duplex);
function Cursor() {
Cursor.super_.call(this, { objectMode: true });
}

Cursor.prototype._save = function ( obj, callback ) {
throw new Error( "_save is not implemented" );
Cursor.prototype._save = function (obj, callback) {
throw new Error("_save is not implemented");
}

Cursor.prototype._remove = function ( obj, callback ) {
throw new Error( "_remove is not implemented" );
Cursor.prototype._remove = function (obj, callback) {
throw new Error("_remove is not implemented");
}

Cursor.prototype._load = function ( size ) {
throw new Error( "_load is not implemented" );
Cursor.prototype._load = function (size) {
throw new Error("_load is not implemented");
}

Cursor.prototype.remove = function ( chunk, encoding, callback ) {
return this.write( { $remove: chunk }, encoding, callback );
Cursor.prototype.remove = function (chunk, encoding, callback) {
return this.write({ $remove: chunk }, encoding, callback);
}

Cursor.prototype._read = function ( size ) {
if ( !this._query ) return this.push( null ); // nothing to query
return this._load( size );
Cursor.prototype._read = function (size) {
if (!this._query) return this.push(null); // nothing to query
return this._load(size);
}

Cursor.prototype._write = function ( chunk, encoding, callback ) {
return ( chunk.$remove )
? this._remove( chunk.$remove, callback )
: this._save( chunk, callback );
Cursor.prototype._write = function (chunk, encoding, callback) {
return (chunk.$remove)
? this._remove(chunk.$remove, callback)
: this._save(chunk, callback);
}

// Query API
Cursor.prototype.find = function ( query ) {
Cursor.prototype.find = function (query) {
this._query = query;
return this;
}

Cursor.prototype.sort = function ( key, direction ) {
this._sort || ( this._sort = [] );
this._sort.push( { key: key, direction: direction || 1 });
Cursor.prototype.sort = function (key, direction) {
this._sort || (this._sort = []);
this._sort.push({ key: key, direction: direction || 1 });
return this;
}

Cursor.prototype.skip = function ( n ) {
Cursor.prototype.skip = function (n) {
this._skip = n;
return this;
}

Cursor.prototype.limit = function ( n ) {
Cursor.prototype.limit = function (n) {
this._limit = n;
return this;
}

Cursor.prototype.copy = function(other) {
Cursor.prototype.copy = function (other) {
this._query = other._query
this._sort = other._sort
this._skip = other._skip
Expand Down
Loading

0 comments on commit 57f3077

Please sign in to comment.