mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 10:49:36 +02:00
New updates and modules
This commit is contained in:
parent
4d5d408898
commit
0abf0f90f6
959 changed files with 364301 additions and 17493 deletions
44
node_modules/level-js/util/deserialize.js
generated
vendored
Normal file
44
node_modules/level-js/util/deserialize.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict'
|
||||
|
||||
var Buffer = require('buffer').Buffer
|
||||
var ta2str = (function () {
|
||||
if (global.TextDecoder) {
|
||||
var decoder = new TextDecoder('utf-8')
|
||||
return decoder.decode.bind(decoder)
|
||||
} else {
|
||||
return function ta2str (ta) {
|
||||
return ta2buf(ta).toString()
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
var ab2str = (function () {
|
||||
if (global.TextDecoder) {
|
||||
var decoder = new TextDecoder('utf-8')
|
||||
return decoder.decode.bind(decoder)
|
||||
} else {
|
||||
return function ab2str (ab) {
|
||||
return Buffer.from(ab).toString()
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
function ta2buf (ta) {
|
||||
var buf = Buffer.from(ta.buffer)
|
||||
|
||||
if (ta.byteLength === ta.buffer.byteLength) {
|
||||
return buf
|
||||
} else {
|
||||
return buf.slice(ta.byteOffset, ta.byteOffset + ta.byteLength)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (data, asBuffer) {
|
||||
if (data instanceof Uint8Array) {
|
||||
return asBuffer ? ta2buf(data) : ta2str(data)
|
||||
} else if (data instanceof ArrayBuffer) {
|
||||
return asBuffer ? Buffer.from(data) : ab2str(data)
|
||||
} else {
|
||||
return asBuffer ? Buffer.from(String(data)) : String(data)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue