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 JSONPPolling (socket) {
io.Transport['xhr-polling'].apply(this, arguments);
this.index = io.j.length;
var self = this;
io.j.push(function (msg) {
self._(msg);
});
} | The JSONP transport creates an persistent connection by dynamically
inserting a script tag in the page. This script tag will receive the
information of the Socket.IO server. When new information is received
it creates a new script tag for the new data stream.
@constructor
@extends {io.Transport.xhr-polling}
@api publi... | JSONPPolling | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function complete () {
initIframe();
self.socket.setBuffer(false);
} | Posts a encoded message to the Socket.IO server using an iframe.
The iframe is used because script tags can create POST based requests.
The iframe is positioned outside of the view so the user does not
notice it's existence.
@param {String} data A encoded message.
@api private | complete | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function initIframe () {
if (self.iframe) {
self.form.removeChild(self.iframe);
}
try {
// ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
iframe = document.createElement('<iframe name="'+ self.iframeId +'">');
} catch (e) {
iframe = document.... | Posts a encoded message to the Socket.IO server using an iframe.
The iframe is used because script tags can create POST based requests.
The iframe is positioned outside of the view so the user does not
notice it's existence.
@param {String} data A encoded message.
@api private | initIframe | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.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 ... | 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... | Buffer | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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... | 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... | from | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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')
}
} | 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]]) | assertSize | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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.
r... | 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]]) | alloc | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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
} | Creates a new filled Buffer instance.
alloc(size[, fill[, encoding]]) | allocUnsafe | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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, ... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | fromString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | fromArrayBuffer | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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.buffe... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | fromObject | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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().... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | checked | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 !== '... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | byteLength | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 ... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | slowToString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 = 0x7fffff... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | bidirectionalIndexOf | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 ===... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | arrayIndexOf | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 = str... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | hexWrite | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 + bytesPer... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | utf8Slice | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 += Strin... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | decodeCodePointsArray | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | base64clean | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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) {
... | Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | utf8ToBytes | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.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 | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function calcLengthLength (length) {
if (length >= 0 && length < 128) return 1
else if (length >= 128 && length < 16384) return 2
else if (length >= 16384 && length < 2097152) return 3
else if (length >= 2097152 && length < 268435456) return 4
else return 0
} | calcLengthLength - calculate the length of the remaining
length field
@api private | calcLengthLength | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function genBufLength (length) {
var digit = 0
var pos = 0
var buffer = new Buffer(calcLengthLength(length))
do {
digit = length % 128 | 0
length = length / 128 | 0
if (length > 0) digit = digit | 0x80
buffer.writeUInt8(digit, pos++, true)
} while (length > 0)
return buffer
} | calcLengthLength - calculate the length of the remaining
length field
@api private | genBufLength | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function writeLength (stream, length) {
var buffer = lengthCache[length]
if (!buffer) {
buffer = genBufLength(length)
if (length < 16384) lengthCache[length] = buffer
}
stream.write(buffer)
} | writeLength - write an MQTT style length field to the buffer
@param <Buffer> buffer - destination
@param <Number> pos - offset
@param <Number> length - length (>0)
@returns <Number> number of bytes written
@api private | writeLength | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function writeString (stream, string) {
var strlen = Buffer.byteLength(string)
writeNumber(stream, strlen)
stream.write(string, 'utf8')
} | writeString - write a utf8 string to the buffer
@param <Buffer> buffer - destination
@param <Number> pos - offset
@param <String> string - string to write
@return <Number> number of bytes written
@api private | writeString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function writeNumber (stream, number) {
return stream.write(numCache[number])
} | writeNumber - write a two byte number to the buffer
@param <Buffer> buffer - destination
@param <Number> pos - offset
@param <String> number - number to write
@return <Number> number of bytes written
@api private | writeNumber | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function writeStringOrBuffer (stream, toWrite) {
if (toWrite && typeof toWrite === 'string') writeString(stream, toWrite)
else if (toWrite) {
writeNumber(stream, toWrite.length)
stream.write(toWrite)
} else writeNumber(stream, 0)
} | writeStringOrBuffer - write a String or Buffer with the its length prefix
@param <Buffer> buffer - destination
@param <Number> pos - offset
@param <String> toWrite - String or Buffer
@return <Number> number of bytes written | writeStringOrBuffer | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function byteLength (bufOrString) {
if (!bufOrString) return 0
else if (Buffer.isBuffer(bufOrString)) return bufOrString.length
else return Buffer.byteLength(bufOrString)
} | writeStringOrBuffer - write a String or Buffer with the its length prefix
@param <Buffer> buffer - destination
@param <Number> pos - offset
@param <String> toWrite - String or Buffer
@return <Number> number of bytes written | byteLength | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function inspect(obj, opts) {
// default options
var ctx = {
seen: [],
stylize: stylizeNoColor
};
// legacy...
if (arguments.length >= 3) ctx.depth = arguments[2];
if (arguments.length >= 4) ctx.colors = arguments[3];
if (isBoolean(opts)) {
// legacy...
ctx.showHidden = opts;
} else if (... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | inspect | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function stylizeWithColor(str, styleType) {
var style = inspect.styles[styleType];
if (style) {
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
'\u001b[' + inspect.colors[style][1] + 'm';
} else {
return str;
}
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | stylizeWithColor | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function stylizeNoColor(str, styleType) {
return str;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | stylizeNoColor | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | arrayToHash | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (ctx.customInspect &&
value &&
isFunction(value.inspect) &&
// Filter out the util module, it's inspect function is special
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatValue | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function formatPrimitive(ctx, value) {
if (isUndefined(value))
return ctx.stylize('undefined', 'undefined');
if (isString(value)) {
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatPrimitive | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatError | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatArray | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str, desc;
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
if (desc.get) {
if (desc.set) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]',... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | formatProperty | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
}, 0);
if (length > 60) {
return braces[0] +
... | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | reduceToSingleString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isArray(ar) {
return Array.isArray(ar);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isArray | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isBoolean(arg) {
return typeof arg === 'boolean';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isBoolean | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isNull(arg) {
return arg === null;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isNull | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isNullOrUndefined(arg) {
return arg == null;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isNullOrUndefined | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isNumber(arg) {
return typeof arg === 'number';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isNumber | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isString(arg) {
return typeof arg === 'string';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isSymbol(arg) {
return typeof arg === 'symbol';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isSymbol | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isUndefined(arg) {
return arg === void 0;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isUndefined | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isRegExp | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isObject | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isDate | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isError(e) {
return isObject(e) &&
(objectToString(e) === '[object Error]' || e instanceof Error);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isError | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isFunction(arg) {
return typeof arg === 'function';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isFunction | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function isPrimitive(arg) {
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | isPrimitive | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function objectToString(o) {
return Object.prototype.toString.call(o);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | objectToString | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | pad | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
} | Echos the value of a value. Trys to print the value out
in the best way possible given the different types.
@param {Object} obj The object to print out.
@param {Object} opts Optional options object that alters the output. | timestamp | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
} | Inherit the prototype methods from one constructor into another.
The Function.prototype.inherits from lang.js rewritten as a standalone
function (not on Function.prototype). NOTE: If this file is to be loaded
during bootstrapping this function needs to be rewritten using some native
functions as prototype setup using ... | hasOwnProperty | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function MqttClient (streamBuilder, options) {
var k
var that = this
if (!(this instanceof MqttClient)) {
return new MqttClient(streamBuilder, options)
}
this.options = options || {}
// Defaults
for (k in defaultConnectOptions) {
if (typeof this.options[k] === 'undefined') {
this.options[... | MqttClient constructor
@param {Stream} stream - stream
@param {Object} [options] - connection options
(see Connection#connect) | MqttClient | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function storeDeliver () {
var packet = outStore.read(1)
var cb
if (!packet) {
return
}
// Avoid unnecesary stream read operations when disconnected
if (!that.disconnecting && !that.reconnectTimer && that.options.reconnectPeriod > 0) {
outStore.read(... | MqttClient constructor
@param {Stream} stream - stream
@param {Object} [options] - connection options
(see Connection#connect) | storeDeliver | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function deliver () {
var entry = queue.shift()
var packet = null
if (!entry) {
return
}
packet = entry.packet
that._sendPacket(
packet,
function (err) {
if (entry.cb) {
entry.cb(err)
}
deliver()
}
)
... | MqttClient constructor
@param {Stream} stream - stream
@param {Object} [options] - connection options
(see Connection#connect) | deliver | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function process () {
var packet = packets.shift()
var done = completeParse
if (packet) {
that._handlePacket(packet, process)
} else {
completeParse = null
done()
}
} | setup the event handlers in the inner stream.
@api private | process | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function closeStores () {
that.disconnected = true
that.incomingStore.close(function () {
that.outgoingStore.close(cb)
})
} | end - close connection
@returns {MqttClient} this - for chaining
@param {Boolean} force - do not wait for all in-flight messages to be acked
@param {Function} cb - called when the client has been closed
@api public | closeStores | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function finish () {
// defer closesStores of an I/O cycle,
// just to make sure things are
// ok for websockets
that._cleanUp(force, setImmediate.bind(null, closeStores))
} | end - close connection
@returns {MqttClient} this - for chaining
@param {Boolean} force - do not wait for all in-flight messages to be acked
@param {Function} cb - called when the client has been closed
@api public | finish | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function Store () {
if (!(this instanceof Store)) {
return new Store()
}
this._inflights = {}
} | In-memory implementation of the message store
This can actually be saved into files. | Store | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function validateTopic (topic) {
var parts = topic.split('/')
for (var i = 0; i < parts.length; i++) {
if (parts[i] === '+') {
continue
}
if (parts[i] === '#') {
// for Rule #2
return i === parts.length - 1
}
if (parts[i].indexOf('+') !== -1 || parts[i].indexOf('#') !== -1) ... | Validate a topic to see if it's valid or not.
A topic is valid if it follow below rules:
- Rule #1: If any part of the topic is not `+` or `#`, then it must not contain `+` and '#'
- Rule #2: Part `#` must be located at the end of the mailbox
@param {String} topic - A topic
@returns {Boolean} If the topic is valid, re... | validateTopic | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function validateTopics (topics) {
if (topics.length === 0) {
return 'empty_topic_list'
}
for (var i = 0; i < topics.length; i++) {
if (!validateTopic(topics[i])) {
return topics[i]
}
}
return null
} | Validate an array of topics to see if any of them is valid or not
@param {Array} topics - Array of topics
@returns {String} If the topics is valid, returns null. Otherwise, returns the invalid one | validateTopics | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function deprecate (fn, msg) {
if (config('noDeprecation')) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (config('throwDeprecation')) {
throw new Error(msg);
} else if (config('traceDeprecation')) {
console.trace(msg);
} else {
c... | Mark that a method should not be used.
Returns a modified function which warns once by default.
If `localStorage.noDeprecation = true` is set, then it is a no-op.
If `localStorage.throwDeprecation = true` is set, then deprecated functions
will throw an Error when invoked.
If `localStorage.traceDeprecation = true` is... | deprecate | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function deprecated() {
if (!warned) {
if (config('throwDeprecation')) {
throw new Error(msg);
} else if (config('traceDeprecation')) {
console.trace(msg);
} else {
console.warn(msg);
}
warned = true;
}
return fn.apply(this, arguments);
} | Mark that a method should not be used.
Returns a modified function which warns once by default.
If `localStorage.noDeprecation = true` is set, then it is a no-op.
If `localStorage.throwDeprecation = true` is set, then deprecated functions
will throw an Error when invoked.
If `localStorage.traceDeprecation = true` is... | deprecated | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function config (name) {
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
try {
if (!global.localStorage) return false;
} catch (_) {
return false;
}
var val = global.localStorage[name];
if (null == val) return false;
return String(val).toLowerCase() === 'true';
} | Checks `localStorage` for boolean values for the given `name`.
@param {String} name
@returns {Boolean}
@api private | config | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function error(type) {
throw new RangeError(errors[type]);
} | A generic error utility function.
@private
@param {String} type The error type.
@returns {Error} Throws a `RangeError` with the applicable error message. | error | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function map(array, fn) {
var length = array.length;
var result = [];
while (length--) {
result[length] = fn(array[length]);
}
return result;
} | A generic `Array#map` utility function.
@private
@param {Array} array The array to iterate over.
@param {Function} callback The function that gets called for every array
item.
@returns {Array} A new array of values returned by the callback function. | map | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function mapDomain(string, fn) {
var parts = string.split('@');
var result = '';
if (parts.length > 1) {
// In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact.
result = parts[0] + '@';
string = parts[1];
}
// Avoid `split(regex)... | A simple `Array#map`-like wrapper to work with domain name strings or email
addresses.
@private
@param {String} domain The domain name or email address.
@param {Function} callback The function that gets called for every
character.
@returns {Array} A new string of characters returned by the callback
function. | mapDomain | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
function ucs2decode(string) {
var output = [],
counter = 0,
length = string.length,
value,
extra;
while (counter < length) {
value = string.charCodeAt(counter++);
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
// high surrogate, and there is a next character
extr... | Creates an array containing the numeric code points of each Unicode
character in the string. While JavaScript uses UCS-2 internally,
this function will convert a pair of surrogate halves (each of which
UCS-2 exposes as separate characters) into a single code point,
matching UTF-16.
@see `punycode.ucs2.encode`
@see <htt... | ucs2decode | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/util/browserMqtt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/util/browserMqtt.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.