Added dsl.js
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 28297a0 · Browse files · 3 files·+39 added−36 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+39 added−36 removed
- other:+39 added−36 removed
Provenance
- Commit
f4c0fb0- Tree
574d6bb- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
28297a0
3 files changed+39 added−36 removed
modified:lib/express/core.js+1 added-36 removed
1 unmodified line2 // Express - Core - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3 4 process.mixin(require('sys'))5 process.mixin(require('express/helpers'))6+process.mixin(require('express/dsl'))7 8 // --- ExpressError9 10 ExpressError = Class({165 unmodified lines176 return '(.*?)'177 }), '/ [ ]') + '$', 'i')178 }179 179-/**180- * Escape RegExp _chars_ in _string_. Where _chars_ 181- * defaults to regular expression special characters.182- *183- * _chars_ should be a space delimited list of characters,184- * for example '[ ] ( )'.185- *186- * @param {string} string187- * @param {string} chars188- * @return {Type}189- * @api public190- */191-192-escapeRegexp = function(string, chars) {193- var specials = (chars || '/ . * + ? | ( ) [ ] { } \\').split(' ').join('|\\')194- return string.replace(new RegExp('(\\' + specials + ')', 'g'), '\\$1')195-}196-197-set = function(option, val) {198- return val == undefined ?199- Express.settings[option] :200- Express.settings[option] = val201-}202-203-enable = function(option) {204- set(option, true)205-}206-207-disable = function(option) {208- set(option, false)209-}210-211-run = function() {212- Express.server.run()213-}214-180 // --- Routing API181 182 get = view = route('get')183 post = create = route('post')2 unmodified linesadded:lib/express/dsl.js+20 added
1234567891011121314151617181920
// Express - DSL - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
exports.set = function(option, val) { return val == undefined ? Express.settings[option] : Express.settings[option] = val}
exports.enable = function(option) { set(option, true)}
exports.disable = function(option) { set(option, false)}
exports.run = function() { Express.server.run()}No newline at end of filemodified:lib/express/helpers.js+18 added
40 unmodified lines414243444546474849505152535455565758596061626340 unmodified lines */
exports.toArray = function(arr, offset) { return Array.prototype.slice.call(arr, offset)}
/** * Escape RegExp _chars_ in _string_. Where _chars_ * defaults to regular expression special characters. * * _chars_ should be a space delimited list of characters, * for example '[ ] ( )'. * * @param {string} string * @param {string} chars * @return {Type} * @api public */
exports.escapeRegexp = function(string, chars) { var specials = (chars || '/ . * + ? | ( ) [ ] { } \\').split(' ').join('|\\') return string.replace(new RegExp('(\\' + specials + ')', 'g'), '\\$1')}No newline at end of fileNo newline at end of file