-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHORE(lib): deprecate util, validate, sanitize
This commit deprecates and deletes the vast majority of code in the following files: - lib/util.js - lib/validate.js - lib/sanitize.js Any remaining methods have been wrapped in NodeJS's util.deprecate() method to indicate that they should not be used. These methods will be completely removed in the coming month. Additionally, lodash has been added as a dependency. This serves to fill some of the needs left by the deletion and deprecation of our lib functions. Closes #32.
- Loading branch information
Showing
12 changed files
with
37 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,6 @@ | ||
// lib/util/sanitize.js | ||
var db = require('./db'); | ||
var util = require('util'); | ||
|
||
// FIXME | ||
// These are mostly duplicates of util.js. Remove them from here and | ||
// inject util.js into the application where it is needed. | ||
module.exports = { | ||
|
||
// this is not incredibly secure | ||
escapeid : function (id) { return ['`', id, '`'].join(''); }, | ||
|
||
escape: function (str) { return '"' + String(str).replace(/"/g, '\\"') + '"'; }, | ||
|
||
isInt : function (n) { return (Math.floor(n) === Number(n)); }, | ||
|
||
isIn : function (s) { return String(s).indexOf('(') > -1; }, | ||
|
||
isFloat : function (f) { return parseFloat(f) !== undefined && f.toString().indexOf('.') > -1; }, | ||
|
||
// this also works for hexadecimal ('0x12') | ||
isNumber: function (n) { return !Number.isNaN(Number(n)); }, | ||
|
||
isArray: function (arr) { return Object.prototype.toString.call(arr) === '[object Array]'; }, | ||
|
||
isString: function (str) { return typeof str === 'string'; }, | ||
|
||
isObject: function (obj) { return Object.prototype.toString.call(obj) === '[object Object]'; }, | ||
|
||
// is there a better way to do this? | ||
isUndefined : function (u) { return u === undefined; }, | ||
|
||
isDefined : function (u) { return !this.isUndefined(u); } | ||
|
||
escape: util.deprecate(db.escape, 'sanitize.escape() is deprecated. Please use db.escape instead.') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters