Built browser version

pull/2/head
Louis Chatriot 9 years ago
parent cef38553c8
commit 92ec75fbed
  1. 30
      browser-version/out/nedb.js
  2. 8
      browser-version/out/nedb.min.js

@ -924,7 +924,7 @@ Cursor.prototype._exec = function(callback) {
var criterion, compare, i; var criterion, compare, i;
for (i = 0; i < criteria.length; i++) { for (i = 0; i < criteria.length; i++) {
criterion = criteria[i]; criterion = criteria[i];
compare = criterion.direction * model.compareThings(model.getDotValue(a, criterion.key), model.getDotValue(b, criterion.key)); compare = criterion.direction * model.compareThings(model.getDotValue(a, criterion.key), model.getDotValue(b, criterion.key), self.db.compareStrings);
if (compare !== 0) { if (compare !== 0) {
return compare; return compare;
} }
@ -1067,6 +1067,10 @@ var customUtils = require('./customUtils')
* @param {Function} options.onload Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown * @param {Function} options.onload Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown
* @param {Function} options.afterSerialization/options.beforeDeserialization Optional, serialization hooks * @param {Function} options.afterSerialization/options.beforeDeserialization Optional, serialization hooks
* @param {Number} options.corruptAlertThreshold Optional, threshold after which an alert is thrown if too much data is corrupt * @param {Number} options.corruptAlertThreshold Optional, threshold after which an alert is thrown if too much data is corrupt
* @param {Function} options.compareStrings Optional, string comparison function that overrides default for sorting
*
* Event Emitter - Events
* * compaction.done - Fired whenever a compaction operation was finished
*/ */
function Datastore (options) { function Datastore (options) {
var filename; var filename;
@ -1091,6 +1095,9 @@ function Datastore (options) {
this.filename = filename; this.filename = filename;
} }
// String comparison function
this.compareStrings = options.compareStrings;
// Persistence handling // Persistence handling
this.persistence = new Persistence({ db: this, nodeWebkitAppName: options.nodeWebkitAppName this.persistence = new Persistence({ db: this, nodeWebkitAppName: options.nodeWebkitAppName
, afterSerialization: options.afterSerialization , afterSerialization: options.afterSerialization
@ -1116,6 +1123,8 @@ function Datastore (options) {
}); } }); }
} }
util.inherits(Datastore, require('events'));
/** /**
* Load the database from the datafile, and trigger the execution of buffered commands if any * Load the database from the datafile, and trigger the execution of buffered commands if any
@ -1681,7 +1690,7 @@ Datastore.prototype.remove = function () {
module.exports = Datastore; module.exports = Datastore;
},{"./cursor":5,"./customUtils":6,"./executor":8,"./indexes":9,"./model":10,"./persistence":11,"async":13,"underscore":19,"util":3}],8:[function(require,module,exports){ },{"./cursor":5,"./customUtils":6,"./executor":8,"./indexes":9,"./model":10,"./persistence":11,"async":13,"events":1,"underscore":19,"util":3}],8:[function(require,module,exports){
var process=require("__browserify_process");/** var process=require("__browserify_process");/**
* Responsible for sequentially executing actions on the database * Responsible for sequentially executing actions on the database
*/ */
@ -2242,9 +2251,12 @@ function compareArrays (a, b) {
* In the case of objects and arrays, we deep-compare * In the case of objects and arrays, we deep-compare
* If two objects dont have the same type, the (arbitrary) type hierarchy is: undefined, null, number, strings, boolean, dates, arrays, objects * If two objects dont have the same type, the (arbitrary) type hierarchy is: undefined, null, number, strings, boolean, dates, arrays, objects
* Return -1 if a < b, 1 if a > b and 0 if a = b (note that equality here is NOT the same as defined in areThingsEqual!) * Return -1 if a < b, 1 if a > b and 0 if a = b (note that equality here is NOT the same as defined in areThingsEqual!)
*
* @param {Function} _compareStrings String comparing function, returning -1, 0 or 1, overriding default string comparison (useful for languages with accented letters)
*/ */
function compareThings (a, b) { function compareThings (a, b, _compareStrings) {
var aKeys, bKeys, comp, i; var aKeys, bKeys, comp, i
, compareStrings = _compareStrings || compareNSB;
// undefined // undefined
if (a === undefined) { return b === undefined ? 0 : -1; } if (a === undefined) { return b === undefined ? 0 : -1; }
@ -2259,8 +2271,8 @@ function compareThings (a, b) {
if (typeof b === 'number') { return typeof a === 'number' ? compareNSB(a, b) : 1; } if (typeof b === 'number') { return typeof a === 'number' ? compareNSB(a, b) : 1; }
// Strings // Strings
if (typeof a === 'string') { return typeof b === 'string' ? compareNSB(a, b) : -1; } if (typeof a === 'string') { return typeof b === 'string' ? compareStrings(a, b) : -1; }
if (typeof b === 'string') { return typeof a === 'string' ? compareNSB(a, b) : 1; } if (typeof b === 'string') { return typeof a === 'string' ? compareStrings(a, b) : 1; }
// Booleans // Booleans
if (typeof a === 'boolean') { return typeof b === 'boolean' ? compareNSB(a, b) : -1; } if (typeof a === 'boolean') { return typeof b === 'boolean' ? compareNSB(a, b) : -1; }
@ -2961,7 +2973,11 @@ Persistence.prototype.persistCachedDatabase = function (cb) {
} }
}); });
storage.crashSafeWriteFile(this.filename, toPersist, callback); storage.crashSafeWriteFile(this.filename, toPersist, function (err) {
if (err) { return callback(err); }
self.db.emit('compaction.done');
return callback(null);
});
}; };

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save