-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified the command method. Allowing args to be multi-word strings e…
…nclosed in single/double quotes
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ node_modules | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Ignore IDE files | ||
.idea |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function tokenize (str) { | ||
var tokens = []; | ||
var k, i, temp; | ||
var strLen = str.length; | ||
|
||
for (i = 0; i < strLen; i++) { | ||
if (str[i] === '\"') { | ||
// Keep reading chars until | ||
for (temp = [], k = i+1; k < strLen && str[k] !== '\"'; k++) { | ||
temp.push(str[k]); | ||
} | ||
tokens.push(temp.join('')); | ||
i = k+1; | ||
} | ||
|
||
if (str[i] === '\'') { | ||
// Keep reading chars until | ||
for (temp = [], k = i+1; k < strLen && str[k] !== '\''; k++) { | ||
temp.push(str[k]); | ||
} | ||
tokens.push(temp.join('')); | ||
i = k+1; | ||
} | ||
|
||
if (str[i] && str[i] !== ' ') { | ||
// Keep reading chars until | ||
for (temp = [], k = i; k < strLen && str[k] !== ' '; k++) { | ||
temp.push(str[k]); | ||
} | ||
tokens.push(temp.join('')); | ||
i = k; | ||
} | ||
} | ||
|
||
return tokens; | ||
} | ||
|
||
module.exports = tokenize; |