Skip to content

Commit

Permalink
Browser files rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Sep 6, 2014
1 parent c092026 commit 198385e
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 175 deletions.
158 changes: 72 additions & 86 deletions demo/js/js-yaml.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* js-yaml 3.2.1 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"./":[function(require,module,exports){
/* js-yaml 3.2.2 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"./":[function(require,module,exports){
'use strict';


Expand Down Expand Up @@ -1473,12 +1473,10 @@ function readBlockScalar(state, nodeIndent) {
emptyLines = 0;
captureStart = state.position;

do { ch = state.input.charCodeAt(++state.position); }
while (!is_EOL(ch) && (0 !== ch));
while (!is_EOL(ch) && (0 !== ch))
{ ch = state.input.charCodeAt(++state.position); }

captureSegment(state, captureStart, state.position, false);

ch = state.input.charCodeAt(state.position);
}

return true;
Expand Down Expand Up @@ -2552,95 +2550,72 @@ function Type(tag, options) {
module.exports = Type;

},{"./exception":4}],14:[function(require,module,exports){
// 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('');
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';

function resolveYamlBinary(data) {
var code, idx = 0, len = data.length, leftbits;

leftbits = 0; // number of bits decoded, but yet to be appended
function resolveYamlBinary(data) {
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;

// Convert one by one.
for (idx = 0; idx < len; idx += 1) {
code = data.charCodeAt(idx);
for (idx = 0; idx < max; idx ++) {
code = map.indexOf(data.charAt(idx));

// Skip LF(NL) || CR
if (0x0A === code || 0x0D === code) { continue; }
// Skip CR/LF
if (code > 64) { continue; }

// Fail on illegal characters
if (-1 === BASE64_BINTABLE[code & 0x7F]) {
return false;
}

// update bitcount
leftbits += 6;
if (code < 0) { return false; }

// If we have 8 or more bits, append 8 bits to the result
if (leftbits >= 8) {
leftbits -= 8;
}
bitlen += 6;
}

// If there are any bits left, the base64 string was corrupted
if (leftbits) {
return false;
} else {
return true;
}
// If there are any bits left, source was corrupted
return (bitlen % 8) === 0;
}

function constructYamlBinary(data) {
var value, code, idx = 0, len = data.length, result = [], leftbits, leftdata;
var code, idx, tailbits,
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
max = input.length,
map = BASE64_MAP,
bits = 0,
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 < len; idx += 1) {
code = data.charCodeAt(idx);
value = BASE64_BINTABLE[code & 0x7F];
// Collect by 6*4 bits (3 bytes)

// Skip LF(NL) || CR
if (0x0A === code || 0x0D === code) { continue; }
for (idx = 0; idx < max; idx++) {
if ((idx % 4 === 0) && idx) {
result.push((bits >> 16) & 0xFF);
result.push((bits >> 8) & 0xFF);
result.push(bits & 0xFF);
}

// Collect data into leftdata, update bitcount
leftdata = (leftdata << 6) | value;
leftbits += 6;
bits = (bits << 6) | map.indexOf(input.charAt(idx));
}

// If we have 8 or more bits, append 8 bits to the result
if (leftbits >= 8) {
leftbits -= 8;
// Dump tail

// Append if not padding.
if (BASE64_PADDING !== data.charAt(idx)) {
result.push((leftdata >> leftbits) & 0xFF);
}
tailbits = (max % 4)*6;

leftdata &= (1 << leftbits) - 1;
}
if (tailbits === 0) {
result.push((bits >> 16) & 0xFF);
result.push((bits >> 8) & 0xFF);
result.push(bits & 0xFF);
} else if (tailbits === 18) {
result.push((bits >> 10) & 0xFF);
result.push((bits >> 2) & 0xFF);
} else if (tailbits === 12) {
result.push((bits >> 4) & 0xFF);
}

// Wrap into Buffer for NodeJS and leave Array for browser
Expand All @@ -2652,31 +2627,42 @@ function constructYamlBinary(data) {
}

function representYamlBinary(object /*, style*/) {
var result = '', index, length, rest;
var result = '', bits = 0, idx, tail,
max = object.length,
map = BASE64_MAP;

// 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];

for (idx = 0; idx < max; idx++) {
if ((idx % 3 === 0) && idx) {
result += map[(bits >> 18) & 0x3F];
result += map[(bits >> 12) & 0x3F];
result += map[(bits >> 6) & 0x3F];
result += map[bits & 0x3F];
}

bits = (bits << 8) + object[idx];
}

rest = object.length % 3;
// Dump tail

// 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];
tail = max % 3;

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;
}
if (tail === 0) {
result += map[(bits >> 18) & 0x3F];
result += map[(bits >> 12) & 0x3F];
result += map[(bits >> 6) & 0x3F];
result += map[bits & 0x3F];
} else if (tail === 2) {
result += map[(bits >> 10) & 0x3F];
result += map[(bits >> 4) & 0x3F];
result += map[(bits << 2) & 0x3F];
result += map[64];
} else if (tail === 1) {
result += map[(bits >> 2) & 0x3F];
result += map[(bits << 4) & 0x3F];
result += map[64];
result += map[64];
}

return result;
Expand Down
Loading

0 comments on commit 198385e

Please sign in to comment.