Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get the tests 100% green with common js module system

  • Loading branch information...
commit f3240e8be6437eaf55102dc16bcf2f5f7f45e620 1 parent aa29764
@smtlaissezfaire authored
Showing with 11 additions and 2 deletions.
  1. +6 −1 jslex.js
  2. +5 −1 jslex_test.js
View
7 jslex.js
@@ -25,7 +25,7 @@
function TokenDef(pattern, callbackfn) {
this.match = function match(text) {
- var trimmed = text.trimBegin();
+ var trimmed = text.trim();
var match = trimmed.match(pattern);
if (match && match.index == 0) {
var newText = trimmed.substr(match[0].length);
@@ -77,3 +77,8 @@ function jsLex(tokenDefs, text) {
return tokenStream;
}
+
+if (typeof(exports) !== "undefined") {
+ exports.TokenDef = TokenDef;
+ exports.jsLex = jsLex;
+}
View
6 jslex_test.js
@@ -23,7 +23,11 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/;
-load("jslex.js");
+
+var lexer = require("./jslex");
+
+var TokenDef = lexer.TokenDef;
+var jsLex = lexer.jsLex;
function testTokenMatch() {
var result = true;
Please sign in to comment.
Something went wrong with that request. Please try again.