-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
30 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* Copyright (C) 2011 James Roe <[email protected]> | ||
* Copyright (C) 2011 execjosh, http://execjosh.blogspot.com | ||
* Copyright (C) 2012 James M. Greene <[email protected]> | ||
**/ | ||
*/ | ||
|
||
// Source: https://github.com/ariya/phantomjs/blob/master/src/modules/webpage.js#L205 | ||
const detectType = (value: any) => { | ||
|
@@ -33,7 +33,11 @@ const detectType = (value: any) => { | |
|
||
// Source: https://github.com/ariya/phantomjs/blob/master/src/modules/webpage.js#L167 | ||
const quoteString = (str: string) => { | ||
let c, i, l = str.length, o = '"'; | ||
let c; | ||
let i; | ||
let l = str.length; | ||
let o = '"'; | ||
|
||
for (i = 0; i < l; i += 1) { | ||
c = str.charAt(i); | ||
if (c >= ' ') { | ||
|
@@ -80,14 +84,14 @@ export function serializeFunctionWithArgs(fn: any, ...args: any[]) { | |
let argType = detectType(arg); | ||
|
||
switch (argType) { | ||
case 'object': //< for type "object" | ||
case 'array': //< for type "array" | ||
case 'object': // < for type "object" | ||
case 'array': // < for type "array" | ||
str += JSON.stringify(arg) + ','; | ||
break; | ||
case 'date': //< for type "date" | ||
case 'date': // < for type "date" | ||
str += 'new Date(' + JSON.stringify(arg) + '),'; | ||
break; | ||
case 'string': //< for type "string" | ||
case 'string': // < for type "string" | ||
str += quoteString(arg) + ','; | ||
break; | ||
default: // for types: "null", "number", "function", "regexp", "undefined" | ||
|
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