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

mysql-live-select

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-live-select - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

15

lib/LiveMysqlSelect.js

@@ -78,8 +78,13 @@ /* mysql-live-select, MIT License ben@latenightsketches.com

if(!self.base.settings.skipDiff){
var diff = [];
var diffEvent = function(){
self.emit.apply(self, arguments);
diff.push(Array.prototype.slice.call(arguments));
}
rows.forEach(function(row, index){
if(self.data.length - 1 < index){
self.emit('added', row, index);
diffEvent('added', row, index);
self.data[index] = row;
}else if(JSON.stringify(self.data[index]) !== JSON.stringify(row)){
self.emit('changed', self.data[index], row, index);
diffEvent('changed', self.data[index], row, index);
self.data[index] = row;

@@ -90,6 +95,10 @@ }

for(var i = self.data.length - 1; i >= rows.length; i--){
self.emit('removed', self.data[i], i);
diffEvent('removed', self.data[i], i);
}
self.data.splice(rows.length, self.data.length - rows.length);
}
if(diff.length !== 0){
// Output all difference events in a single event
self.emit('diff', diff);
}
}

@@ -96,0 +105,0 @@

2

package.json
{
"name": "mysql-live-select",
"version": "0.0.8",
"version": "0.0.9",
"description": "Live updating MySQL SELECT statements",

@@ -5,0 +5,0 @@ "main": "lib/LiveMysql.js",

@@ -7,2 +7,5 @@ # mysql-live-select

* [Example Application using Express, SockJS and React](https://github.com/numtel/reactive-mysql-example)
* [Meteor package for reactive MySQL](https://github.com/numtel/meteor-mysql)
## Installation

@@ -123,2 +126,3 @@

`removed` | `row`, `index` | Row removed at index
`diff` | `diff` | Aggregation of `added`, `changed`, `removed` events for current event into a single array for easier handling of multiple changes
`error` | `error` | Unhandled errors will be thrown

@@ -125,0 +129,0 @@

@@ -50,2 +50,19 @@ /* mysql-live-select, MIT License ben@latenightsketches.com

test.equal(row.col, 15);
}).on('diff', function(diff){
// Only one row will change at once
test.equal(diff.length, 1);
// Index will always be 0, the first item
test.equal(diff[0][diff[0].length - 1], 0);
switch(diff[0][0]){
case 'added':
test.equal(diff[0][1].col, 10);
break;
case 'changed':
test.equal(diff[0][1].col, 10);
test.equal(diff[0][2].col, 15);
break;
case 'added':
test.equal(diff[0][1].col, 15);
break;
}
});

@@ -52,0 +69,0 @@

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