Apache Cordova
  1. Apache Cordova
  2. CB-1892

Refactor type-checking code in plugins into a helper method

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.0
    • Component/s: CordovaJS
    • Labels:
      None

      Description

      ML Discussion: http://callback.markmail.org/thread/4vgze66wlaaxthsd

      The idea is to add a typecheck module along the lines of:
      argscheck.checkArgs('noasdf', 'testFunc', arguments);

      where n=number, o=object, a=array, s=string, d=date, f=function, *=anything

      Side-effects of this change will include:
      1. All core plugins will have their callbacks be optional

      2. Incorrect types will result in an exception thrown

      3. Should reduce the size of cordova.js through removing repetitive code.

        Activity

        Show
        Andrew Grieve added a comment - argscheck module: https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=1dfa2ac54a41287279e6726d2b748060e1cc44bf Lower-case .js plugin files: https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=9ba65d4f42cddf0cdc1c1f1b624df201bde0ca18 https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=f400233bef00da6d3678d95e4abf745a1f62e07f https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=58990dad50f337fd8c71250398d6586ae2b055ac https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=f81be6623d3429f442a0e214adfe3f66fff32b1f https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=4864283bcc17d37d7d28d85ffed9dc41dd3931f9 https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=1fe276bcb9b36ced8be236c40886a6c0dc0a1076 https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=ee4a70cce10fadd7a7563eb2941f231c9841d009 So far, 4kb off of cordova.ios.js (from 192 to 188kb) 245 insertions , 323 deletions This is now mostly done, but need to check if it would make sense for any of the CamelCase.js files to use it.
        Hide
        Andrew Grieve added a comment -

        Some commits ending with:
        https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=790e28572ec70d2956f24c48591ed681ddec5eaf

        This applies argscheck to all files that already have type-checking in them (and so reduces code size).

        I'd like to not go overboard with this, so am marking as fixed and do not intend to introduce it anywhere else.

        Show
        Andrew Grieve added a comment - Some commits ending with: https://git-wip-us.apache.org/repos/asf?p=cordova-js.git;a=commit;h=790e28572ec70d2956f24c48591ed681ddec5eaf This applies argscheck to all files that already have type-checking in them (and so reduces code size). I'd like to not go overboard with this, so am marking as fixed and do not intend to introduce it anywhere else.

          People

          • Assignee:
            Andrew Grieve
            Reporter:
            Andrew Grieve
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development