Comparing version 0.1.14 to 0.1.15
39
mql.js
@@ -28,2 +28,4 @@ import { | ||
const minBy = (f, arr) => arr.reduce((a, b) => f(a) <= f(b) ? a : b); | ||
const cmap = curry((f, arr) => Promise.all(arr.map(f))); | ||
@@ -86,4 +88,36 @@ const uniq_index_by = curry((f, coll) => index_by(f, uniqueBy(f, coll))); | ||
function ASSOCIATE_MODULE(strs, ...tails) { | ||
var [strs2, tails2] = import_module(strs, tails); | ||
const splited = flatten(strs.map(str => str.split('\n'))) | ||
.filter(str => str.match(/^\s*/)[0]) | ||
.filter(str => str.trim()); | ||
const min = minBy(str => str.match(/^\s*/)[0].length, splited); | ||
const a = '\n' + min.match(/^\s*/)[0]; | ||
return [strs2.map(str => str.split(a).join('\n')), tails2]; | ||
} | ||
function import_module(strs, tails) { | ||
if (!tails.some(tail => typeof tail == 'function' && !is_tag(tail))) return [strs, tails]; | ||
var strs2 = [...strs]; | ||
var j = 0; | ||
var tails2 = tails.map(function(tail, i) { | ||
if (typeof tail != 'function' || is_tag(tail)) return tail; | ||
var k = i + j++; | ||
var spaces = last(strs2[k].split('\n')).match(/^\s*/)[0]; | ||
var [strs3, tails3] = tail(); | ||
strs2.splice(k+1, 0, strs3.map(str => str.replace(/\n/g, '\n' + spaces))); | ||
return tails3; | ||
}); | ||
return [flatten(strs2), flatten(tails2)]; | ||
} | ||
function ready_sqls(strs, tails) { | ||
const options = strs | ||
const [strs2, tails2] = import_module(strs, tails); | ||
const options = strs2 | ||
.map(s => s | ||
@@ -113,3 +147,3 @@ .replace(/\s*\n/, '') | ||
go( | ||
tails, | ||
tails2, | ||
map(tail => | ||
@@ -409,2 +443,3 @@ is_tag(tail) ? | ||
ASSOCIATE1, | ||
ASSOCIATE_MODULE, | ||
LOAD_LJOIN: use_ljoin ? LOAD_LJOIN : null, | ||
@@ -411,0 +446,0 @@ async TRANSACTION() { |
{ | ||
"name": "mql2", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"description": "query builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35499
647