mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
New updates and modules
This commit is contained in:
parent
4d5d408898
commit
0abf0f90f6
959 changed files with 364301 additions and 17493 deletions
66
node_modules/level-codec/lib/encodings.js
generated
vendored
Normal file
66
node_modules/level-codec/lib/encodings.js
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
var Buffer = require('buffer').Buffer
|
||||
|
||||
exports.utf8 = exports['utf-8'] = {
|
||||
encode: function (data) {
|
||||
return isBinary(data) ? data : String(data)
|
||||
},
|
||||
decode: identity,
|
||||
buffer: false,
|
||||
type: 'utf8'
|
||||
}
|
||||
|
||||
exports.json = {
|
||||
encode: JSON.stringify,
|
||||
decode: JSON.parse,
|
||||
buffer: false,
|
||||
type: 'json'
|
||||
}
|
||||
|
||||
exports.binary = {
|
||||
encode: function (data) {
|
||||
return isBinary(data) ? data : Buffer.from(data)
|
||||
},
|
||||
decode: identity,
|
||||
buffer: true,
|
||||
type: 'binary'
|
||||
}
|
||||
|
||||
exports.none = {
|
||||
encode: identity,
|
||||
decode: identity,
|
||||
buffer: false,
|
||||
type: 'id'
|
||||
}
|
||||
|
||||
exports.id = exports.none
|
||||
|
||||
var bufferEncodings = [
|
||||
'hex',
|
||||
'ascii',
|
||||
'base64',
|
||||
'ucs2',
|
||||
'ucs-2',
|
||||
'utf16le',
|
||||
'utf-16le'
|
||||
]
|
||||
|
||||
bufferEncodings.forEach(function (type) {
|
||||
exports[type] = {
|
||||
encode: function (data) {
|
||||
return isBinary(data) ? data : Buffer.from(data, type)
|
||||
},
|
||||
decode: function (buffer) {
|
||||
return buffer.toString(type)
|
||||
},
|
||||
buffer: true,
|
||||
type: type
|
||||
}
|
||||
})
|
||||
|
||||
function identity (value) {
|
||||
return value
|
||||
}
|
||||
|
||||
function isBinary (data) {
|
||||
return data === undefined || data === null || Buffer.isBuffer(data)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue