code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function parseRIFF(string) {
var offset = 0;
var chunks = {};
while (offset < string.length) {
var id = string.substr(offset, 4);
var len = getStrLength(string, offset);
var data = string.substr(offset + 4 + 4, len);
offset += 4 + 4 + len;
chunks[id] = chunks[id] || [];
if (id === 'RIFF' || id === 'LIST') {
chunks[id].push(parseRIFF(data));
} else {
chunks[id].push(data);
}
}
return chunks;
}
|
Pass Canvas or Context or image/webp(string) to {@link Whammy} encoder.
@method
@memberof Whammy
@example
recorder = new Whammy().Video(0.8, 100);
recorder.add(canvas || context || 'image/webp');
@param {string} frame - Canvas || Context || image/webp
@param {number} duration - Stick a duration (in milliseconds)
|
parseRIFF
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/Whammy.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/Whammy.js
|
MIT
|
function doubleToString(num) {
return [].slice.call(
new Uint8Array((new Float64Array([num])).buffer), 0).map(function(e) {
return String.fromCharCode(e);
}).reverse().join('');
}
|
Pass Canvas or Context or image/webp(string) to {@link Whammy} encoder.
@method
@memberof Whammy
@example
recorder = new Whammy().Video(0.8, 100);
recorder.add(canvas || context || 'image/webp');
@param {string} frame - Canvas || Context || image/webp
@param {number} duration - Stick a duration (in milliseconds)
|
doubleToString
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/Whammy.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/Whammy.js
|
MIT
|
function drawFrames(frameInterval) {
frameInterval = typeof frameInterval !== 'undefined' ? frameInterval : 10;
var duration = new Date().getTime() - lastTime;
if (!duration) {
return setTimeout(drawFrames, frameInterval, frameInterval);
}
if (isPausedRecording) {
lastTime = new Date().getTime();
return setTimeout(drawFrames, 100);
}
// via #206, by Jack i.e. @Seymourr
lastTime = new Date().getTime();
if (video.paused) {
// via: https://github.com/muaz-khan/WebRTC-Experiment/pull/316
// Tweak for Android Chrome
video.play();
}
context.drawImage(video, 0, 0, canvas.width, canvas.height);
whammy.frames.push({
duration: duration,
image: canvas.toDataURL('image/webp')
});
if (!isStopDrawing) {
setTimeout(drawFrames, frameInterval, frameInterval);
}
}
|
Draw and push frames to Whammy
@param {integer} frameInterval - set minimum interval (in milliseconds) between each time we push a frame to Whammy
|
drawFrames
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/WhammyRecorder.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/WhammyRecorder.js
|
MIT
|
function asyncLoop(o) {
var i = -1,
length = o.length;
(function loop() {
i++;
if (i === length) {
o.callback();
return;
}
// "setTimeout" added by Jim McLeod
setTimeout(function() {
o.functionToLoop(loop, i);
}, 1);
})();
}
|
Draw and push frames to Whammy
@param {integer} frameInterval - set minimum interval (in milliseconds) between each time we push a frame to Whammy
|
asyncLoop
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/WhammyRecorder.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/WhammyRecorder.js
|
MIT
|
function dropBlackFrames(_frames, _framesToCheck, _pixTolerance, _frameTolerance, callback) {
var localCanvas = document.createElement('canvas');
localCanvas.width = canvas.width;
localCanvas.height = canvas.height;
var context2d = localCanvas.getContext('2d');
var resultFrames = [];
var checkUntilNotBlack = _framesToCheck === -1;
var endCheckFrame = (_framesToCheck && _framesToCheck > 0 && _framesToCheck <= _frames.length) ?
_framesToCheck : _frames.length;
var sampleColor = {
r: 0,
g: 0,
b: 0
};
var maxColorDifference = Math.sqrt(
Math.pow(255, 2) +
Math.pow(255, 2) +
Math.pow(255, 2)
);
var pixTolerance = _pixTolerance && _pixTolerance >= 0 && _pixTolerance <= 1 ? _pixTolerance : 0;
var frameTolerance = _frameTolerance && _frameTolerance >= 0 && _frameTolerance <= 1 ? _frameTolerance : 0;
var doNotCheckNext = false;
asyncLoop({
length: endCheckFrame,
functionToLoop: function(loop, f) {
var matchPixCount, endPixCheck, maxPixCount;
var finishImage = function() {
if (!doNotCheckNext && maxPixCount - matchPixCount <= maxPixCount * frameTolerance) {
// console.log('removed black frame : ' + f + ' ; frame duration ' + _frames[f].duration);
} else {
// console.log('frame is passed : ' + f);
if (checkUntilNotBlack) {
doNotCheckNext = true;
}
resultFrames.push(_frames[f]);
}
loop();
};
if (!doNotCheckNext) {
var image = new Image();
image.onload = function() {
context2d.drawImage(image, 0, 0, canvas.width, canvas.height);
var imageData = context2d.getImageData(0, 0, canvas.width, canvas.height);
matchPixCount = 0;
endPixCheck = imageData.data.length;
maxPixCount = imageData.data.length / 4;
for (var pix = 0; pix < endPixCheck; pix += 4) {
var currentColor = {
r: imageData.data[pix],
g: imageData.data[pix + 1],
b: imageData.data[pix + 2]
};
var colorDifference = Math.sqrt(
Math.pow(currentColor.r - sampleColor.r, 2) +
Math.pow(currentColor.g - sampleColor.g, 2) +
Math.pow(currentColor.b - sampleColor.b, 2)
);
// difference in color it is difference in color vectors (r1,g1,b1) <=> (r2,g2,b2)
if (colorDifference <= maxColorDifference * pixTolerance) {
matchPixCount++;
}
}
finishImage();
};
image.src = _frames[f].image;
} else {
finishImage();
}
},
callback: function() {
resultFrames = resultFrames.concat(_frames.slice(endCheckFrame));
if (resultFrames.length <= 0) {
// at least one last frame should be available for next manipulation
// if total duration of all frames will be < 1000 than ffmpeg doesn't work well...
resultFrames.push(_frames[_frames.length - 1]);
}
callback(resultFrames);
}
});
}
|
remove black frames from the beginning to the specified frame
@param {Array} _frames - array of frames to be checked
@param {number} _framesToCheck - number of frame until check will be executed (-1 - will drop all frames until frame not matched will be found)
@param {number} _pixTolerance - 0 - very strict (only black pixel color) ; 1 - all
@param {number} _frameTolerance - 0 - very strict (only black frame color) ; 1 - all
@returns {Array} - array of frames
|
dropBlackFrames
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/WhammyRecorder.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/WhammyRecorder.js
|
MIT
|
finishImage = function() {
if (!doNotCheckNext && maxPixCount - matchPixCount <= maxPixCount * frameTolerance) {
// console.log('removed black frame : ' + f + ' ; frame duration ' + _frames[f].duration);
} else {
// console.log('frame is passed : ' + f);
if (checkUntilNotBlack) {
doNotCheckNext = true;
}
resultFrames.push(_frames[f]);
}
loop();
}
|
remove black frames from the beginning to the specified frame
@param {Array} _frames - array of frames to be checked
@param {number} _framesToCheck - number of frame until check will be executed (-1 - will drop all frames until frame not matched will be found)
@param {number} _pixTolerance - 0 - very strict (only black pixel color) ; 1 - all
@param {number} _frameTolerance - 0 - very strict (only black frame color) ; 1 - all
@returns {Array} - array of frames
|
finishImage
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/WhammyRecorder.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/WhammyRecorder.js
|
MIT
|
function clearRecordedDataCB() {
whammy.frames = [];
isStopDrawing = true;
isPausedRecording = false;
}
|
This method resets currently recorded data.
@method
@memberof WhammyRecorder
@example
recorder.clearRecordedData();
|
clearRecordedDataCB
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/dev/WhammyRecorder.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/dev/WhammyRecorder.js
|
MIT
|
function makeMetadataSeekable(originalMetadata, duration, cuesInfo) {
// extract the header, we can reuse this as-is
var header = extractElement("EBML", originalMetadata);
var headerSize = encodedSizeOfEbml(header);
//console.error("Header size: " + headerSize);
//printElementIds(header);
// After the header comes the Segment open tag, which in this implementation is always 12 bytes (4 byte id, 8 byte 'unknown length')
// After that the segment content starts. All SeekPositions and CueClusterPosition must be relative to segmentContentStartPos
var segmentContentStartPos = headerSize + 12;
//console.error("segmentContentStartPos: " + segmentContentStartPos);
// find the original metadata size, and adjust it for header size and Segment start element so we can keep all positions relative to segmentContentStartPos
var originalMetadataSize = originalMetadata[originalMetadata.length - 1].dataEnd - segmentContentStartPos;
//console.error("Original Metadata size: " + originalMetadataSize);
//printElementIds(originalMetadata);
// extract the segment info, remove the potentially existing Duration element, and add our own one.
var info = extractElement("Info", originalMetadata);
removeElement("Duration", info);
info.splice(1, 0, { name: "Duration", type: "f", data: createFloatBuffer(duration, 8) });
var infoSize = encodedSizeOfEbml(info);
//console.error("Info size: " + infoSize);
//printElementIds(info);
// extract the track info, we can re-use this as is
var tracks = extractElement("Tracks", originalMetadata);
var tracksSize = encodedSizeOfEbml(tracks);
//console.error("Tracks size: " + tracksSize);
//printElementIds(tracks);
var seekHeadSize = 47; // Initial best guess, but could be slightly larger if the Cues element is huge.
var seekHead = [];
var cuesSize = 5 + cuesInfo.length * 15; // very rough initial approximation, depends a lot on file size and number of CuePoints
var cues = [];
var lastSizeDifference = -1; //
// The size of SeekHead and Cues elements depends on how many bytes the offsets values can be encoded in.
// The actual offsets in CueClusterPosition depend on the final size of the SeekHead and Cues elements
// We need to iteratively converge to a stable solution.
var maxIterations = 10;
var _loop_1 = function (i) {
// SeekHead starts at 0
var infoStart = seekHeadSize; // Info comes directly after SeekHead
var tracksStart = infoStart + infoSize; // Tracks comes directly after Info
var cuesStart = tracksStart + tracksSize; // Cues starts directly after
var newMetadataSize = cuesStart + cuesSize; // total size of metadata
// This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing.
var sizeDifference = newMetadataSize - originalMetadataSize;
// console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`);
// console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`);
// console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`);
// console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`);
// create the SeekHead element
seekHead = [];
seekHead.push({ name: "SeekHead", type: "m", isEnd: false });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(infoStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tracksStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(cuesStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "SeekHead", type: "m", isEnd: true });
seekHeadSize = encodedSizeOfEbml(seekHead);
//console.error("SeekHead size: " + seekHeadSize);
//printElementIds(seekHead);
// create the Cues element
cues = [];
cues.push({ name: "Cues", type: "m", isEnd: false });
cuesInfo.forEach(function (_a) {
var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;
cues.push({ name: "CuePoint", type: "m", isEnd: false });
cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: false });
cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) });
//console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`);
// EBMLReader returns CueClusterPosition with absolute byte offsets. The Cues section expects them as offsets from the first level 1 element of the Segment, so we need to adjust it.
CueClusterPosition -= segmentContentStartPos;
// We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata.
CueClusterPosition += sizeDifference;
cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: true });
cues.push({ name: "CuePoint", type: "m", isEnd: true });
});
cues.push({ name: "Cues", type: "m", isEnd: true });
cuesSize = encodedSizeOfEbml(cues);
//console.error("Cues size: " + cuesSize);
//console.error("Cue count: " + cuesInfo.length);
//printElementIds(cues);
// If the new MetadataSize is not the same as the previous iteration, we need to run once more.
if (lastSizeDifference !== sizeDifference) {
lastSizeDifference = sizeDifference;
if (i === maxIterations - 1) {
throw new Error("Failed to converge to a stable metadata size");
}
}
else {
return "break";
}
};
for (var i = 0; i < maxIterations; i++) {
var state_1 = _loop_1(i);
if (state_1 === "break")
break;
}
var finalMetadata = [].concat.apply([], [
header,
{ name: "Segment", type: "m", isEnd: false, unknownSize: true },
seekHead,
info,
tracks,
cues
]);
var result = new EBMLEncoder_1.default().encode(finalMetadata);
//printElementIds(finalMetadata);
//console.error(`Final metadata buffer size: ${result.byteLength}`);
//console.error(`Final metadata buffer size without header and segment: ${result.byteLength-segmentContentStartPos}`);
return result;
}
|
convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues
@param originalMetadata - orginal metadata (everything before the clusters start) from media recorder
@param duration - Duration (TimecodeScale)
@param cues - cue points for clusters
|
makeMetadataSeekable
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
_loop_1 = function (i) {
// SeekHead starts at 0
var infoStart = seekHeadSize; // Info comes directly after SeekHead
var tracksStart = infoStart + infoSize; // Tracks comes directly after Info
var cuesStart = tracksStart + tracksSize; // Cues starts directly after
var newMetadataSize = cuesStart + cuesSize; // total size of metadata
// This is the offset all CueClusterPositions should be adjusted by due to the metadata size changing.
var sizeDifference = newMetadataSize - originalMetadataSize;
// console.error(`infoStart: ${infoStart}, infoSize: ${infoSize}`);
// console.error(`tracksStart: ${tracksStart}, tracksSize: ${tracksSize}`);
// console.error(`cuesStart: ${cuesStart}, cuesSize: ${cuesSize}`);
// console.error(`originalMetadataSize: ${originalMetadataSize}, newMetadataSize: ${newMetadataSize}, sizeDifference: ${sizeDifference}`);
// create the SeekHead element
seekHead = [];
seekHead.push({ name: "SeekHead", type: "m", isEnd: false });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x15, 0x49, 0xA9, 0x66]) }); // Info
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(infoStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x16, 0x54, 0xAE, 0x6B]) }); // Tracks
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(tracksStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "Seek", type: "m", isEnd: false });
seekHead.push({ name: "SeekID", type: "b", data: new exports.Buffer([0x1C, 0x53, 0xBB, 0x6B]) }); // Cues
seekHead.push({ name: "SeekPosition", type: "u", data: createUIntBuffer(cuesStart) });
seekHead.push({ name: "Seek", type: "m", isEnd: true });
seekHead.push({ name: "SeekHead", type: "m", isEnd: true });
seekHeadSize = encodedSizeOfEbml(seekHead);
//console.error("SeekHead size: " + seekHeadSize);
//printElementIds(seekHead);
// create the Cues element
cues = [];
cues.push({ name: "Cues", type: "m", isEnd: false });
cuesInfo.forEach(function (_a) {
var CueTrack = _a.CueTrack, CueClusterPosition = _a.CueClusterPosition, CueTime = _a.CueTime;
cues.push({ name: "CuePoint", type: "m", isEnd: false });
cues.push({ name: "CueTime", type: "u", data: createUIntBuffer(CueTime) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: false });
cues.push({ name: "CueTrack", type: "u", data: createUIntBuffer(CueTrack) });
//console.error(`CueClusterPosition: ${CueClusterPosition}, Corrected to: ${CueClusterPosition - segmentContentStartPos} , offset by ${sizeDifference} to become ${(CueClusterPosition - segmentContentStartPos) + sizeDifference - segmentContentStartPos}`);
// EBMLReader returns CueClusterPosition with absolute byte offsets. The Cues section expects them as offsets from the first level 1 element of the Segment, so we need to adjust it.
CueClusterPosition -= segmentContentStartPos;
// We also need to adjust to take into account the change in metadata size from when EBMLReader read the original metadata.
CueClusterPosition += sizeDifference;
cues.push({ name: "CueClusterPosition", type: "u", data: createUIntBuffer(CueClusterPosition) });
cues.push({ name: "CueTrackPositions", type: "m", isEnd: true });
cues.push({ name: "CuePoint", type: "m", isEnd: true });
});
cues.push({ name: "Cues", type: "m", isEnd: true });
cuesSize = encodedSizeOfEbml(cues);
//console.error("Cues size: " + cuesSize);
//console.error("Cue count: " + cuesInfo.length);
//printElementIds(cues);
// If the new MetadataSize is not the same as the previous iteration, we need to run once more.
if (lastSizeDifference !== sizeDifference) {
lastSizeDifference = sizeDifference;
if (i === maxIterations - 1) {
throw new Error("Failed to converge to a stable metadata size");
}
}
else {
return "break";
}
}
|
convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues
@param originalMetadata - orginal metadata (everything before the clusters start) from media recorder
@param duration - Duration (TimecodeScale)
@param cues - cue points for clusters
|
_loop_1
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function removeElement(idName, metadata) {
var result = [];
var start = -1;
for (var i = 0; i < metadata.length; i++) {
var element = metadata[i];
if (element.name === idName) {
// if it's a Master element, extract the start and end element, and everything in between
if (element.type === "m") {
if (!element.isEnd) {
start = i;
}
else {
// we've reached the end, extract the whole thing
if (start == -1)
throw new Error("Detected " + idName + " closing element before finding the start");
metadata.splice(start, i - start + 1);
return;
}
}
else {
// not a Master element, so we've found what we're looking for.
metadata.splice(i, 1);
return;
}
}
}
}
|
remove all occurances of an EBML element from an array of elements
If it's a MasterElement you will also remove the content. (everything between start and end)
@param idName - name of the EBML Element to remove.
@param metadata - array of EBML elements to search
|
removeElement
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function extractElement(idName, metadata) {
var result = [];
var start = -1;
for (var i = 0; i < metadata.length; i++) {
var element = metadata[i];
if (element.name === idName) {
// if it's a Master element, extract the start and end element, and everything in between
if (element.type === "m") {
if (!element.isEnd) {
start = i;
}
else {
// we've reached the end, extract the whole thing
if (start == -1)
throw new Error("Detected " + idName + " closing element before finding the start");
result = metadata.slice(start, i + 1);
break;
}
}
else {
// not a Master element, so we've found what we're looking for.
result.push(metadata[i]);
break;
}
}
}
return result;
}
|
extract the first occurance of an EBML tag from a flattened array of EBML data.
If it's a MasterElement you will also get the content. (everything between start and end)
@param idName - name of the EBML Element to extract.
@param metadata - array of EBML elements to search
|
extractElement
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function kMaxLength () {
return Buffer.TYPED_ARRAY_SUPPORT
? 0x7fffffff
: 0x3fffffff
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
kMaxLength
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function createBuffer (that, length) {
if (kMaxLength() < length) {
throw new RangeError('Invalid typed array length')
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = new Uint8Array(length)
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
if (that === null) {
that = new Buffer(length)
}
that.length = length
}
return that
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
createBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function Buffer (arg, encodingOrOffset, length) {
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
return new Buffer(arg, encodingOrOffset, length)
}
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new Error(
'If encoding is specified then the first argument must be a string'
)
}
return allocUnsafe(this, arg)
}
return from(this, arg, encodingOrOffset, length)
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
Buffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function from (that, value, encodingOrOffset, length) {
if (typeof value === 'number') {
throw new TypeError('"value" argument must not be a number')
}
if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
return fromArrayBuffer(that, value, encodingOrOffset, length)
}
if (typeof value === 'string') {
return fromString(that, value, encodingOrOffset)
}
return fromObject(that, value)
}
|
Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
if value is a number.
Buffer.from(str[, encoding])
Buffer.from(array)
Buffer.from(buffer)
Buffer.from(arrayBuffer[, byteOffset[, length]])
|
from
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function assertSize (size) {
if (typeof size !== 'number') {
throw new TypeError('"size" argument must be a number')
} else if (size < 0) {
throw new RangeError('"size" argument must not be negative')
}
}
|
Creates a new filled Buffer instance.
alloc(size[, fill[, encoding]])
|
assertSize
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function alloc (that, size, fill, encoding) {
assertSize(size)
if (size <= 0) {
return createBuffer(that, size)
}
if (fill !== undefined) {
// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpretted as a start offset.
return typeof encoding === 'string'
? createBuffer(that, size).fill(fill, encoding)
: createBuffer(that, size).fill(fill)
}
return createBuffer(that, size)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
alloc
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function allocUnsafe (that, size) {
assertSize(size)
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) {
for (var i = 0; i < size; ++i) {
that[i] = 0
}
}
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
allocUnsafe
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromString (that, string, encoding) {
if (typeof encoding !== 'string' || encoding === '') {
encoding = 'utf8'
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError('"encoding" must be a valid string encoding')
}
var length = byteLength(string, encoding) | 0
that = createBuffer(that, length)
var actual = that.write(string, encoding)
if (actual !== length) {
// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
that = that.slice(0, actual)
}
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromString
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromArrayLike (that, array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0
that = createBuffer(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromArrayLike
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromArrayBuffer (that, array, byteOffset, length) {
array.byteLength // this throws if `array` is not a valid ArrayBuffer
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('\'offset\' is out of bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('\'length\' is out of bounds')
}
if (byteOffset === undefined && length === undefined) {
array = new Uint8Array(array)
} else if (length === undefined) {
array = new Uint8Array(array, byteOffset)
} else {
array = new Uint8Array(array, byteOffset, length)
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = array
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
that = fromArrayLike(that, array)
}
return that
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromArrayBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromObject (that, obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0
that = createBuffer(that, len)
if (that.length === 0) {
return that
}
obj.copy(that, 0, 0, len)
return that
}
if (obj) {
if ((typeof ArrayBuffer !== 'undefined' &&
obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
return createBuffer(that, 0)
}
return fromArrayLike(that, obj)
}
if (obj.type === 'Buffer' && isArray(obj.data)) {
return fromArrayLike(that, obj.data)
}
}
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromObject
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checked (length) {
// Note: cannot use `length < kMaxLength()` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= kMaxLength()) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength().toString(16) + ' bytes')
}
return length | 0
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checked
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function SlowBuffer (length) {
if (+length != length) { // eslint-disable-line eqeqeq
length = 0
}
return Buffer.alloc(+length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
SlowBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function byteLength (string, encoding) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
string = '' + string
}
var len = string.length
if (len === 0) return 0
// Use a for loop to avoid recursion
var loweredCase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'latin1':
case 'binary':
return len
case 'utf8':
case 'utf-8':
case undefined:
return utf8ToBytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64ToBytes(string).length
default:
if (loweredCase) return utf8ToBytes(string).length // assume utf8
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
byteLength
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function slowToString (encoding, start, end) {
var loweredCase = false
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if (start === undefined || start < 0) {
start = 0
}
// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if (start > this.length) {
return ''
}
if (end === undefined || end > this.length) {
end = this.length
}
if (end <= 0) {
return ''
}
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
end >>>= 0
start >>>= 0
if (end <= start) {
return ''
}
if (!encoding) encoding = 'utf8'
while (true) {
switch (encoding) {
case 'hex':
return hexSlice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8Slice(this, start, end)
case 'ascii':
return asciiSlice(this, start, end)
case 'latin1':
case 'binary':
return latin1Slice(this, start, end)
case 'base64':
return base64Slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leSlice(this, start, end)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = (encoding + '').toLowerCase()
loweredCase = true
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
slowToString
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function swap (b, n, m) {
var i = b[n]
b[n] = b[m]
b[m] = i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
swap
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
// Empty buffer means no match
if (buffer.length === 0) return -1
// Normalize byteOffset
if (typeof byteOffset === 'string') {
encoding = byteOffset
byteOffset = 0
} else if (byteOffset > 0x7fffffff) {
byteOffset = 0x7fffffff
} else if (byteOffset < -0x80000000) {
byteOffset = -0x80000000
}
byteOffset = +byteOffset // Coerce to Number.
if (isNaN(byteOffset)) {
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset = dir ? 0 : (buffer.length - 1)
}
// Normalize byteOffset: negative offsets start from the end of the buffer
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
if (byteOffset >= buffer.length) {
if (dir) return -1
else byteOffset = buffer.length - 1
} else if (byteOffset < 0) {
if (dir) byteOffset = 0
else return -1
}
// Normalize val
if (typeof val === 'string') {
val = Buffer.from(val, encoding)
}
// Finally, search either indexOf (if dir is true) or lastIndexOf
if (Buffer.isBuffer(val)) {
// Special case: looking for empty string/buffer always fails
if (val.length === 0) {
return -1
}
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
} else if (typeof val === 'number') {
val = val & 0xFF // Search for a byte value [0-255]
if (Buffer.TYPED_ARRAY_SUPPORT &&
typeof Uint8Array.prototype.indexOf === 'function') {
if (dir) {
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
} else {
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
}
}
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
}
throw new TypeError('val must be string, number or Buffer')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
bidirectionalIndexOf
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
var indexSize = 1
var arrLength = arr.length
var valLength = val.length
if (encoding !== undefined) {
encoding = String(encoding).toLowerCase()
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le') {
if (arr.length < 2 || val.length < 2) {
return -1
}
indexSize = 2
arrLength /= 2
valLength /= 2
byteOffset /= 2
}
}
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
var i
if (dir) {
var foundIndex = -1
for (i = byteOffset; i < arrLength; i++) {
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
} else {
if (foundIndex !== -1) i -= i - foundIndex
foundIndex = -1
}
}
} else {
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
for (i = byteOffset; i >= 0; i--) {
var found = true
for (var j = 0; j < valLength; j++) {
if (read(arr, i + j) !== read(val, j)) {
found = false
break
}
}
if (found) return i
}
}
return -1
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
arrayIndexOf
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
read
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
var remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = Number(length)
if (length > remaining) {
length = remaining
}
}
// must be an even number of digits
var strLen = string.length
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
if (length > strLen / 2) {
length = strLen / 2
}
for (var i = 0; i < length; ++i) {
var parsed = parseInt(string.substr(i * 2, 2), 16)
if (isNaN(parsed)) return i
buf[offset + i] = parsed
}
return i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hexWrite
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function asciiWrite (buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiWrite
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function latin1Write (buf, string, offset, length) {
return asciiWrite(buf, string, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
latin1Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64Write (buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function ucs2Write (buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ucs2Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
} else {
return base64.fromByteArray(buf.slice(start, end))
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64Slice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf8Slice (buf, start, end) {
end = Math.min(buf.length, end)
var res = []
var i = start
while (i < end) {
var firstByte = buf[i]
var codePoint = null
var bytesPerSequence = (firstByte > 0xEF) ? 4
: (firstByte > 0xDF) ? 3
: (firstByte > 0xBF) ? 2
: 1
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint
switch (bytesPerSequence) {
case 1:
if (firstByte < 0x80) {
codePoint = firstByte
}
break
case 2:
secondByte = buf[i + 1]
if ((secondByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
if (tempCodePoint > 0x7F) {
codePoint = tempCodePoint
}
}
break
case 3:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
codePoint = tempCodePoint
}
}
break
case 4:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
fourthByte = buf[i + 3]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
codePoint = tempCodePoint
}
}
}
}
if (codePoint === null) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
codePoint = 0xDC00 | codePoint & 0x3FF
}
res.push(codePoint)
i += bytesPerSequence
}
return decodeCodePointsArray(res)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8Slice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function decodeCodePointsArray (codePoints) {
var len = codePoints.length
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
}
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while (i < len) {
res += String.fromCharCode.apply(
String,
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
)
}
return res
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
decodeCodePointsArray
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function asciiSlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i] & 0x7F)
}
return ret
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiSlice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function latin1Slice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i])
}
return ret
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
latin1Slice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function hexSlice (buf, start, end) {
var len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
var out = ''
for (var i = start; i < end; ++i) {
out += toHex(buf[i])
}
return out
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hexSlice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
}
return res
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf16leSlice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checkOffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkOffset
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
if (offset + ext > buf.length) throw new RangeError('Index out of range')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkInt
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function objectWriteUInt16 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
(littleEndian ? i : 1 - i) * 8
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
objectWriteUInt16
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function objectWriteUInt32 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffffffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
objectWriteUInt32
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError('Index out of range')
if (offset < 0) throw new RangeError('Index out of range')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkIEEE754
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
writeFloat
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
}
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
writeDouble
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64clean
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function stringtrim (str) {
if (str.trim) return str.trim()
return str.replace(/^\s+|\s+$/g, '')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
stringtrim
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function toHex (n) {
if (n < 16) return '0' + n.toString(16)
return n.toString(16)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
toHex
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; ++i) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8ToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function asciiToBytes (str) {
var byteArray = []
for (var i = 0; i < str.length; ++i) {
// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF)
}
return byteArray
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf16leToBytes (str, units) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; ++i) {
if ((units -= 2) < 0) break
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf16leToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64ToBytes (str) {
return base64.toByteArray(base64clean(str))
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64ToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; ++i) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
blitBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
isnan
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function createBuffer (length) {
if (length > K_MAX_LENGTH) {
throw new RangeError('The value "' + length + '" is invalid for option "size"')
}
// Return an augmented `Uint8Array` instance
var buf = new Uint8Array(length)
buf.__proto__ = Buffer.prototype
return buf
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
createBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function Buffer (arg, encodingOrOffset, length) {
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new TypeError(
'The "string" argument must be of type string. Received type number'
)
}
return allocUnsafe(arg)
}
return from(arg, encodingOrOffset, length)
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
Buffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function from (value, encodingOrOffset, length) {
if (typeof value === 'string') {
return fromString(value, encodingOrOffset)
}
if (ArrayBuffer.isView(value)) {
return fromArrayLike(value)
}
if (value == null) {
throw TypeError(
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
'or Array-like Object. Received type ' + (typeof value)
)
}
if (isInstance(value, ArrayBuffer) ||
(value && isInstance(value.buffer, ArrayBuffer))) {
return fromArrayBuffer(value, encodingOrOffset, length)
}
if (typeof value === 'number') {
throw new TypeError(
'The "value" argument must not be of type number. Received type number'
)
}
var valueOf = value.valueOf && value.valueOf()
if (valueOf != null && valueOf !== value) {
return Buffer.from(valueOf, encodingOrOffset, length)
}
var b = fromObject(value)
if (b) return b
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
typeof value[Symbol.toPrimitive] === 'function') {
return Buffer.from(
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
)
}
throw new TypeError(
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
'or Array-like Object. Received type ' + (typeof value)
)
}
|
The Buffer constructor returns instances of `Uint8Array` that have their
prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
`Uint8Array`, so the returned instances will have all the node `Buffer` methods
and the `Uint8Array` methods. Square bracket notation works as expected -- it
returns a single octet.
The `Uint8Array` prototype remains unmodified.
|
from
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function assertSize (size) {
if (typeof size !== 'number') {
throw new TypeError('"size" argument must be of type number')
} else if (size < 0) {
throw new RangeError('The value "' + size + '" is invalid for option "size"')
}
}
|
Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
assertSize
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function alloc (size, fill, encoding) {
assertSize(size)
if (size <= 0) {
return createBuffer(size)
}
if (fill !== undefined) {
// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpretted as a start offset.
return typeof encoding === 'string'
? createBuffer(size).fill(fill, encoding)
: createBuffer(size).fill(fill)
}
return createBuffer(size)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
alloc
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function allocUnsafe (size) {
assertSize(size)
return createBuffer(size < 0 ? 0 : checked(size) | 0)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
allocUnsafe
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromString (string, encoding) {
if (typeof encoding !== 'string' || encoding === '') {
encoding = 'utf8'
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError('Unknown encoding: ' + encoding)
}
var length = byteLength(string, encoding) | 0
var buf = createBuffer(length)
var actual = buf.write(string, encoding)
if (actual !== length) {
// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
buf = buf.slice(0, actual)
}
return buf
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromString
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromArrayLike (array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0
var buf = createBuffer(length)
for (var i = 0; i < length; i += 1) {
buf[i] = array[i] & 255
}
return buf
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromArrayLike
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromArrayBuffer (array, byteOffset, length) {
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('"offset" is outside of buffer bounds')
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('"length" is outside of buffer bounds')
}
var buf
if (byteOffset === undefined && length === undefined) {
buf = new Uint8Array(array)
} else if (length === undefined) {
buf = new Uint8Array(array, byteOffset)
} else {
buf = new Uint8Array(array, byteOffset, length)
}
// Return an augmented `Uint8Array` instance
buf.__proto__ = Buffer.prototype
return buf
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromArrayBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function fromObject (obj) {
if (Buffer.isBuffer(obj)) {
var len = checked(obj.length) | 0
var buf = createBuffer(len)
if (buf.length === 0) {
return buf
}
obj.copy(buf, 0, 0, len)
return buf
}
if (obj.length !== undefined) {
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
return createBuffer(0)
}
return fromArrayLike(obj)
}
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
return fromArrayLike(obj.data)
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
fromObject
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checked (length) {
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= K_MAX_LENGTH) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
}
return length | 0
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checked
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function SlowBuffer (length) {
if (+length != length) { // eslint-disable-line eqeqeq
length = 0
}
return Buffer.alloc(+length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
SlowBuffer
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function byteLength (string, encoding) {
if (Buffer.isBuffer(string)) {
return string.length
}
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
return string.byteLength
}
if (typeof string !== 'string') {
throw new TypeError(
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
'Received type ' + typeof string
)
}
var len = string.length
var mustMatch = (arguments.length > 2 && arguments[2] === true)
if (!mustMatch && len === 0) return 0
// Use a for loop to avoid recursion
var loweredCase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'latin1':
case 'binary':
return len
case 'utf8':
case 'utf-8':
return utf8ToBytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64ToBytes(string).length
default:
if (loweredCase) {
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
}
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
byteLength
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function slowToString (encoding, start, end) {
var loweredCase = false
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if (start === undefined || start < 0) {
start = 0
}
// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if (start > this.length) {
return ''
}
if (end === undefined || end > this.length) {
end = this.length
}
if (end <= 0) {
return ''
}
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
end >>>= 0
start >>>= 0
if (end <= start) {
return ''
}
if (!encoding) encoding = 'utf8'
while (true) {
switch (encoding) {
case 'hex':
return hexSlice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8Slice(this, start, end)
case 'ascii':
return asciiSlice(this, start, end)
case 'latin1':
case 'binary':
return latin1Slice(this, start, end)
case 'base64':
return base64Slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leSlice(this, start, end)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = (encoding + '').toLowerCase()
loweredCase = true
}
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
slowToString
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function swap (b, n, m) {
var i = b[n]
b[n] = b[m]
b[m] = i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
swap
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
// Empty buffer means no match
if (buffer.length === 0) return -1
// Normalize byteOffset
if (typeof byteOffset === 'string') {
encoding = byteOffset
byteOffset = 0
} else if (byteOffset > 0x7fffffff) {
byteOffset = 0x7fffffff
} else if (byteOffset < -0x80000000) {
byteOffset = -0x80000000
}
byteOffset = +byteOffset // Coerce to Number.
if (numberIsNaN(byteOffset)) {
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset = dir ? 0 : (buffer.length - 1)
}
// Normalize byteOffset: negative offsets start from the end of the buffer
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
if (byteOffset >= buffer.length) {
if (dir) return -1
else byteOffset = buffer.length - 1
} else if (byteOffset < 0) {
if (dir) byteOffset = 0
else return -1
}
// Normalize val
if (typeof val === 'string') {
val = Buffer.from(val, encoding)
}
// Finally, search either indexOf (if dir is true) or lastIndexOf
if (Buffer.isBuffer(val)) {
// Special case: looking for empty string/buffer always fails
if (val.length === 0) {
return -1
}
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
} else if (typeof val === 'number') {
val = val & 0xFF // Search for a byte value [0-255]
if (typeof Uint8Array.prototype.indexOf === 'function') {
if (dir) {
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
} else {
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
}
}
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
}
throw new TypeError('val must be string, number or Buffer')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
bidirectionalIndexOf
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
var indexSize = 1
var arrLength = arr.length
var valLength = val.length
if (encoding !== undefined) {
encoding = String(encoding).toLowerCase()
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le') {
if (arr.length < 2 || val.length < 2) {
return -1
}
indexSize = 2
arrLength /= 2
valLength /= 2
byteOffset /= 2
}
}
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
var i
if (dir) {
var foundIndex = -1
for (i = byteOffset; i < arrLength; i++) {
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
} else {
if (foundIndex !== -1) i -= i - foundIndex
foundIndex = -1
}
}
} else {
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
for (i = byteOffset; i >= 0; i--) {
var found = true
for (var j = 0; j < valLength; j++) {
if (read(arr, i + j) !== read(val, j)) {
found = false
break
}
}
if (found) return i
}
}
return -1
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
arrayIndexOf
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function read (buf, i) {
if (indexSize === 1) {
return buf[i]
} else {
return buf.readUInt16BE(i * indexSize)
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
read
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
var remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = Number(length)
if (length > remaining) {
length = remaining
}
}
var strLen = string.length
if (length > strLen / 2) {
length = strLen / 2
}
for (var i = 0; i < length; ++i) {
var parsed = parseInt(string.substr(i * 2, 2), 16)
if (numberIsNaN(parsed)) return i
buf[offset + i] = parsed
}
return i
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hexWrite
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function asciiWrite (buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiWrite
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function latin1Write (buf, string, offset, length) {
return asciiWrite(buf, string, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
latin1Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64Write (buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function ucs2Write (buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
ucs2Write
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
} else {
return base64.fromByteArray(buf.slice(start, end))
}
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64Slice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf8Slice (buf, start, end) {
end = Math.min(buf.length, end)
var res = []
var i = start
while (i < end) {
var firstByte = buf[i]
var codePoint = null
var bytesPerSequence = (firstByte > 0xEF) ? 4
: (firstByte > 0xDF) ? 3
: (firstByte > 0xBF) ? 2
: 1
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint
switch (bytesPerSequence) {
case 1:
if (firstByte < 0x80) {
codePoint = firstByte
}
break
case 2:
secondByte = buf[i + 1]
if ((secondByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
if (tempCodePoint > 0x7F) {
codePoint = tempCodePoint
}
}
break
case 3:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
codePoint = tempCodePoint
}
}
break
case 4:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
fourthByte = buf[i + 3]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
codePoint = tempCodePoint
}
}
}
}
if (codePoint === null) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
codePoint = 0xDC00 | codePoint & 0x3FF
}
res.push(codePoint)
i += bytesPerSequence
}
return decodeCodePointsArray(res)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8Slice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function decodeCodePointsArray (codePoints) {
var len = codePoints.length
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
}
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while (i < len) {
res += String.fromCharCode.apply(
String,
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
)
}
return res
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
decodeCodePointsArray
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function asciiSlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i] & 0x7F)
}
return ret
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiSlice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function latin1Slice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; ++i) {
ret += String.fromCharCode(buf[i])
}
return ret
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
latin1Slice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function hexSlice (buf, start, end) {
var len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
var out = ''
for (var i = start; i < end; ++i) {
out += toHex(buf[i])
}
return out
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
hexSlice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
}
return res
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf16leSlice
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checkOffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkOffset
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
if (offset + ext > buf.length) throw new RangeError('Index out of range')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkInt
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new RangeError('Index out of range')
if (offset < 0) throw new RangeError('Index out of range')
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
checkIEEE754
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
writeFloat
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
value = +value
offset = offset >>> 0
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
}
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
writeDouble
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function base64clean (str) {
// Node takes equal signs as end of the Base64 encoding
str = str.split('=')[0]
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = str.trim().replace(INVALID_BASE64_RE, '')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
base64clean
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function toHex (n) {
if (n < 16) return '0' + n.toString(16)
return n.toString(16)
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
toHex
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; ++i) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf8ToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function asciiToBytes (str) {
var byteArray = []
for (var i = 0; i < str.length; ++i) {
// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF)
}
return byteArray
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
asciiToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
function utf16leToBytes (str, units) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; ++i) {
if ((units -= 2) < 0) break
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
|
Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
utf16leToBytes
|
javascript
|
muaz-khan/WebRTC-Experiment
|
RecordRTC/libs/EBML.js
|
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/RecordRTC/libs/EBML.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.