Socket
Socket
Sign inDemoInstall

monologue

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monologue - npm Package Compare versions

Comparing version 0.7.3 to 0.7.4

85

monologue.js
(function(exports) {
"use strict";
function condition(cond, sep, part) {
sep = ( typeof sep === "undefined" ? "AND" : sep );
sep = ( sep.length > 0 ? " " + sep + " " : sep );
if( cond instanceof Array && Object(cond[0]) === cond[0] ) {
cond.forEach(function(v, k, arr) {
arr[k] = this.stringify( v ).join(' AND ');
}.bind(this));
// join an array of objects with OR
cond = '(' + cond.join(' OR ') + ')';
// cond = cond.join(' OR ')
// cond = `(${cond})`;
}
else if( cond instanceof Array ) {
cond = cond.join(' OR ');
}
else if( cond === Object(cond) ) {
// stringify the where statements
cond = this.stringify( cond ).join( sep );
}
part = ( part.length > 0 ? part + sep + cond : cond );
return part;
}
function monologue(opt) {

@@ -27,4 +57,5 @@ return new Monologue(opt);

// store whether where() or having() was used last
// default is "where" (presumably used more often)
// (I hope this doesn't get ugly)
this.last_condition = null;
this.last_condition = this.where;

@@ -88,3 +119,3 @@ // set the inital parts container

Monologue.prototype.join = function join( dir, tbl, stmt ) {
// default to inner join if unspecified (parity with mysql)
// default to inner join if not specified (parity with mysql)
if( typeof stmt === "undefined" ) {

@@ -138,6 +169,6 @@ stmt = tbl;

/**
* t: table, p: params
* t: table, p: params, d: data
*/
Monologue.prototype.insert = function insert( tbl, p ) {
Monologue.prototype.insert = function insert( tbl, p, d ) {
var col = '';

@@ -149,4 +180,14 @@

// I don't know why this would ever NOT be the case
if( typeof p === "object" ) {
if( p instanceof Array && d instanceof Array ) {
var p = this.backquote( p ).join(',');
var d = this.stringify( d, "");
// stringify should be refactored a bit so this isn't necessary
d.shift();
d = d.join(',');
col = "(" + p + ") VALUES " + d;
}
// Array is also an object
else if( typeof p === "object" ) {
// if it's not a nested array, cheat and make it one

@@ -248,32 +289,2 @@ if( ! ( p instanceof Array ) ) {

function condition(cond, sep, part) {
sep = ( typeof sep === "undefined" ? "AND" : sep );
sep = ( sep.length > 0 ? " " + sep + " " : sep );
if( cond instanceof Array && Object(cond[0]) === cond[0] ) {
cond.forEach(function(v, k, arr) {
arr[k] = this.stringify( v ).join(' AND ');
}.bind(this));
// join an array of objects with OR
cond = '(' + cond.join(' OR ') + ')';
// cond = cond.join(' OR ')
// cond = `(${cond})`;
}
else if( cond instanceof Array ) {
cond = cond.join(' OR ');
}
else if( cond === Object(cond) ) {
// stringify the where statements
cond = this.stringify( cond ).join( sep );
}
part = ( part.length > 0 ? part + sep + cond : cond );
return part;
};
Monologue.prototype.and = function and( wh ) {

@@ -458,4 +469,2 @@ return this.where( wh, 'AND' );

this.last_condition = this.last_condition || this.where;
if( p instanceof Array && Object(p[0]) === p[0] ) {

@@ -462,0 +471,0 @@ sep = sep.trim();

{
"name": "monologue",
"version": "0.7.3",
"version": "0.7.4",
"description": "Streamlined MySQL query building",

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

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