Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Created June 15, 2011 15:52

Revisions

  1. nathansmith renamed this gist Feb 3, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. nathansmith revised this gist Feb 3, 2012. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@
    // JSLint:
    /*global window, _parseInt, parseInt*/

    // Protect against parseInt being used
    // without radix, by defaulting to 10.

  3. nathansmith revised this gist Feb 3, 2012. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,13 @@
    // Conditionally check value, in case
    // future implementations of parseInt
    // provide native base-10 by default.
    if (window.parseInt('09') === 0) {
    window._parseInt = window.parseInt;

    window.parseInt = function(str, radix) {
    return window._parseInt(str, radix || 10);
    };
    }
    (function(window) {
    var _parseInt = window.parseInt;

    if (_parseInt('09') === 0) {
    window.parseInt = function(str, radix) {
    return _parseInt(str, radix || 10);
    };
    }
    })(this);
  4. nathansmith revised this gist Feb 3, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    // JSLint:
    /*global window, _parseInt, parseInt*/

    // Protect against parseInt being used
    // without radix, by defaulting to 10.

    // Conditionally check value, in case
    // future implementations of parseInt
    // provide native base-10 by default.
  5. nathansmith revised this gist Jun 15, 2011. No changes.
  6. nathansmith revised this gist Jun 15, 2011. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    // JSLint:
    /*global window, _parseInt, parseInt*/

    // Conditionally check value, in case
    // future implementations of parseInt
    // provide native base-10 by default.
    if (window.parseInt('09') === 0) {
    // JSLint:
    /*global window, _parseInt, parseInt*/

    window._parseInt = window.parseInt;

    window.parseInt = function(str, radix) {
  7. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // Conditionally check value, in case
    // future implementations of parseInt
    // provide native base-10 by default.
    if (parseInt('09') === 0) {
    if (window.parseInt('09') === 0) {
    // JSLint:
    /*global window, _parseInt, parseInt*/

  8. nathansmith revised this gist Jun 15, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,9 @@
    // future implementations of parseInt
    // provide native base-10 by default.
    if (parseInt('09') === 0) {
    // JSLint:
    /*global window, _parseInt, parseInt*/

    window._parseInt = window.parseInt;

    window.parseInt = function(str, radix) {
  9. nathansmith revised this gist Jun 15, 2011. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -2,11 +2,9 @@
    // future implementations of parseInt
    // provide native base-10 by default.
    if (parseInt('09') === 0) {
    /*global _parseInt*/
    _parseInt = parseInt;
    window._parseInt = window.parseInt;

    /*global parseInt*/
    parseInt = function(str, radix) {
    return _parseInt(str, radix || 10);
    window.parseInt = function(str, radix) {
    return window._parseInt(str, radix || 10);
    };
    }
  10. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // Conditionally check value, in case
    // future implementations of parseInt
    // provide native base-10 by default.
    if (parseInt('090') === 0) {
    if (parseInt('09') === 0) {
    /*global _parseInt*/
    _parseInt = parseInt;

  11. nathansmith revised this gist Jun 15, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    // Conditionally check value, in case
    // future implementations of parseInt
    // provide native base-10 by default.
    if (parseInt('090') === 0) {
    /*global _parseInt*/
    _parseInt = parseInt;
  12. nathansmith revised this gist Jun 15, 2011. 1 changed file with 7 additions and 24 deletions.
    31 changes: 7 additions & 24 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,26 +1,9 @@
    // Un-comment to test. Returns 0.
    // console.log(parseInt('090'));
    if (parseInt('090') === 0) {
    /*global _parseInt*/
    _parseInt = parseInt;

    var APP = (function(window) {
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, radix);
    }

    // Un-comment to test. Returns 90.
    // console.log(parseInt('090'));

    return {
    // Sub-objects and methods that
    // use the modified parseInt...
    //
    // parseInt('090');
    //
    // instead of:
    //
    // parseInt('090', 10);
    //
    // Because srsly, who ever means
    // anything *but* base-10 parse?
    /*global parseInt*/
    parseInt = function(str, radix) {
    return _parseInt(str, radix || 10);
    };
    })(this);
    }
  13. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    var APP = (function(window) {
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, 10);
    return window.parseInt(str, radix);
    }

    // Un-comment to test. Returns 90.
  14. nathansmith revised this gist Jun 15, 2011. No changes.
  15. nathansmith revised this gist Jun 15, 2011. No changes.
  16. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ var APP = (function(window) {
    return window.parseInt(str, 10);
    }

    // Un-comment to test. Returns 9.
    // Un-comment to test. Returns 90.
    // console.log(parseInt('090'));

    return {
  17. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ var APP = (function(window) {
    //
    // parseInt('090', 10);
    //
    // Because, srsly, who ever means
    // Because srsly, who ever means
    // anything *but* base-10 parse?
    };
    })(this);
  18. nathansmith revised this gist Jun 15, 2011. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,15 @@
    // Un-comment to test. Returns 0.
    // console.log(parseInt('090'));

    var APP = (function(window) {
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, 10);
    }

    // Un-comment to test. Returns 9.
    // console.log(parseInt('090'));

    return {
    // Sub-objects and methods that
    // use the modified parseInt...
  19. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    var APP = (function(window) {
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, radix);
    return window.parseInt(str, 10);
    }

    return {
  20. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    var APP = (function(window) {
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, 10);
    return window.parseInt(str, radix);
    }

    return {
  21. nathansmith revised this gist Jun 15, 2011. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    var APP = (function(window) {
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, radix);
    }
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, 10);
    }

    return {
    // Sub-objects and methods that
    // use the modified parseInt...
    //
    // parseInt('090');
    //
    // instead of:
    //
    // parseInt('090', 10);
    //
    // Because, srsly, who ever means
    // anything *but* base-10 parse?
    };
    return {
    // Sub-objects and methods that
    // use the modified parseInt...
    //
    // parseInt('090');
    //
    // instead of:
    //
    // parseInt('090', 10);
    //
    // Because, srsly, who ever means
    // anything *but* base-10 parse?
    };
    })(this);
  22. nathansmith revised this gist Jun 15, 2011. 1 changed file with 17 additions and 16 deletions.
    33 changes: 17 additions & 16 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,20 @@
    var APP = (function(window) {
    function parseInt(str) {
    return window.parseInt(str, 10);
    }
    function parseInt(str, radix) {
    radix = radix || 10;
    return window.parseInt(str, radix);
    }

    return {
    // Sub-objects and methods that
    // use the modified parseInt...
    //
    // parseInt('090');
    //
    // instead of:
    //
    // parseInt('090', 10);
    //
    // Because, srsly, who ever means
    // anything *but* base-10 parse?
    };
    return {
    // Sub-objects and methods that
    // use the modified parseInt...
    //
    // parseInt('090');
    //
    // instead of:
    //
    // parseInt('090', 10);
    //
    // Because, srsly, who ever means
    // anything *but* base-10 parse?
    };
    })(this);
  23. nathansmith revised this gist Jun 15, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ var APP = (function(window) {
    //
    // parseInt('090');
    //
    // versus:
    // instead of:
    //
    // parseInt('090', 10);
    //
  24. nathansmith revised this gist Jun 15, 2011. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,15 @@ var APP = (function(window) {

    return {
    // Sub-objects and methods that
    // use the modified parseInt.
    // use the modified parseInt...
    //
    // parseInt('090');
    //
    // versus:
    //
    // parseInt('090', 10);
    //
    // Because, srsly, who ever means
    // anything *but* base-10 parse?
    };
    })(this);
  25. nathansmith created this gist Jun 15, 2011.
    10 changes: 10 additions & 0 deletions lazy_parse_int.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    var APP = (function(window) {
    function parseInt(str) {
    return window.parseInt(str, 10);
    }

    return {
    // Sub-objects and methods that
    // use the modified parseInt.
    };
    })(this);