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

fergies-inverted-index

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fergies-inverted-index - npm Package Compare versions

Comparing version 7.0.0 to 8.0.0

119

dist/fergies-inverted-index.cjs.js

@@ -8,3 +8,3 @@ 'use strict';

function init (db, ops) {
var read = ops => {
const isString = s => (typeof s === 'string');

@@ -137,3 +137,3 @@

token.FIELD.map(
fieldName => new Promise(resolve => db.createReadStream({
fieldName => new Promise(resolve => ops.db.createReadStream({
gte: fieldName + ':' + token.VALUE.GTE + ops.tokenAppend,

@@ -159,3 +159,3 @@ lte: fieldName + ':' + token.VALUE.LTE + ops.tokenAppend + '○',

const fieldNames = [];
db.createReadStream({
ops.db.createReadStream({
gte: '○FIELD○',

@@ -214,3 +214,3 @@ lte: '○FIELD○○'

_ids.map(
id => db.get('○DOC○' + id._id + '○').catch(reason => null)
id => ops.db.get('○DOC○' + id._id + '○').catch(reason => null)
)

@@ -223,5 +223,5 @@ ).then(_objects => _ids.map((_id, i) => {

// TODO: can this be replaced by RANGE?
const getRange = ops => new Promise((resolve, reject) => {
const getRange = rangeOps => new Promise((resolve, reject) => {
const keys = [];
db.createReadStream(ops)
ops.db.createReadStream(rangeOps)
.on('data', data => { keys.push(data); })

@@ -317,5 +317,5 @@ .on('end', () => resolve(keys));

}
}
};
function init$1 (db, ops) {
function init (ops) {
// TODO: set reset this to the max value every time the DB is restarted

@@ -443,3 +443,3 @@ var incrementalId = 0;

// deleted
const DELETE = _ids => init(db).OBJECT(
const DELETE = _ids => read(ops).OBJECT(
_ids.map(_id => ({ _id: _id }))

@@ -454,3 +454,3 @@ ).then(

return doc._object
}), db, 'del', {})
}), ops.db, 'del', {})
).then(

@@ -468,4 +468,4 @@ docs => docs.map(

// are not currently supported
const IMPORT = index => db.clear().then(() =>
db.batch(index.map(
const IMPORT = index => ops.db.clear().then(() =>
ops.db.batch(index.map(
entry => Object.assign(entry, { type: 'put' })

@@ -475,4 +475,4 @@ ))

const PUT = (docs, putOptions) => writer(
docs, db, 'put', (putOptions || {})
const PUT = (docs, putOptions = {}) => writer(
docs, ops.db, 'put', putOptions
).then(

@@ -502,32 +502,3 @@ docs => docs.map(

const makeAFii = (db, ops) => ({
AND: (...keys) => init(db, ops).INTERSECTION(...keys).then(
flattenMatchArrayInResults
),
BUCKET: init(db, ops).BUCKET,
BUCKETS: init(db, ops).BUCKETS,
AGGREGATE: init(db, ops).AGGREGATE,
DELETE: init$1(db, ops).DELETE,
DISTINCT: init(db, ops).DISTINCT,
EXPORT: init(db, ops).EXPORT,
FACETS: init(db, ops).FACETS,
FIELDS: init(db, ops).FIELDS,
GET: init(db, ops).GET,
IMPORT: init$1(db, ops).IMPORT,
MAX: init(db, ops).MAX,
MIN: init(db, ops).MIN,
NOT: (...keys) => init(db, ops).SET_SUBTRACTION(...keys).then(
flattenMatchArrayInResults
),
OBJECT: init(db, ops).OBJECT,
OR: (...keys) => init(db, ops).UNION(...keys)
.then(result => result.union)
.then(flattenMatchArrayInResults),
PUT: init$1(db, ops).PUT,
SET_SUBTRACTION: init(db, ops).SET_SUBTRACTION,
STORE: db,
parseToken: init(db, ops).parseToken
});
function fii (ops, callback) {
const initStore = (ops = {}) => new Promise((resolve, reject) => {
ops = Object.assign({

@@ -543,17 +514,47 @@ name: 'fii',

stopwords: []
}, ops || {});
// if no callback provided, "lazy load"
if (!callback) {
return makeAFii(
(ops.store || level(ops.name, { valueEncoding: 'json' })),
ops
)
} else {
if (ops.store) return callback(new Error('When initing with a store use "lazy loading"'), null)
// use callback to provide a notification that db is opened
level(ops.name, { valueEncoding: 'json' }, (err, store) =>
callback(err, makeAFii(store, ops)));
}
}
}, ops);
if (ops.db) return resolve(ops)
// else
level(
ops.name, { valueEncoding: 'json' }, (err, db) => err
? reject(err)
: resolve(Object.assign(ops, { db: db }))
);
});
module.exports = fii;
const makeAFii = ops => {
const r = read(ops);
const w = init(ops);
return ({
AND: (...keys) => r.INTERSECTION(...keys).then(
flattenMatchArrayInResults
),
BUCKET: r.BUCKET,
BUCKETS: r.BUCKETS,
AGGREGATE: r.AGGREGATE,
DELETE: w.DELETE,
DISTINCT: r.DISTINCT,
EXPORT: r.EXPORT,
FACETS: r.FACETS,
FIELDS: r.FIELDS,
GET: r.GET,
IMPORT: w.IMPORT,
MAX: r.MAX,
MIN: r.MIN,
NOT: (...keys) => r.SET_SUBTRACTION(...keys).then(
flattenMatchArrayInResults
),
OBJECT: r.OBJECT,
OR: (...keys) => r.UNION(...keys)
.then(result => result.union)
.then(flattenMatchArrayInResults),
PUT: w.PUT,
SET_SUBTRACTION: r.SET_SUBTRACTION,
STORE: ops.db,
parseToken: r.parseToken
})
};
var main = ops => initStore(ops).then(makeAFii);
module.exports = main;
import level from 'level';
import trav from 'traverse';
function init (db, ops) {
var read = ops => {
const isString = s => (typeof s === 'string');

@@ -132,3 +132,3 @@

token.FIELD.map(
fieldName => new Promise(resolve => db.createReadStream({
fieldName => new Promise(resolve => ops.db.createReadStream({
gte: fieldName + ':' + token.VALUE.GTE + ops.tokenAppend,

@@ -154,3 +154,3 @@ lte: fieldName + ':' + token.VALUE.LTE + ops.tokenAppend + '○',

const fieldNames = [];
db.createReadStream({
ops.db.createReadStream({
gte: '○FIELD○',

@@ -209,3 +209,3 @@ lte: '○FIELD○○'

_ids.map(
id => db.get('○DOC○' + id._id + '○').catch(reason => null)
id => ops.db.get('○DOC○' + id._id + '○').catch(reason => null)
)

@@ -218,5 +218,5 @@ ).then(_objects => _ids.map((_id, i) => {

// TODO: can this be replaced by RANGE?
const getRange = ops => new Promise((resolve, reject) => {
const getRange = rangeOps => new Promise((resolve, reject) => {
const keys = [];
db.createReadStream(ops)
ops.db.createReadStream(rangeOps)
.on('data', data => { keys.push(data); })

@@ -312,5 +312,5 @@ .on('end', () => resolve(keys));

}
}
};
function init$1 (db, ops) {
function init (ops) {
// TODO: set reset this to the max value every time the DB is restarted

@@ -438,3 +438,3 @@ var incrementalId = 0;

// deleted
const DELETE = _ids => init(db).OBJECT(
const DELETE = _ids => read(ops).OBJECT(
_ids.map(_id => ({ _id: _id }))

@@ -449,3 +449,3 @@ ).then(

return doc._object
}), db, 'del', {})
}), ops.db, 'del', {})
).then(

@@ -463,4 +463,4 @@ docs => docs.map(

// are not currently supported
const IMPORT = index => db.clear().then(() =>
db.batch(index.map(
const IMPORT = index => ops.db.clear().then(() =>
ops.db.batch(index.map(
entry => Object.assign(entry, { type: 'put' })

@@ -470,4 +470,4 @@ ))

const PUT = (docs, putOptions) => writer(
docs, db, 'put', (putOptions || {})
const PUT = (docs, putOptions = {}) => writer(
docs, ops.db, 'put', putOptions
).then(

@@ -497,32 +497,3 @@ docs => docs.map(

const makeAFii = (db, ops) => ({
AND: (...keys) => init(db, ops).INTERSECTION(...keys).then(
flattenMatchArrayInResults
),
BUCKET: init(db, ops).BUCKET,
BUCKETS: init(db, ops).BUCKETS,
AGGREGATE: init(db, ops).AGGREGATE,
DELETE: init$1(db, ops).DELETE,
DISTINCT: init(db, ops).DISTINCT,
EXPORT: init(db, ops).EXPORT,
FACETS: init(db, ops).FACETS,
FIELDS: init(db, ops).FIELDS,
GET: init(db, ops).GET,
IMPORT: init$1(db, ops).IMPORT,
MAX: init(db, ops).MAX,
MIN: init(db, ops).MIN,
NOT: (...keys) => init(db, ops).SET_SUBTRACTION(...keys).then(
flattenMatchArrayInResults
),
OBJECT: init(db, ops).OBJECT,
OR: (...keys) => init(db, ops).UNION(...keys)
.then(result => result.union)
.then(flattenMatchArrayInResults),
PUT: init$1(db, ops).PUT,
SET_SUBTRACTION: init(db, ops).SET_SUBTRACTION,
STORE: db,
parseToken: init(db, ops).parseToken
});
function fii (ops, callback) {
const initStore = (ops = {}) => new Promise((resolve, reject) => {
ops = Object.assign({

@@ -538,17 +509,47 @@ name: 'fii',

stopwords: []
}, ops || {});
// if no callback provided, "lazy load"
if (!callback) {
return makeAFii(
(ops.store || level(ops.name, { valueEncoding: 'json' })),
ops
)
} else {
if (ops.store) return callback(new Error('When initing with a store use "lazy loading"'), null)
// use callback to provide a notification that db is opened
level(ops.name, { valueEncoding: 'json' }, (err, store) =>
callback(err, makeAFii(store, ops)));
}
}
}, ops);
if (ops.db) return resolve(ops)
// else
level(
ops.name, { valueEncoding: 'json' }, (err, db) => err
? reject(err)
: resolve(Object.assign(ops, { db: db }))
);
});
export default fii;
const makeAFii = ops => {
const r = read(ops);
const w = init(ops);
return ({
AND: (...keys) => r.INTERSECTION(...keys).then(
flattenMatchArrayInResults
),
BUCKET: r.BUCKET,
BUCKETS: r.BUCKETS,
AGGREGATE: r.AGGREGATE,
DELETE: w.DELETE,
DISTINCT: r.DISTINCT,
EXPORT: r.EXPORT,
FACETS: r.FACETS,
FIELDS: r.FIELDS,
GET: r.GET,
IMPORT: w.IMPORT,
MAX: r.MAX,
MIN: r.MIN,
NOT: (...keys) => r.SET_SUBTRACTION(...keys).then(
flattenMatchArrayInResults
),
OBJECT: r.OBJECT,
OR: (...keys) => r.UNION(...keys)
.then(result => result.union)
.then(flattenMatchArrayInResults),
PUT: w.PUT,
SET_SUBTRACTION: r.SET_SUBTRACTION,
STORE: ops.db,
parseToken: r.parseToken
})
};
var main = ops => initStore(ops).then(makeAFii);
export default main;
{
"name": "fergies-inverted-index",
"version": "7.0.0",
"version": "8.0.0",
"description": "An inverted index that allows javascript objects to be easily serialised and retrieved using promises and map-reduce",

@@ -5,0 +5,0 @@ "main": "dist/fergies-inverted-index.cjs.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