Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/binary.js

Issue 800513006: Added vulcanize under third_party/npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/binary.js
diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/binary.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/binary.js
new file mode 100644
index 0000000000000000000000000000000000000000..d8617feec93303a9c6280d9304a1bd522cb3827c
--- /dev/null
+++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/binary.js
@@ -0,0 +1,125 @@
+// Modified from:
+// https://raw.github.com/kanaka/noVNC/d890e8640f20fba3215ba7be8e0ff145aeb8c17c/include/base64.js
+
+'use strict';
+
+// A trick for browserified version.
+// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
+var NodeBuffer = require('buffer').Buffer;
+
+var Type = require('../type');
+
+
+
+var BASE64_PADDING = '=';
+
+var BASE64_BINTABLE = [
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1
+];
+
+var BASE64_CHARTABLE =
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
+
+
+function resolveYamlBinary(state) {
+ var value, code, idx = 0, result = [], leftbits, leftdata,
+ object = state.result;
+
+ leftbits = 0; // number of bits decoded, but yet to be appended
+ leftdata = 0; // bits decoded, but yet to be appended
+
+ // Convert one by one.
+ for (idx = 0; idx < object.length; idx += 1) {
+ code = object.charCodeAt(idx);
+ value = BASE64_BINTABLE[code & 0x7F];
+
+ // Skip LF(NL) || CR
+ if (0x0A !== code && 0x0D !== code) {
+ // Fail on illegal characters
+ if (-1 === value) {
+ return false;
+ }
+
+ // Collect data into leftdata, update bitcount
+ leftdata = (leftdata << 6) | value;
+ leftbits += 6;
+
+ // If we have 8 or more bits, append 8 bits to the result
+ if (leftbits >= 8) {
+ leftbits -= 8;
+
+ // Append if not padding.
+ if (BASE64_PADDING !== object.charAt(idx)) {
+ result.push((leftdata >> leftbits) & 0xFF);
+ }
+
+ leftdata &= (1 << leftbits) - 1;
+ }
+ }
+ }
+
+ // If there are any bits left, the base64 string was corrupted
+ if (leftbits) {
+ return false;
+ } else {
+ // Wrap into Buffer for NodeJS and leave Array for browser
+ if (NodeBuffer) {
+ state.result = new NodeBuffer(result);
+ } else {
+ state.result = result;
+ }
+ return true;
+ }
+}
+
+
+function representYamlBinary(object /*, style*/) {
+ var result = '', index, length, rest;
+
+ // Convert every three bytes to 4 ASCII characters.
+ for (index = 0, length = object.length - 2; index < length; index += 3) {
+ result += BASE64_CHARTABLE[object[index + 0] >> 2];
+ result += BASE64_CHARTABLE[((object[index + 0] & 0x03) << 4) + (object[index + 1] >> 4)];
+ result += BASE64_CHARTABLE[((object[index + 1] & 0x0F) << 2) + (object[index + 2] >> 6)];
+ result += BASE64_CHARTABLE[object[index + 2] & 0x3F];
+ }
+
+ rest = object.length % 3;
+
+ // Convert the remaining 1 or 2 bytes, padding out to 4 characters.
+ if (0 !== rest) {
+ index = object.length - rest;
+ result += BASE64_CHARTABLE[object[index + 0] >> 2];
+
+ if (2 === rest) {
+ result += BASE64_CHARTABLE[((object[index + 0] & 0x03) << 4) + (object[index + 1] >> 4)];
+ result += BASE64_CHARTABLE[(object[index + 1] & 0x0F) << 2];
+ result += BASE64_PADDING;
+ } else {
+ result += BASE64_CHARTABLE[(object[index + 0] & 0x03) << 4];
+ result += BASE64_PADDING + BASE64_PADDING;
+ }
+ }
+
+ return result;
+}
+
+
+function isBinary(object) {
+ return NodeBuffer && NodeBuffer.isBuffer(object);
+}
+
+
+module.exports = new Type('tag:yaml.org,2002:binary', {
+ loadKind: 'scalar',
+ loadResolver: resolveYamlBinary,
+ dumpPredicate: isBinary,
+ dumpRepresenter: representYamlBinary
+});

Powered by Google App Engine
This is Rietveld 408576698