cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: Add ArrayBuffer.slice polyfill to unbreak Android pre-KK
Date Fri, 11 Jul 2014 16:27:33 GMT
Repository: cordova-app-harness
Updated Branches:
  refs/heads/master a7ece1558 -> f07fccfee


Add ArrayBuffer.slice polyfill to unbreak Android pre-KK


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/f07fccfe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/f07fccfe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/f07fccfe

Branch: refs/heads/master
Commit: f07fccfee6f31c06040fbe7e778b56e53c133636
Parents: a7ece15
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri Jul 11 12:27:00 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Jul 11 12:27:00 2014 -0400

----------------------------------------------------------------------
 www/cdvah/harnessmenu.html |  1 +
 www/cdvah/js/libs/slice.js | 42 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/f07fccfe/www/cdvah/harnessmenu.html
----------------------------------------------------------------------
diff --git a/www/cdvah/harnessmenu.html b/www/cdvah/harnessmenu.html
index 9721caa..c48e070 100644
--- a/www/cdvah/harnessmenu.html
+++ b/www/cdvah/harnessmenu.html
@@ -22,6 +22,7 @@
         <title>Cordova App Harness</title>
         <script>THIS_IS_APP_HARNESS=true</script>
         <script type="text/javascript" src="../cordova.js"></script>
+        <script type="text/javascript" src="js/libs/slice.js"></script>
         <script type="text/javascript" src="js/libs/angular.js"></script>
         <script type="text/javascript" src="js/libs/angular-route.js"></script>
         <script type="text/javascript" src="js/libs/moment.min.js"></script>

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/f07fccfe/www/cdvah/js/libs/slice.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/libs/slice.js b/www/cdvah/js/libs/slice.js
new file mode 100644
index 0000000..31050f8
--- /dev/null
+++ b/www/cdvah/js/libs/slice.js
@@ -0,0 +1,42 @@
+// https://github.com/ttaubert/node-arraybuffer-slice
+// (c) 2014 Tim Taubert <tim@timtaubert.de>
+// arraybuffer-slice may be freely distributed under the MIT license.
+
+(function (undefined) {
+  "use strict";
+
+  function clamp(val, length) {
+    val = (val|0) || 0;
+
+    if (val < 0) {
+      return Math.max(val + length, 0);
+    }
+
+    return Math.min(val, length);
+  }
+
+  if (!ArrayBuffer.prototype.slice) {
+    ArrayBuffer.prototype.slice = function (from, to) {
+      var length = this.byteLength;
+      var begin = clamp(from, length);
+      var end = length;
+
+      if (to !== undefined) {
+        end = clamp(to, length);
+      }
+
+      if (begin > end) {
+        return new ArrayBuffer(0);
+      }
+
+      var num = end - begin;
+      var target = new ArrayBuffer(num);
+      var targetArray = new Uint8Array(target);
+
+      var sourceArray = new Uint8Array(this, begin, num);
+      targetArray.set(sourceArray);
+
+      return target;
+    };
+  }
+})();


Mime
View raw message