id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
12,400
citronneur/node-rdpjs
lib/protocol/t125/per.js
readNumericString
function readNumericString(s, minValue) { var length = readLength(s); length = (length + minValue + 1) / 2; s.readPadding(length); }
javascript
function readNumericString(s, minValue) { var length = readLength(s); length = (length + minValue + 1) / 2; s.readPadding(length); }
[ "function", "readNumericString", "(", "s", ",", "minValue", ")", "{", "var", "length", "=", "readLength", "(", "s", ")", ";", "length", "=", "(", "length", "+", "minValue", "+", "1", ")", "/", "2", ";", "s", ".", "readPadding", "(", "length", ")", ";", "}" ]
Read as padding... @param s {type.Stream} @param minValue
[ "Read", "as", "padding", "..." ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/per.js#L215-L219
12,401
citronneur/node-rdpjs
lib/security/jsbn.js
bnToBuffer
function bnToBuffer(trimOrSize) { var res = new Buffer(this.toByteArray()); if (trimOrSize === true && res[0] === 0) { res = res.slice(1); } else if (_.isNumber(trimOrSize)) { if (res.length > trimOrSize) { for (var i = 0; i < res.length - trimOrSize; i++) { if (res[i] !== 0) { return null; } } return res.slice(res.length - trimOrSize); } else if (res.length < trimOrSize) { var padded = new Buffer(trimOrSize); padded.fill(0, 0, trimOrSize - res.length); res.copy(padded, trimOrSize - res.length); return padded; } } return res; }
javascript
function bnToBuffer(trimOrSize) { var res = new Buffer(this.toByteArray()); if (trimOrSize === true && res[0] === 0) { res = res.slice(1); } else if (_.isNumber(trimOrSize)) { if (res.length > trimOrSize) { for (var i = 0; i < res.length - trimOrSize; i++) { if (res[i] !== 0) { return null; } } return res.slice(res.length - trimOrSize); } else if (res.length < trimOrSize) { var padded = new Buffer(trimOrSize); padded.fill(0, 0, trimOrSize - res.length); res.copy(padded, trimOrSize - res.length); return padded; } } return res; }
[ "function", "bnToBuffer", "(", "trimOrSize", ")", "{", "var", "res", "=", "new", "Buffer", "(", "this", ".", "toByteArray", "(", ")", ")", ";", "if", "(", "trimOrSize", "===", "true", "&&", "res", "[", "0", "]", "===", "0", ")", "{", "res", "=", "res", ".", "slice", "(", "1", ")", ";", "}", "else", "if", "(", "_", ".", "isNumber", "(", "trimOrSize", ")", ")", "{", "if", "(", "res", ".", "length", ">", "trimOrSize", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "res", ".", "length", "-", "trimOrSize", ";", "i", "++", ")", "{", "if", "(", "res", "[", "i", "]", "!==", "0", ")", "{", "return", "null", ";", "}", "}", "return", "res", ".", "slice", "(", "res", ".", "length", "-", "trimOrSize", ")", ";", "}", "else", "if", "(", "res", ".", "length", "<", "trimOrSize", ")", "{", "var", "padded", "=", "new", "Buffer", "(", "trimOrSize", ")", ";", "padded", ".", "fill", "(", "0", ",", "0", ",", "trimOrSize", "-", "res", ".", "length", ")", ";", "res", ".", "copy", "(", "padded", ",", "trimOrSize", "-", "res", ".", "length", ")", ";", "return", "padded", ";", "}", "}", "return", "res", ";", "}" ]
return Buffer object @param trim {boolean} slice buffer if first element == 0 @returns {Buffer}
[ "return", "Buffer", "object" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/security/jsbn.js#L831-L851
12,402
citronneur/node-rdpjs
lib/protocol/pdu/global.js
Global
function Global(transport, fastPathTransport) { this.transport = transport; this.fastPathTransport = fastPathTransport; // must be init via connect event this.userId = 0; this.serverCapabilities = []; this.clientCapabilities = []; }
javascript
function Global(transport, fastPathTransport) { this.transport = transport; this.fastPathTransport = fastPathTransport; // must be init via connect event this.userId = 0; this.serverCapabilities = []; this.clientCapabilities = []; }
[ "function", "Global", "(", "transport", ",", "fastPathTransport", ")", "{", "this", ".", "transport", "=", "transport", ";", "this", ".", "fastPathTransport", "=", "fastPathTransport", ";", "// must be init via connect event", "this", ".", "userId", "=", "0", ";", "this", ".", "serverCapabilities", "=", "[", "]", ";", "this", ".", "clientCapabilities", "=", "[", "]", ";", "}" ]
Global channel for all graphic updates capabilities exchange and input handles
[ "Global", "channel", "for", "all", "graphic", "updates", "capabilities", "exchange", "and", "input", "handles" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/global.js#L31-L38
12,403
citronneur/node-rdpjs
lib/protocol/rdp.js
decompress
function decompress (bitmap) { var fName = null; switch (bitmap.bitsPerPixel.value) { case 15: fName = 'bitmap_decompress_15'; break; case 16: fName = 'bitmap_decompress_16'; break; case 24: fName = 'bitmap_decompress_24'; break; case 32: fName = 'bitmap_decompress_32'; break; default: throw 'invalid bitmap data format'; } var input = new Uint8Array(bitmap.bitmapDataStream.value); var inputPtr = rle._malloc(input.length); var inputHeap = new Uint8Array(rle.HEAPU8.buffer, inputPtr, input.length); inputHeap.set(input); var ouputSize = bitmap.width.value * bitmap.height.value * 4; var outputPtr = rle._malloc(ouputSize); var outputHeap = new Uint8Array(rle.HEAPU8.buffer, outputPtr, ouputSize); var res = rle.ccall(fName, 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number', 'number'], [outputHeap.byteOffset, bitmap.width.value, bitmap.height.value, bitmap.width.value, bitmap.height.value, inputHeap.byteOffset, input.length] ); var output = new Uint8ClampedArray(outputHeap.buffer, outputHeap.byteOffset, ouputSize); rle._free(inputPtr); rle._free(outputPtr); return output; }
javascript
function decompress (bitmap) { var fName = null; switch (bitmap.bitsPerPixel.value) { case 15: fName = 'bitmap_decompress_15'; break; case 16: fName = 'bitmap_decompress_16'; break; case 24: fName = 'bitmap_decompress_24'; break; case 32: fName = 'bitmap_decompress_32'; break; default: throw 'invalid bitmap data format'; } var input = new Uint8Array(bitmap.bitmapDataStream.value); var inputPtr = rle._malloc(input.length); var inputHeap = new Uint8Array(rle.HEAPU8.buffer, inputPtr, input.length); inputHeap.set(input); var ouputSize = bitmap.width.value * bitmap.height.value * 4; var outputPtr = rle._malloc(ouputSize); var outputHeap = new Uint8Array(rle.HEAPU8.buffer, outputPtr, ouputSize); var res = rle.ccall(fName, 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number', 'number'], [outputHeap.byteOffset, bitmap.width.value, bitmap.height.value, bitmap.width.value, bitmap.height.value, inputHeap.byteOffset, input.length] ); var output = new Uint8ClampedArray(outputHeap.buffer, outputHeap.byteOffset, ouputSize); rle._free(inputPtr); rle._free(outputPtr); return output; }
[ "function", "decompress", "(", "bitmap", ")", "{", "var", "fName", "=", "null", ";", "switch", "(", "bitmap", ".", "bitsPerPixel", ".", "value", ")", "{", "case", "15", ":", "fName", "=", "'bitmap_decompress_15'", ";", "break", ";", "case", "16", ":", "fName", "=", "'bitmap_decompress_16'", ";", "break", ";", "case", "24", ":", "fName", "=", "'bitmap_decompress_24'", ";", "break", ";", "case", "32", ":", "fName", "=", "'bitmap_decompress_32'", ";", "break", ";", "default", ":", "throw", "'invalid bitmap data format'", ";", "}", "var", "input", "=", "new", "Uint8Array", "(", "bitmap", ".", "bitmapDataStream", ".", "value", ")", ";", "var", "inputPtr", "=", "rle", ".", "_malloc", "(", "input", ".", "length", ")", ";", "var", "inputHeap", "=", "new", "Uint8Array", "(", "rle", ".", "HEAPU8", ".", "buffer", ",", "inputPtr", ",", "input", ".", "length", ")", ";", "inputHeap", ".", "set", "(", "input", ")", ";", "var", "ouputSize", "=", "bitmap", ".", "width", ".", "value", "*", "bitmap", ".", "height", ".", "value", "*", "4", ";", "var", "outputPtr", "=", "rle", ".", "_malloc", "(", "ouputSize", ")", ";", "var", "outputHeap", "=", "new", "Uint8Array", "(", "rle", ".", "HEAPU8", ".", "buffer", ",", "outputPtr", ",", "ouputSize", ")", ";", "var", "res", "=", "rle", ".", "ccall", "(", "fName", ",", "'number'", ",", "[", "'number'", ",", "'number'", ",", "'number'", ",", "'number'", ",", "'number'", ",", "'number'", ",", "'number'", ",", "'number'", "]", ",", "[", "outputHeap", ".", "byteOffset", ",", "bitmap", ".", "width", ".", "value", ",", "bitmap", ".", "height", ".", "value", ",", "bitmap", ".", "width", ".", "value", ",", "bitmap", ".", "height", ".", "value", ",", "inputHeap", ".", "byteOffset", ",", "input", ".", "length", "]", ")", ";", "var", "output", "=", "new", "Uint8ClampedArray", "(", "outputHeap", ".", "buffer", ",", "outputHeap", ".", "byteOffset", ",", "ouputSize", ")", ";", "rle", ".", "_free", "(", "inputPtr", ")", ";", "rle", ".", "_free", "(", "outputPtr", ")", ";", "return", "output", ";", "}" ]
decompress bitmap from RLE algorithm @param bitmap {object} bitmap object of bitmap event of node-rdpjs
[ "decompress", "bitmap", "from", "RLE", "algorithm" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/rdp.js#L36-L77
12,404
citronneur/node-rdpjs
lib/protocol/rdp.js
RdpClient
function RdpClient(config) { config = config || {}; this.connected = false; this.bufferLayer = new layer.BufferLayer(new net.Socket()); this.tpkt = new TPKT(this.bufferLayer); this.x224 = new x224.Client(this.tpkt); this.mcs = new t125.mcs.Client(this.x224); this.sec = new pdu.sec.Client(this.mcs, this.tpkt); this.global = new pdu.global.Client(this.sec, this.sec); // config log level log.level = log.Levels[config.logLevel || 'INFO'] || log.Levels.INFO; // credentials if (config.domain) { this.sec.infos.obj.domain.value = new Buffer(config.domain + '\x00', 'ucs2'); } if (config.userName) { this.sec.infos.obj.userName.value = new Buffer(config.userName + '\x00', 'ucs2'); } if (config.password) { this.sec.infos.obj.password.value = new Buffer(config.password + '\x00', 'ucs2'); } if (config.enablePerf) { this.sec.infos.obj.extendedInfo.obj.performanceFlags.value = pdu.sec.PerfFlag.PERF_DISABLE_WALLPAPER | pdu.sec.PerfFlag.PERF_DISABLE_MENUANIMATIONS | pdu.sec.PerfFlag.PERF_DISABLE_CURSOR_SHADOW | pdu.sec.PerfFlag.PERF_DISABLE_THEMING | pdu.sec.PerfFlag.PERF_DISABLE_FULLWINDOWDRAG; } if (config.autoLogin) { this.sec.infos.obj.flag.value |= pdu.sec.InfoFlag.INFO_AUTOLOGON; } if (config.screen && config.screen.width && config.screen.height) { this.mcs.clientCoreData.obj.desktopWidth.value = config.screen.width; this.mcs.clientCoreData.obj.desktopHeight.value = config.screen.height; } log.info('screen ' + this.mcs.clientCoreData.obj.desktopWidth.value + 'x' + this.mcs.clientCoreData.obj.desktopHeight.value); // config keyboard layout switch (config.locale) { case 'fr': log.info('french keyboard layout'); this.mcs.clientCoreData.obj.kbdLayout.value = t125.gcc.KeyboardLayout.FRENCH; break; case 'en': default: log.info('english keyboard layout'); this.mcs.clientCoreData.obj.kbdLayout.value = t125.gcc.KeyboardLayout.US; } //bind all events var self = this; this.global.on('connect', function () { self.connected = true; self.emit('connect'); }).on('session', function () { self.emit('session'); }).on('close', function () { self.connected = false; self.emit('close'); }).on('bitmap', function (bitmaps) { for(var bitmap in bitmaps) { var bitmapData = bitmaps[bitmap].obj.bitmapDataStream.value; var isCompress = bitmaps[bitmap].obj.flags.value & pdu.data.BitmapFlag.BITMAP_COMPRESSION; if (isCompress && config.decompress) { bitmapData = decompress(bitmaps[bitmap].obj); isCompress = false; } self.emit('bitmap', { destTop : bitmaps[bitmap].obj.destTop.value, destLeft : bitmaps[bitmap].obj.destLeft.value, destBottom : bitmaps[bitmap].obj.destBottom.value, destRight : bitmaps[bitmap].obj.destRight.value, width : bitmaps[bitmap].obj.width.value, height : bitmaps[bitmap].obj.height.value, bitsPerPixel : bitmaps[bitmap].obj.bitsPerPixel.value, isCompress : isCompress, data : bitmapData }); } }).on('error', function (err) { log.error(err.code + '(' + err.message + ')\n' + err.stack); if (err instanceof error.FatalError) { throw err; } else { self.emit('error', err); } }); }
javascript
function RdpClient(config) { config = config || {}; this.connected = false; this.bufferLayer = new layer.BufferLayer(new net.Socket()); this.tpkt = new TPKT(this.bufferLayer); this.x224 = new x224.Client(this.tpkt); this.mcs = new t125.mcs.Client(this.x224); this.sec = new pdu.sec.Client(this.mcs, this.tpkt); this.global = new pdu.global.Client(this.sec, this.sec); // config log level log.level = log.Levels[config.logLevel || 'INFO'] || log.Levels.INFO; // credentials if (config.domain) { this.sec.infos.obj.domain.value = new Buffer(config.domain + '\x00', 'ucs2'); } if (config.userName) { this.sec.infos.obj.userName.value = new Buffer(config.userName + '\x00', 'ucs2'); } if (config.password) { this.sec.infos.obj.password.value = new Buffer(config.password + '\x00', 'ucs2'); } if (config.enablePerf) { this.sec.infos.obj.extendedInfo.obj.performanceFlags.value = pdu.sec.PerfFlag.PERF_DISABLE_WALLPAPER | pdu.sec.PerfFlag.PERF_DISABLE_MENUANIMATIONS | pdu.sec.PerfFlag.PERF_DISABLE_CURSOR_SHADOW | pdu.sec.PerfFlag.PERF_DISABLE_THEMING | pdu.sec.PerfFlag.PERF_DISABLE_FULLWINDOWDRAG; } if (config.autoLogin) { this.sec.infos.obj.flag.value |= pdu.sec.InfoFlag.INFO_AUTOLOGON; } if (config.screen && config.screen.width && config.screen.height) { this.mcs.clientCoreData.obj.desktopWidth.value = config.screen.width; this.mcs.clientCoreData.obj.desktopHeight.value = config.screen.height; } log.info('screen ' + this.mcs.clientCoreData.obj.desktopWidth.value + 'x' + this.mcs.clientCoreData.obj.desktopHeight.value); // config keyboard layout switch (config.locale) { case 'fr': log.info('french keyboard layout'); this.mcs.clientCoreData.obj.kbdLayout.value = t125.gcc.KeyboardLayout.FRENCH; break; case 'en': default: log.info('english keyboard layout'); this.mcs.clientCoreData.obj.kbdLayout.value = t125.gcc.KeyboardLayout.US; } //bind all events var self = this; this.global.on('connect', function () { self.connected = true; self.emit('connect'); }).on('session', function () { self.emit('session'); }).on('close', function () { self.connected = false; self.emit('close'); }).on('bitmap', function (bitmaps) { for(var bitmap in bitmaps) { var bitmapData = bitmaps[bitmap].obj.bitmapDataStream.value; var isCompress = bitmaps[bitmap].obj.flags.value & pdu.data.BitmapFlag.BITMAP_COMPRESSION; if (isCompress && config.decompress) { bitmapData = decompress(bitmaps[bitmap].obj); isCompress = false; } self.emit('bitmap', { destTop : bitmaps[bitmap].obj.destTop.value, destLeft : bitmaps[bitmap].obj.destLeft.value, destBottom : bitmaps[bitmap].obj.destBottom.value, destRight : bitmaps[bitmap].obj.destRight.value, width : bitmaps[bitmap].obj.width.value, height : bitmaps[bitmap].obj.height.value, bitsPerPixel : bitmaps[bitmap].obj.bitsPerPixel.value, isCompress : isCompress, data : bitmapData }); } }).on('error', function (err) { log.error(err.code + '(' + err.message + ')\n' + err.stack); if (err instanceof error.FatalError) { throw err; } else { self.emit('error', err); } }); }
[ "function", "RdpClient", "(", "config", ")", "{", "config", "=", "config", "||", "{", "}", ";", "this", ".", "connected", "=", "false", ";", "this", ".", "bufferLayer", "=", "new", "layer", ".", "BufferLayer", "(", "new", "net", ".", "Socket", "(", ")", ")", ";", "this", ".", "tpkt", "=", "new", "TPKT", "(", "this", ".", "bufferLayer", ")", ";", "this", ".", "x224", "=", "new", "x224", ".", "Client", "(", "this", ".", "tpkt", ")", ";", "this", ".", "mcs", "=", "new", "t125", ".", "mcs", ".", "Client", "(", "this", ".", "x224", ")", ";", "this", ".", "sec", "=", "new", "pdu", ".", "sec", ".", "Client", "(", "this", ".", "mcs", ",", "this", ".", "tpkt", ")", ";", "this", ".", "global", "=", "new", "pdu", ".", "global", ".", "Client", "(", "this", ".", "sec", ",", "this", ".", "sec", ")", ";", "// config log level", "log", ".", "level", "=", "log", ".", "Levels", "[", "config", ".", "logLevel", "||", "'INFO'", "]", "||", "log", ".", "Levels", ".", "INFO", ";", "// credentials", "if", "(", "config", ".", "domain", ")", "{", "this", ".", "sec", ".", "infos", ".", "obj", ".", "domain", ".", "value", "=", "new", "Buffer", "(", "config", ".", "domain", "+", "'\\x00'", ",", "'ucs2'", ")", ";", "}", "if", "(", "config", ".", "userName", ")", "{", "this", ".", "sec", ".", "infos", ".", "obj", ".", "userName", ".", "value", "=", "new", "Buffer", "(", "config", ".", "userName", "+", "'\\x00'", ",", "'ucs2'", ")", ";", "}", "if", "(", "config", ".", "password", ")", "{", "this", ".", "sec", ".", "infos", ".", "obj", ".", "password", ".", "value", "=", "new", "Buffer", "(", "config", ".", "password", "+", "'\\x00'", ",", "'ucs2'", ")", ";", "}", "if", "(", "config", ".", "enablePerf", ")", "{", "this", ".", "sec", ".", "infos", ".", "obj", ".", "extendedInfo", ".", "obj", ".", "performanceFlags", ".", "value", "=", "pdu", ".", "sec", ".", "PerfFlag", ".", "PERF_DISABLE_WALLPAPER", "|", "pdu", ".", "sec", ".", "PerfFlag", ".", "PERF_DISABLE_MENUANIMATIONS", "|", "pdu", ".", "sec", ".", "PerfFlag", ".", "PERF_DISABLE_CURSOR_SHADOW", "|", "pdu", ".", "sec", ".", "PerfFlag", ".", "PERF_DISABLE_THEMING", "|", "pdu", ".", "sec", ".", "PerfFlag", ".", "PERF_DISABLE_FULLWINDOWDRAG", ";", "}", "if", "(", "config", ".", "autoLogin", ")", "{", "this", ".", "sec", ".", "infos", ".", "obj", ".", "flag", ".", "value", "|=", "pdu", ".", "sec", ".", "InfoFlag", ".", "INFO_AUTOLOGON", ";", "}", "if", "(", "config", ".", "screen", "&&", "config", ".", "screen", ".", "width", "&&", "config", ".", "screen", ".", "height", ")", "{", "this", ".", "mcs", ".", "clientCoreData", ".", "obj", ".", "desktopWidth", ".", "value", "=", "config", ".", "screen", ".", "width", ";", "this", ".", "mcs", ".", "clientCoreData", ".", "obj", ".", "desktopHeight", ".", "value", "=", "config", ".", "screen", ".", "height", ";", "}", "log", ".", "info", "(", "'screen '", "+", "this", ".", "mcs", ".", "clientCoreData", ".", "obj", ".", "desktopWidth", ".", "value", "+", "'x'", "+", "this", ".", "mcs", ".", "clientCoreData", ".", "obj", ".", "desktopHeight", ".", "value", ")", ";", "// config keyboard layout", "switch", "(", "config", ".", "locale", ")", "{", "case", "'fr'", ":", "log", ".", "info", "(", "'french keyboard layout'", ")", ";", "this", ".", "mcs", ".", "clientCoreData", ".", "obj", ".", "kbdLayout", ".", "value", "=", "t125", ".", "gcc", ".", "KeyboardLayout", ".", "FRENCH", ";", "break", ";", "case", "'en'", ":", "default", ":", "log", ".", "info", "(", "'english keyboard layout'", ")", ";", "this", ".", "mcs", ".", "clientCoreData", ".", "obj", ".", "kbdLayout", ".", "value", "=", "t125", ".", "gcc", ".", "KeyboardLayout", ".", "US", ";", "}", "//bind all events", "var", "self", "=", "this", ";", "this", ".", "global", ".", "on", "(", "'connect'", ",", "function", "(", ")", "{", "self", ".", "connected", "=", "true", ";", "self", ".", "emit", "(", "'connect'", ")", ";", "}", ")", ".", "on", "(", "'session'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'session'", ")", ";", "}", ")", ".", "on", "(", "'close'", ",", "function", "(", ")", "{", "self", ".", "connected", "=", "false", ";", "self", ".", "emit", "(", "'close'", ")", ";", "}", ")", ".", "on", "(", "'bitmap'", ",", "function", "(", "bitmaps", ")", "{", "for", "(", "var", "bitmap", "in", "bitmaps", ")", "{", "var", "bitmapData", "=", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "bitmapDataStream", ".", "value", ";", "var", "isCompress", "=", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "flags", ".", "value", "&", "pdu", ".", "data", ".", "BitmapFlag", ".", "BITMAP_COMPRESSION", ";", "if", "(", "isCompress", "&&", "config", ".", "decompress", ")", "{", "bitmapData", "=", "decompress", "(", "bitmaps", "[", "bitmap", "]", ".", "obj", ")", ";", "isCompress", "=", "false", ";", "}", "self", ".", "emit", "(", "'bitmap'", ",", "{", "destTop", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "destTop", ".", "value", ",", "destLeft", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "destLeft", ".", "value", ",", "destBottom", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "destBottom", ".", "value", ",", "destRight", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "destRight", ".", "value", ",", "width", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "width", ".", "value", ",", "height", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "height", ".", "value", ",", "bitsPerPixel", ":", "bitmaps", "[", "bitmap", "]", ".", "obj", ".", "bitsPerPixel", ".", "value", ",", "isCompress", ":", "isCompress", ",", "data", ":", "bitmapData", "}", ")", ";", "}", "}", ")", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "log", ".", "error", "(", "err", ".", "code", "+", "'('", "+", "err", ".", "message", "+", "')\\n'", "+", "err", ".", "stack", ")", ";", "if", "(", "err", "instanceof", "error", ".", "FatalError", ")", "{", "throw", "err", ";", "}", "else", "{", "self", ".", "emit", "(", "'error'", ",", "err", ")", ";", "}", "}", ")", ";", "}" ]
Main RDP module
[ "Main", "RDP", "module" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/rdp.js#L82-L180
12,405
citronneur/node-rdpjs
lib/protocol/rdp.js
RdpServer
function RdpServer(config, socket) { if (!(config.key && config.cert)) { throw new error.FatalError('NODE_RDP_PROTOCOL_RDP_SERVER_CONFIG_MISSING', 'missing cryptographic tools') } this.connected = false; this.bufferLayer = new layer.BufferLayer(socket); this.tpkt = new TPKT(this.bufferLayer); this.x224 = new x224.Server(this.tpkt, config.key, config.cert); this.mcs = new t125.mcs.Server(this.x224); }
javascript
function RdpServer(config, socket) { if (!(config.key && config.cert)) { throw new error.FatalError('NODE_RDP_PROTOCOL_RDP_SERVER_CONFIG_MISSING', 'missing cryptographic tools') } this.connected = false; this.bufferLayer = new layer.BufferLayer(socket); this.tpkt = new TPKT(this.bufferLayer); this.x224 = new x224.Server(this.tpkt, config.key, config.cert); this.mcs = new t125.mcs.Server(this.x224); }
[ "function", "RdpServer", "(", "config", ",", "socket", ")", "{", "if", "(", "!", "(", "config", ".", "key", "&&", "config", ".", "cert", ")", ")", "{", "throw", "new", "error", ".", "FatalError", "(", "'NODE_RDP_PROTOCOL_RDP_SERVER_CONFIG_MISSING'", ",", "'missing cryptographic tools'", ")", "}", "this", ".", "connected", "=", "false", ";", "this", ".", "bufferLayer", "=", "new", "layer", ".", "BufferLayer", "(", "socket", ")", ";", "this", ".", "tpkt", "=", "new", "TPKT", "(", "this", ".", "bufferLayer", ")", ";", "this", ".", "x224", "=", "new", "x224", ".", "Server", "(", "this", ".", "tpkt", ",", "config", ".", "key", ",", "config", ".", "cert", ")", ";", "this", ".", "mcs", "=", "new", "t125", ".", "mcs", ".", "Server", "(", "this", ".", "x224", ")", ";", "}" ]
RDP server side protocol @param config {object} configuration @param socket {net.Socket}
[ "RDP", "server", "side", "protocol" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/rdp.js#L330-L339
12,406
citronneur/node-rdpjs
lib/protocol/pdu/sec.js
rdpInfos
function rdpInfos(extendedInfoConditional) { var self = { codePage : new type.UInt32Le(), flag : new type.UInt32Le(InfoFlag.INFO_MOUSE | InfoFlag.INFO_UNICODE | InfoFlag.INFO_LOGONNOTIFY | InfoFlag.INFO_LOGONERRORS | InfoFlag.INFO_DISABLECTRLALTDEL | InfoFlag.INFO_ENABLEWINDOWSKEY), cbDomain : new type.UInt16Le(function() { return self.domain.size() - 2; }), cbUserName : new type.UInt16Le(function() { return self.userName.size() - 2; }), cbPassword : new type.UInt16Le(function() { return self.password.size() - 2; }), cbAlternateShell : new type.UInt16Le(function() { return self.alternateShell.size() - 2; }), cbWorkingDir : new type.UInt16Le(function() { return self.workingDir.size() - 2; }), domain : new type.BinaryString(new Buffer('\x00', 'ucs2'),{ readLength : new type.CallableValue(function() { return self.cbDomain.value + 2; })}), userName : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbUserName.value + 2; })}), password : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function () { return self.cbPassword.value + 2; })}), alternateShell : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbAlternateShell.value + 2; })}), workingDir : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbWorkingDir.value + 2; })}), extendedInfo : rdpExtendedInfos({ conditional : extendedInfoConditional }) }; return new type.Component(self); }
javascript
function rdpInfos(extendedInfoConditional) { var self = { codePage : new type.UInt32Le(), flag : new type.UInt32Le(InfoFlag.INFO_MOUSE | InfoFlag.INFO_UNICODE | InfoFlag.INFO_LOGONNOTIFY | InfoFlag.INFO_LOGONERRORS | InfoFlag.INFO_DISABLECTRLALTDEL | InfoFlag.INFO_ENABLEWINDOWSKEY), cbDomain : new type.UInt16Le(function() { return self.domain.size() - 2; }), cbUserName : new type.UInt16Le(function() { return self.userName.size() - 2; }), cbPassword : new type.UInt16Le(function() { return self.password.size() - 2; }), cbAlternateShell : new type.UInt16Le(function() { return self.alternateShell.size() - 2; }), cbWorkingDir : new type.UInt16Le(function() { return self.workingDir.size() - 2; }), domain : new type.BinaryString(new Buffer('\x00', 'ucs2'),{ readLength : new type.CallableValue(function() { return self.cbDomain.value + 2; })}), userName : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbUserName.value + 2; })}), password : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function () { return self.cbPassword.value + 2; })}), alternateShell : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbAlternateShell.value + 2; })}), workingDir : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbWorkingDir.value + 2; })}), extendedInfo : rdpExtendedInfos({ conditional : extendedInfoConditional }) }; return new type.Component(self); }
[ "function", "rdpInfos", "(", "extendedInfoConditional", ")", "{", "var", "self", "=", "{", "codePage", ":", "new", "type", ".", "UInt32Le", "(", ")", ",", "flag", ":", "new", "type", ".", "UInt32Le", "(", "InfoFlag", ".", "INFO_MOUSE", "|", "InfoFlag", ".", "INFO_UNICODE", "|", "InfoFlag", ".", "INFO_LOGONNOTIFY", "|", "InfoFlag", ".", "INFO_LOGONERRORS", "|", "InfoFlag", ".", "INFO_DISABLECTRLALTDEL", "|", "InfoFlag", ".", "INFO_ENABLEWINDOWSKEY", ")", ",", "cbDomain", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "domain", ".", "size", "(", ")", "-", "2", ";", "}", ")", ",", "cbUserName", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "userName", ".", "size", "(", ")", "-", "2", ";", "}", ")", ",", "cbPassword", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "password", ".", "size", "(", ")", "-", "2", ";", "}", ")", ",", "cbAlternateShell", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "alternateShell", ".", "size", "(", ")", "-", "2", ";", "}", ")", ",", "cbWorkingDir", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "workingDir", ".", "size", "(", ")", "-", "2", ";", "}", ")", ",", "domain", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbDomain", ".", "value", "+", "2", ";", "}", ")", "}", ")", ",", "userName", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbUserName", ".", "value", "+", "2", ";", "}", ")", "}", ")", ",", "password", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbPassword", ".", "value", "+", "2", ";", "}", ")", "}", ")", ",", "alternateShell", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbAlternateShell", ".", "value", "+", "2", ";", "}", ")", "}", ")", ",", "workingDir", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbWorkingDir", ".", "value", "+", "2", ";", "}", ")", "}", ")", ",", "extendedInfo", ":", "rdpExtendedInfos", "(", "{", "conditional", ":", "extendedInfoConditional", "}", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
RDP client informations @param extendedInfoConditional {boolean} true if RDP5+ @returns {type.Component}
[ "RDP", "client", "informations" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/sec.js#L191-L229
12,407
citronneur/node-rdpjs
lib/protocol/pdu/sec.js
rdpExtendedInfos
function rdpExtendedInfos(opt) { var self = { clientAddressFamily : new type.UInt16Le(AfInet.AfInet), cbClientAddress : new type.UInt16Le(function() { return self.clientAddress.size(); }), clientAddress : new type.BinaryString(new Buffer('\x00', 'ucs2'),{ readLength : new type.CallableValue(function() { return self.cbClientAddress; }) }), cbClientDir : new type.UInt16Le(function() { return self.clientDir.size(); }), clientDir : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbClientDir; }) }), clientTimeZone : new type.BinaryString(new Buffer(Array(172 + 1).join("\x00"))), clientSessionId : new type.UInt32Le(), performanceFlags : new type.UInt32Le() }; return new type.Component(self, opt); }
javascript
function rdpExtendedInfos(opt) { var self = { clientAddressFamily : new type.UInt16Le(AfInet.AfInet), cbClientAddress : new type.UInt16Le(function() { return self.clientAddress.size(); }), clientAddress : new type.BinaryString(new Buffer('\x00', 'ucs2'),{ readLength : new type.CallableValue(function() { return self.cbClientAddress; }) }), cbClientDir : new type.UInt16Le(function() { return self.clientDir.size(); }), clientDir : new type.BinaryString(new Buffer('\x00', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbClientDir; }) }), clientTimeZone : new type.BinaryString(new Buffer(Array(172 + 1).join("\x00"))), clientSessionId : new type.UInt32Le(), performanceFlags : new type.UInt32Le() }; return new type.Component(self, opt); }
[ "function", "rdpExtendedInfos", "(", "opt", ")", "{", "var", "self", "=", "{", "clientAddressFamily", ":", "new", "type", ".", "UInt16Le", "(", "AfInet", ".", "AfInet", ")", ",", "cbClientAddress", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "clientAddress", ".", "size", "(", ")", ";", "}", ")", ",", "clientAddress", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbClientAddress", ";", "}", ")", "}", ")", ",", "cbClientDir", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "clientDir", ".", "size", "(", ")", ";", "}", ")", ",", "clientDir", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbClientDir", ";", "}", ")", "}", ")", ",", "clientTimeZone", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "Array", "(", "172", "+", "1", ")", ".", "join", "(", "\"\\x00\"", ")", ")", ")", ",", "clientSessionId", ":", "new", "type", ".", "UInt32Le", "(", ")", ",", "performanceFlags", ":", "new", "type", ".", "UInt32Le", "(", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ",", "opt", ")", ";", "}" ]
RDP client extended informations present in RDP5+ @param opt @returns {type.Component}
[ "RDP", "client", "extended", "informations", "present", "in", "RDP5", "+" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/sec.js#L236-L256
12,408
citronneur/node-rdpjs
lib/protocol/pdu/sec.js
securityHeader
function securityHeader() { var self = { securityFlag : new type.UInt16Le(), securityFlagHi : new type.UInt16Le() }; return new type.Component(self); }
javascript
function securityHeader() { var self = { securityFlag : new type.UInt16Le(), securityFlagHi : new type.UInt16Le() }; return new type.Component(self); }
[ "function", "securityHeader", "(", ")", "{", "var", "self", "=", "{", "securityFlag", ":", "new", "type", ".", "UInt16Le", "(", ")", ",", "securityFlagHi", ":", "new", "type", ".", "UInt16Le", "(", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
Header of security header @returns {type.Component}
[ "Header", "of", "security", "header" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/sec.js#L262-L269
12,409
citronneur/node-rdpjs
lib/protocol/pdu/sec.js
Client
function Client(transport, fastPathTransport) { Sec.call(this, transport, fastPathTransport); // for basic RDP layer (in futur) this.enableSecureCheckSum = false; var self = this; this.transport.on('connect', function(gccClient, gccServer, userId, channels) { self.connect(gccClient, gccServer, userId, channels); }).on('close', function() { self.emit('close'); }).on('error', function (err) { self.emit('error', err); }); }
javascript
function Client(transport, fastPathTransport) { Sec.call(this, transport, fastPathTransport); // for basic RDP layer (in futur) this.enableSecureCheckSum = false; var self = this; this.transport.on('connect', function(gccClient, gccServer, userId, channels) { self.connect(gccClient, gccServer, userId, channels); }).on('close', function() { self.emit('close'); }).on('error', function (err) { self.emit('error', err); }); }
[ "function", "Client", "(", "transport", ",", "fastPathTransport", ")", "{", "Sec", ".", "call", "(", "this", ",", "transport", ",", "fastPathTransport", ")", ";", "// for basic RDP layer (in futur)", "this", ".", "enableSecureCheckSum", "=", "false", ";", "var", "self", "=", "this", ";", "this", ".", "transport", ".", "on", "(", "'connect'", ",", "function", "(", "gccClient", ",", "gccServer", ",", "userId", ",", "channels", ")", "{", "self", ".", "connect", "(", "gccClient", ",", "gccServer", ",", "userId", ",", "channels", ")", ";", "}", ")", ".", "on", "(", "'close'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'close'", ")", ";", "}", ")", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "self", ".", "emit", "(", "'error'", ",", "err", ")", ";", "}", ")", ";", "}" ]
Client security layer @param transport {events.EventEmitter}
[ "Client", "security", "layer" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/sec.js#L351-L363
12,410
citronneur/node-rdpjs
lib/asn1/spec.js
Asn1Tag
function Asn1Tag(tagClass, tagFormat, tagNumber) { this.tagClass = tagClass; this.tagFormat = tagFormat; this.tagNumber = tagNumber; }
javascript
function Asn1Tag(tagClass, tagFormat, tagNumber) { this.tagClass = tagClass; this.tagFormat = tagFormat; this.tagNumber = tagNumber; }
[ "function", "Asn1Tag", "(", "tagClass", ",", "tagFormat", ",", "tagNumber", ")", "{", "this", ".", "tagClass", "=", "tagClass", ";", "this", ".", "tagFormat", "=", "tagFormat", ";", "this", ".", "tagNumber", "=", "tagNumber", ";", "}" ]
ASN.1 tag @param tagClass {TagClass} @param tagFormat {TagFormat} @param tagNumber {integer}
[ "ASN", ".", "1", "tag" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/asn1/spec.js#L48-L52
12,411
citronneur/node-rdpjs
lib/core/type.js
Stream
function Stream(i) { this.offset = 0; if (i instanceof Buffer) { this.buffer = i; } else { this.buffer = new Buffer(i || 8192); } }
javascript
function Stream(i) { this.offset = 0; if (i instanceof Buffer) { this.buffer = i; } else { this.buffer = new Buffer(i || 8192); } }
[ "function", "Stream", "(", "i", ")", "{", "this", ".", "offset", "=", "0", ";", "if", "(", "i", "instanceof", "Buffer", ")", "{", "this", ".", "buffer", "=", "i", ";", "}", "else", "{", "this", ".", "buffer", "=", "new", "Buffer", "(", "i", "||", "8192", ")", ";", "}", "}" ]
Stream wrapper around buffer type @param i {Buffer | integer} size of init buffer @returns
[ "Stream", "wrapper", "around", "buffer", "type" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L29-L37
12,412
citronneur/node-rdpjs
lib/core/type.js
Type
function Type(opt) { CallableValue.call(this); this.opt = opt || {}; this.isReaded = false; this.isWritten = false; }
javascript
function Type(opt) { CallableValue.call(this); this.opt = opt || {}; this.isReaded = false; this.isWritten = false; }
[ "function", "Type", "(", "opt", ")", "{", "CallableValue", ".", "call", "(", "this", ")", ";", "this", ".", "opt", "=", "opt", "||", "{", "}", ";", "this", ".", "isReaded", "=", "false", ";", "this", ".", "isWritten", "=", "false", ";", "}" ]
Type readable or writable by binary stream @param {object} opt .conditional {boolean} read or write type depend on conditional call @returns
[ "Type", "readable", "or", "writable", "by", "binary", "stream" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L94-L99
12,413
citronneur/node-rdpjs
lib/core/type.js
SingleType
function SingleType(value, nbBytes, readBufferCallback, writeBufferCallback, opt){ Type.call(this, opt); this.value = value || 0; this.nbBytes = nbBytes; this.readBufferCallback = readBufferCallback; this.writeBufferCallback = writeBufferCallback; }
javascript
function SingleType(value, nbBytes, readBufferCallback, writeBufferCallback, opt){ Type.call(this, opt); this.value = value || 0; this.nbBytes = nbBytes; this.readBufferCallback = readBufferCallback; this.writeBufferCallback = writeBufferCallback; }
[ "function", "SingleType", "(", "value", ",", "nbBytes", ",", "readBufferCallback", ",", "writeBufferCallback", ",", "opt", ")", "{", "Type", ".", "call", "(", "this", ",", "opt", ")", ";", "this", ".", "value", "=", "value", "||", "0", ";", "this", ".", "nbBytes", "=", "nbBytes", ";", "this", ".", "readBufferCallback", "=", "readBufferCallback", ";", "this", ".", "writeBufferCallback", "=", "writeBufferCallback", ";", "}" ]
Leaf of tree type @param {number} value of type @param {function} readBufferCallback Buffer prototype read function @param {function} writeBufferCallback Buffer prototype write function @param {object} opt Type parameter
[ "Leaf", "of", "tree", "type" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L290-L296
12,414
citronneur/node-rdpjs
lib/core/type.js
UInt8
function UInt8(value, opt) { SingleType.call(this, value, 1, Buffer.prototype.readUInt8, Buffer.prototype.writeUInt8, opt); }
javascript
function UInt8(value, opt) { SingleType.call(this, value, 1, Buffer.prototype.readUInt8, Buffer.prototype.writeUInt8, opt); }
[ "function", "UInt8", "(", "value", ",", "opt", ")", "{", "SingleType", ".", "call", "(", "this", ",", "value", ",", "1", ",", "Buffer", ".", "prototype", ".", "readUInt8", ",", "Buffer", ".", "prototype", ".", "writeUInt8", ",", "opt", ")", ";", "}" ]
Integer on 1 byte @param {number | function} value of type @param {object} opt Type parameter @returns
[ "Integer", "on", "1", "byte" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L333-L335
12,415
citronneur/node-rdpjs
lib/core/type.js
UInt16Le
function UInt16Le(value, opt) { SingleType.call(this, value, 2, Buffer.prototype.readUInt16LE, Buffer.prototype.writeUInt16LE, opt); }
javascript
function UInt16Le(value, opt) { SingleType.call(this, value, 2, Buffer.prototype.readUInt16LE, Buffer.prototype.writeUInt16LE, opt); }
[ "function", "UInt16Le", "(", "value", ",", "opt", ")", "{", "SingleType", ".", "call", "(", "this", ",", "value", ",", "2", ",", "Buffer", ".", "prototype", ".", "readUInt16LE", ",", "Buffer", ".", "prototype", ".", "writeUInt16LE", ",", "opt", ")", ";", "}" ]
Integer on 2 bytes in Little Endian @param {number | function} value to write or compare if constant @param {object} opt Type parameter @returns
[ "Integer", "on", "2", "bytes", "in", "Little", "Endian" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L346-L348
12,416
citronneur/node-rdpjs
lib/core/type.js
UInt16Be
function UInt16Be(value, opt) { SingleType.call(this, value, 2, Buffer.prototype.readUInt16BE, Buffer.prototype.writeUInt16BE, opt); }
javascript
function UInt16Be(value, opt) { SingleType.call(this, value, 2, Buffer.prototype.readUInt16BE, Buffer.prototype.writeUInt16BE, opt); }
[ "function", "UInt16Be", "(", "value", ",", "opt", ")", "{", "SingleType", ".", "call", "(", "this", ",", "value", ",", "2", ",", "Buffer", ".", "prototype", ".", "readUInt16BE", ",", "Buffer", ".", "prototype", ".", "writeUInt16BE", ",", "opt", ")", ";", "}" ]
Integer on 2 bytes in Big Endian @param {number | function} value to write or compare if constant @param {object} opt Type parameter @returns
[ "Integer", "on", "2", "bytes", "in", "Big", "Endian" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L359-L361
12,417
citronneur/node-rdpjs
lib/core/type.js
UInt32Le
function UInt32Le(value, opt) { SingleType.call(this, value, 4, Buffer.prototype.readUInt32LE, Buffer.prototype.writeUInt32LE, opt); }
javascript
function UInt32Le(value, opt) { SingleType.call(this, value, 4, Buffer.prototype.readUInt32LE, Buffer.prototype.writeUInt32LE, opt); }
[ "function", "UInt32Le", "(", "value", ",", "opt", ")", "{", "SingleType", ".", "call", "(", "this", ",", "value", ",", "4", ",", "Buffer", ".", "prototype", ".", "readUInt32LE", ",", "Buffer", ".", "prototype", ".", "writeUInt32LE", ",", "opt", ")", ";", "}" ]
Integer on 4 bytes in Little Endian @param {number | function} value to write or compare if constant @param {object} opt Type parameter @returns
[ "Integer", "on", "4", "bytes", "in", "Little", "Endian" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L372-L374
12,418
citronneur/node-rdpjs
lib/core/type.js
UInt32Be
function UInt32Be(value, opt) { SingleType.call(this, value, 4, Buffer.prototype.readUInt32BE, Buffer.prototype.writeUInt32BE, opt); }
javascript
function UInt32Be(value, opt) { SingleType.call(this, value, 4, Buffer.prototype.readUInt32BE, Buffer.prototype.writeUInt32BE, opt); }
[ "function", "UInt32Be", "(", "value", ",", "opt", ")", "{", "SingleType", ".", "call", "(", "this", ",", "value", ",", "4", ",", "Buffer", ".", "prototype", ".", "readUInt32BE", ",", "Buffer", ".", "prototype", ".", "writeUInt32BE", ",", "opt", ")", ";", "}" ]
Integer on 4 bytes in Big Endian @param {number | function} value to write or compare if constant @param {object} opt Type parameter @returns
[ "Integer", "on", "4", "bytes", "in", "Big", "Endian" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/core/type.js#L385-L387
12,419
citronneur/node-rdpjs
lib/protocol/t125/gcc.js
clientCoreData
function clientCoreData(opt) { var self = { __TYPE__ : MessageType.CS_CORE, rdpVersion : new type.UInt32Le(VERSION.RDP_VERSION_5_PLUS), desktopWidth : new type.UInt16Le(1280), desktopHeight : new type.UInt16Le(800), colorDepth : new type.UInt16Le(ColorDepth.RNS_UD_COLOR_8BPP), sasSequence : new type.UInt16Le(Sequence.RNS_UD_SAS_DEL), kbdLayout : new type.UInt32Le(KeyboardLayout.FRENCH), clientBuild : new type.UInt32Le(3790), clientName : new type.BinaryString(new Buffer('node-rdpjs\x00\x00\x00\x00\x00\x00', 'ucs2'), { readLength : new type.CallableValue(32) }), keyboardType : new type.UInt32Le(KeyboardType.IBM_101_102_KEYS), keyboardSubType : new type.UInt32Le(0), keyboardFnKeys : new type.UInt32Le(12), imeFileName : new type.BinaryString(new Buffer(Array(64 + 1).join('\x00')), { readLength : new type.CallableValue(64), optional : true }), postBeta2ColorDepth : new type.UInt16Le(ColorDepth.RNS_UD_COLOR_8BPP, { optional : true }), clientProductId : new type.UInt16Le(1, { optional : true }), serialNumber : new type.UInt32Le(0, { optional : true }), highColorDepth : new type.UInt16Le(HighColor.HIGH_COLOR_24BPP, { optional : true }), supportedColorDepths : new type.UInt16Le(Support.RNS_UD_15BPP_SUPPORT | Support.RNS_UD_16BPP_SUPPORT | Support.RNS_UD_24BPP_SUPPORT | Support.RNS_UD_32BPP_SUPPORT, { optional : true }), earlyCapabilityFlags : new type.UInt16Le(CapabilityFlag.RNS_UD_CS_SUPPORT_ERRINFO_PDU, { optional : true }), clientDigProductId : new type.BinaryString(new Buffer(Array(64 + 1).join('\x00')), { optional : true, readLength : new type.CallableValue(64) }), connectionType : new type.UInt8(0, { optional : true }), pad1octet : new type.UInt8(0, { optional : true }), serverSelectedProtocol : new type.UInt32Le(0, { optional : true }) }; return new type.Component(self, opt); }
javascript
function clientCoreData(opt) { var self = { __TYPE__ : MessageType.CS_CORE, rdpVersion : new type.UInt32Le(VERSION.RDP_VERSION_5_PLUS), desktopWidth : new type.UInt16Le(1280), desktopHeight : new type.UInt16Le(800), colorDepth : new type.UInt16Le(ColorDepth.RNS_UD_COLOR_8BPP), sasSequence : new type.UInt16Le(Sequence.RNS_UD_SAS_DEL), kbdLayout : new type.UInt32Le(KeyboardLayout.FRENCH), clientBuild : new type.UInt32Le(3790), clientName : new type.BinaryString(new Buffer('node-rdpjs\x00\x00\x00\x00\x00\x00', 'ucs2'), { readLength : new type.CallableValue(32) }), keyboardType : new type.UInt32Le(KeyboardType.IBM_101_102_KEYS), keyboardSubType : new type.UInt32Le(0), keyboardFnKeys : new type.UInt32Le(12), imeFileName : new type.BinaryString(new Buffer(Array(64 + 1).join('\x00')), { readLength : new type.CallableValue(64), optional : true }), postBeta2ColorDepth : new type.UInt16Le(ColorDepth.RNS_UD_COLOR_8BPP, { optional : true }), clientProductId : new type.UInt16Le(1, { optional : true }), serialNumber : new type.UInt32Le(0, { optional : true }), highColorDepth : new type.UInt16Le(HighColor.HIGH_COLOR_24BPP, { optional : true }), supportedColorDepths : new type.UInt16Le(Support.RNS_UD_15BPP_SUPPORT | Support.RNS_UD_16BPP_SUPPORT | Support.RNS_UD_24BPP_SUPPORT | Support.RNS_UD_32BPP_SUPPORT, { optional : true }), earlyCapabilityFlags : new type.UInt16Le(CapabilityFlag.RNS_UD_CS_SUPPORT_ERRINFO_PDU, { optional : true }), clientDigProductId : new type.BinaryString(new Buffer(Array(64 + 1).join('\x00')), { optional : true, readLength : new type.CallableValue(64) }), connectionType : new type.UInt8(0, { optional : true }), pad1octet : new type.UInt8(0, { optional : true }), serverSelectedProtocol : new type.UInt32Le(0, { optional : true }) }; return new type.Component(self, opt); }
[ "function", "clientCoreData", "(", "opt", ")", "{", "var", "self", "=", "{", "__TYPE__", ":", "MessageType", ".", "CS_CORE", ",", "rdpVersion", ":", "new", "type", ".", "UInt32Le", "(", "VERSION", ".", "RDP_VERSION_5_PLUS", ")", ",", "desktopWidth", ":", "new", "type", ".", "UInt16Le", "(", "1280", ")", ",", "desktopHeight", ":", "new", "type", ".", "UInt16Le", "(", "800", ")", ",", "colorDepth", ":", "new", "type", ".", "UInt16Le", "(", "ColorDepth", ".", "RNS_UD_COLOR_8BPP", ")", ",", "sasSequence", ":", "new", "type", ".", "UInt16Le", "(", "Sequence", ".", "RNS_UD_SAS_DEL", ")", ",", "kbdLayout", ":", "new", "type", ".", "UInt32Le", "(", "KeyboardLayout", ".", "FRENCH", ")", ",", "clientBuild", ":", "new", "type", ".", "UInt32Le", "(", "3790", ")", ",", "clientName", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'node-rdpjs\\x00\\x00\\x00\\x00\\x00\\x00'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "32", ")", "}", ")", ",", "keyboardType", ":", "new", "type", ".", "UInt32Le", "(", "KeyboardType", ".", "IBM_101_102_KEYS", ")", ",", "keyboardSubType", ":", "new", "type", ".", "UInt32Le", "(", "0", ")", ",", "keyboardFnKeys", ":", "new", "type", ".", "UInt32Le", "(", "12", ")", ",", "imeFileName", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "Array", "(", "64", "+", "1", ")", ".", "join", "(", "'\\x00'", ")", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "64", ")", ",", "optional", ":", "true", "}", ")", ",", "postBeta2ColorDepth", ":", "new", "type", ".", "UInt16Le", "(", "ColorDepth", ".", "RNS_UD_COLOR_8BPP", ",", "{", "optional", ":", "true", "}", ")", ",", "clientProductId", ":", "new", "type", ".", "UInt16Le", "(", "1", ",", "{", "optional", ":", "true", "}", ")", ",", "serialNumber", ":", "new", "type", ".", "UInt32Le", "(", "0", ",", "{", "optional", ":", "true", "}", ")", ",", "highColorDepth", ":", "new", "type", ".", "UInt16Le", "(", "HighColor", ".", "HIGH_COLOR_24BPP", ",", "{", "optional", ":", "true", "}", ")", ",", "supportedColorDepths", ":", "new", "type", ".", "UInt16Le", "(", "Support", ".", "RNS_UD_15BPP_SUPPORT", "|", "Support", ".", "RNS_UD_16BPP_SUPPORT", "|", "Support", ".", "RNS_UD_24BPP_SUPPORT", "|", "Support", ".", "RNS_UD_32BPP_SUPPORT", ",", "{", "optional", ":", "true", "}", ")", ",", "earlyCapabilityFlags", ":", "new", "type", ".", "UInt16Le", "(", "CapabilityFlag", ".", "RNS_UD_CS_SUPPORT_ERRINFO_PDU", ",", "{", "optional", ":", "true", "}", ")", ",", "clientDigProductId", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "Array", "(", "64", "+", "1", ")", ".", "join", "(", "'\\x00'", ")", ")", ",", "{", "optional", ":", "true", ",", "readLength", ":", "new", "type", ".", "CallableValue", "(", "64", ")", "}", ")", ",", "connectionType", ":", "new", "type", ".", "UInt8", "(", "0", ",", "{", "optional", ":", "true", "}", ")", ",", "pad1octet", ":", "new", "type", ".", "UInt8", "(", "0", ",", "{", "optional", ":", "true", "}", ")", ",", "serverSelectedProtocol", ":", "new", "type", ".", "UInt32Le", "(", "0", ",", "{", "optional", ":", "true", "}", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ",", "opt", ")", ";", "}" ]
Main client informations keyboard screen definition color depth @see http://msdn.microsoft.com/en-us/library/cc240510.aspx @param opt {object} Classic type options @returns {type.Component}
[ "Main", "client", "informations", "keyboard", "screen", "definition", "color", "depth" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/gcc.js#L263-L291
12,420
citronneur/node-rdpjs
lib/protocol/t125/gcc.js
settings
function settings(blocks, opt) { var self = { blocks : blocks || new type.Factory(function(s) { self.blocks = new type.Component([]); // read until end of stream while(s.availableLength() > 0) { self.blocks.obj.push(block().read(s)); } }), }; return new type.Component(self, opt); }
javascript
function settings(blocks, opt) { var self = { blocks : blocks || new type.Factory(function(s) { self.blocks = new type.Component([]); // read until end of stream while(s.availableLength() > 0) { self.blocks.obj.push(block().read(s)); } }), }; return new type.Component(self, opt); }
[ "function", "settings", "(", "blocks", ",", "opt", ")", "{", "var", "self", "=", "{", "blocks", ":", "blocks", "||", "new", "type", ".", "Factory", "(", "function", "(", "s", ")", "{", "self", ".", "blocks", "=", "new", "type", ".", "Component", "(", "[", "]", ")", ";", "// read until end of stream", "while", "(", "s", ".", "availableLength", "(", ")", ">", "0", ")", "{", "self", ".", "blocks", ".", "obj", ".", "push", "(", "block", "(", ")", ".", "read", "(", "s", ")", ")", ";", "}", "}", ")", ",", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ",", "opt", ")", ";", "}" ]
Client or server GCC settings block @param blocks {type.Component} array of gcc blocks @param opt {object} options to component type @returns {type.Component}
[ "Client", "or", "server", "GCC", "settings", "block" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/gcc.js#L409-L421
12,421
citronneur/node-rdpjs
lib/protocol/t125/gcc.js
readConferenceCreateResponse
function readConferenceCreateResponse(s) { per.readChoice(s); if(!per.readObjectIdentifier(s, t124_02_98_oid)) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_OBJECT_IDENTIFIER_T124'); } per.readLength(s); per.readChoice(s); per.readInteger16(s, 1001); per.readInteger(s); per.readEnumerates(s); per.readNumberOfSet(s); per.readChoice(s); if (!per.readOctetStream(s, h221_sc_key, 4)) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY'); } length = per.readLength(s); serverSettings = settings(null, { readLength : new type.CallableValue(length) }); // Object magic return serverSettings.read(s).obj.blocks.obj.map(function(e) { return e.obj.data; }); }
javascript
function readConferenceCreateResponse(s) { per.readChoice(s); if(!per.readObjectIdentifier(s, t124_02_98_oid)) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_OBJECT_IDENTIFIER_T124'); } per.readLength(s); per.readChoice(s); per.readInteger16(s, 1001); per.readInteger(s); per.readEnumerates(s); per.readNumberOfSet(s); per.readChoice(s); if (!per.readOctetStream(s, h221_sc_key, 4)) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY'); } length = per.readLength(s); serverSettings = settings(null, { readLength : new type.CallableValue(length) }); // Object magic return serverSettings.read(s).obj.blocks.obj.map(function(e) { return e.obj.data; }); }
[ "function", "readConferenceCreateResponse", "(", "s", ")", "{", "per", ".", "readChoice", "(", "s", ")", ";", "if", "(", "!", "per", ".", "readObjectIdentifier", "(", "s", ",", "t124_02_98_oid", ")", ")", "{", "throw", "new", "error", ".", "ProtocolError", "(", "'NODE_RDP_PROTOCOL_T125_GCC_BAD_OBJECT_IDENTIFIER_T124'", ")", ";", "}", "per", ".", "readLength", "(", "s", ")", ";", "per", ".", "readChoice", "(", "s", ")", ";", "per", ".", "readInteger16", "(", "s", ",", "1001", ")", ";", "per", ".", "readInteger", "(", "s", ")", ";", "per", ".", "readEnumerates", "(", "s", ")", ";", "per", ".", "readNumberOfSet", "(", "s", ")", ";", "per", ".", "readChoice", "(", "s", ")", ";", "if", "(", "!", "per", ".", "readOctetStream", "(", "s", ",", "h221_sc_key", ",", "4", ")", ")", "{", "throw", "new", "error", ".", "ProtocolError", "(", "'NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY'", ")", ";", "}", "length", "=", "per", ".", "readLength", "(", "s", ")", ";", "serverSettings", "=", "settings", "(", "null", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "length", ")", "}", ")", ";", "// Object magic", "return", "serverSettings", ".", "read", "(", "s", ")", ".", "obj", ".", "blocks", ".", "obj", ".", "map", "(", "function", "(", "e", ")", "{", "return", "e", ".", "obj", ".", "data", ";", "}", ")", ";", "}" ]
Read GCC response from server @param s {type.Stream} current stream @returns {Array(type.Component)} list of server block
[ "Read", "GCC", "response", "from", "server" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/gcc.js#L428-L454
12,422
citronneur/node-rdpjs
lib/protocol/t125/gcc.js
readConferenceCreateRequest
function readConferenceCreateRequest (s) { per.readChoice(s); if (!per.readObjectIdentifier(s, t124_02_98_oid)) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY'); } per.readLength(s); per.readChoice(s); per.readSelection(s); per.readNumericString(s, 1); per.readPadding(s, 1); if (per.readNumberOfSet(s) !== 1) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_SET'); } if (per.readChoice(s) !== 0xc0) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_CHOICE'); } per.readOctetStream(s, h221_cs_key, 4); length = per.readLength(s); var clientSettings = settings(null, { readLength : new type.CallableValue(length) }); // Object magic return clientSettings.read(s).obj.blocks.obj.map(function(e) { return e.obj.data; }); }
javascript
function readConferenceCreateRequest (s) { per.readChoice(s); if (!per.readObjectIdentifier(s, t124_02_98_oid)) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY'); } per.readLength(s); per.readChoice(s); per.readSelection(s); per.readNumericString(s, 1); per.readPadding(s, 1); if (per.readNumberOfSet(s) !== 1) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_SET'); } if (per.readChoice(s) !== 0xc0) { throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_CHOICE'); } per.readOctetStream(s, h221_cs_key, 4); length = per.readLength(s); var clientSettings = settings(null, { readLength : new type.CallableValue(length) }); // Object magic return clientSettings.read(s).obj.blocks.obj.map(function(e) { return e.obj.data; }); }
[ "function", "readConferenceCreateRequest", "(", "s", ")", "{", "per", ".", "readChoice", "(", "s", ")", ";", "if", "(", "!", "per", ".", "readObjectIdentifier", "(", "s", ",", "t124_02_98_oid", ")", ")", "{", "throw", "new", "error", ".", "ProtocolError", "(", "'NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY'", ")", ";", "}", "per", ".", "readLength", "(", "s", ")", ";", "per", ".", "readChoice", "(", "s", ")", ";", "per", ".", "readSelection", "(", "s", ")", ";", "per", ".", "readNumericString", "(", "s", ",", "1", ")", ";", "per", ".", "readPadding", "(", "s", ",", "1", ")", ";", "if", "(", "per", ".", "readNumberOfSet", "(", "s", ")", "!==", "1", ")", "{", "throw", "new", "error", ".", "ProtocolError", "(", "'NODE_RDP_PROTOCOL_T125_GCC_BAD_SET'", ")", ";", "}", "if", "(", "per", ".", "readChoice", "(", "s", ")", "!==", "0xc0", ")", "{", "throw", "new", "error", ".", "ProtocolError", "(", "'NODE_RDP_PROTOCOL_T125_GCC_BAD_CHOICE'", ")", ";", "}", "per", ".", "readOctetStream", "(", "s", ",", "h221_cs_key", ",", "4", ")", ";", "length", "=", "per", ".", "readLength", "(", "s", ")", ";", "var", "clientSettings", "=", "settings", "(", "null", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "length", ")", "}", ")", ";", "// Object magic", "return", "clientSettings", ".", "read", "(", "s", ")", ".", "obj", ".", "blocks", ".", "obj", ".", "map", "(", "function", "(", "e", ")", "{", "return", "e", ".", "obj", ".", "data", ";", "}", ")", ";", "}" ]
Read GCC request @param s {type.Stream} @returns {Array(type.Component)} list of client block
[ "Read", "GCC", "request" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/gcc.js#L461-L489
12,423
citronneur/node-rdpjs
lib/protocol/cert.js
certBlob
function certBlob() { var self = { cbCert : new type.UInt32Le(function() { return self.abCert.size(); }), abCert : new type.BinaryString(null, { readLength : new type.CallableValue(function() { return self.cbCert.value; }) }) }; return new type.Component(self); }
javascript
function certBlob() { var self = { cbCert : new type.UInt32Le(function() { return self.abCert.size(); }), abCert : new type.BinaryString(null, { readLength : new type.CallableValue(function() { return self.cbCert.value; }) }) }; return new type.Component(self); }
[ "function", "certBlob", "(", ")", "{", "var", "self", "=", "{", "cbCert", ":", "new", "type", ".", "UInt32Le", "(", "function", "(", ")", "{", "return", "self", ".", "abCert", ".", "size", "(", ")", ";", "}", ")", ",", "abCert", ":", "new", "type", ".", "BinaryString", "(", "null", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbCert", ".", "value", ";", "}", ")", "}", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
For x509 certificate @see http://msdn.microsoft.com/en-us/library/cc241911.aspx @returns {type.Component}
[ "For", "x509", "certificate" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/cert.js#L100-L111
12,424
citronneur/node-rdpjs
lib/protocol/cert.js
x509CertificateChain
function x509CertificateChain() { var self = { __TYPE__ : CertificateType.CERT_CHAIN_VERSION_2, NumCertBlobs : new type.UInt32Le(), CertBlobArray : new type.Factory(function(s) { self.CertBlobArray = new type.Component([]); for(var i = 0; i < self.NumCertBlobs.value; i++) { self.CertBlobArray.obj.push(certBlob().read(s)); } }), padding : new type.BinaryString(null, { readLength : new type.CallableValue(function() { return 8 + 4 * self.NumCertBlobs.value; }) }), /** * @return {object} {n : modulus{bignum}, e : publicexponent{integer} */ getPublicKey : function(){ var cert = x509.X509Certificate().decode(new type.Stream(self.CertBlobArray.obj[self.CertBlobArray.obj.length - 1].obj.abCert.value), asn1.ber); var publikeyStream = new type.Stream(cert.value.tbsCertificate.value.subjectPublicKeyInfo.value.subjectPublicKey.toBuffer()); var asn1PublicKey = x509.RSAPublicKey().decode(publikeyStream, asn1.ber); return rsa.publicKey(asn1PublicKey.value.modulus.value, asn1PublicKey.value.publicExponent.value); } }; return new type.Component(self); }
javascript
function x509CertificateChain() { var self = { __TYPE__ : CertificateType.CERT_CHAIN_VERSION_2, NumCertBlobs : new type.UInt32Le(), CertBlobArray : new type.Factory(function(s) { self.CertBlobArray = new type.Component([]); for(var i = 0; i < self.NumCertBlobs.value; i++) { self.CertBlobArray.obj.push(certBlob().read(s)); } }), padding : new type.BinaryString(null, { readLength : new type.CallableValue(function() { return 8 + 4 * self.NumCertBlobs.value; }) }), /** * @return {object} {n : modulus{bignum}, e : publicexponent{integer} */ getPublicKey : function(){ var cert = x509.X509Certificate().decode(new type.Stream(self.CertBlobArray.obj[self.CertBlobArray.obj.length - 1].obj.abCert.value), asn1.ber); var publikeyStream = new type.Stream(cert.value.tbsCertificate.value.subjectPublicKeyInfo.value.subjectPublicKey.toBuffer()); var asn1PublicKey = x509.RSAPublicKey().decode(publikeyStream, asn1.ber); return rsa.publicKey(asn1PublicKey.value.modulus.value, asn1PublicKey.value.publicExponent.value); } }; return new type.Component(self); }
[ "function", "x509CertificateChain", "(", ")", "{", "var", "self", "=", "{", "__TYPE__", ":", "CertificateType", ".", "CERT_CHAIN_VERSION_2", ",", "NumCertBlobs", ":", "new", "type", ".", "UInt32Le", "(", ")", ",", "CertBlobArray", ":", "new", "type", ".", "Factory", "(", "function", "(", "s", ")", "{", "self", ".", "CertBlobArray", "=", "new", "type", ".", "Component", "(", "[", "]", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "self", ".", "NumCertBlobs", ".", "value", ";", "i", "++", ")", "{", "self", ".", "CertBlobArray", ".", "obj", ".", "push", "(", "certBlob", "(", ")", ".", "read", "(", "s", ")", ")", ";", "}", "}", ")", ",", "padding", ":", "new", "type", ".", "BinaryString", "(", "null", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "8", "+", "4", "*", "self", ".", "NumCertBlobs", ".", "value", ";", "}", ")", "}", ")", ",", "/**\n * @return {object} {n : modulus{bignum}, e : publicexponent{integer}\n */", "getPublicKey", ":", "function", "(", ")", "{", "var", "cert", "=", "x509", ".", "X509Certificate", "(", ")", ".", "decode", "(", "new", "type", ".", "Stream", "(", "self", ".", "CertBlobArray", ".", "obj", "[", "self", ".", "CertBlobArray", ".", "obj", ".", "length", "-", "1", "]", ".", "obj", ".", "abCert", ".", "value", ")", ",", "asn1", ".", "ber", ")", ";", "var", "publikeyStream", "=", "new", "type", ".", "Stream", "(", "cert", ".", "value", ".", "tbsCertificate", ".", "value", ".", "subjectPublicKeyInfo", ".", "value", ".", "subjectPublicKey", ".", "toBuffer", "(", ")", ")", ";", "var", "asn1PublicKey", "=", "x509", ".", "RSAPublicKey", "(", ")", ".", "decode", "(", "publikeyStream", ",", "asn1", ".", "ber", ")", ";", "return", "rsa", ".", "publicKey", "(", "asn1PublicKey", ".", "value", ".", "modulus", ".", "value", ",", "asn1PublicKey", ".", "value", ".", "publicExponent", ".", "value", ")", ";", "}", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
x509 certificate chain @see http://msdn.microsoft.com/en-us/library/cc241910.aspx @returns {type.Component}
[ "x509", "certificate", "chain" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/cert.js#L118-L143
12,425
citronneur/node-rdpjs
lib/protocol/t125/mcs.js
MCS
function MCS(transport, recvOpCode, sendOpCode) { this.transport = transport; this.recvOpCode = recvOpCode; this.sendOpCode = sendOpCode; this.channels = [{id : Channel.MCS_GLOBAL_CHANNEL, name : 'global'}]; this.channels.find = function(callback) { for(var i in this) { if(callback(this[i])) return this[i]; }; }; // bind events var self = this; this.transport.on('close', function () { self.emit('close'); }).on('error', function (err) { self.emit('error', err); }); }
javascript
function MCS(transport, recvOpCode, sendOpCode) { this.transport = transport; this.recvOpCode = recvOpCode; this.sendOpCode = sendOpCode; this.channels = [{id : Channel.MCS_GLOBAL_CHANNEL, name : 'global'}]; this.channels.find = function(callback) { for(var i in this) { if(callback(this[i])) return this[i]; }; }; // bind events var self = this; this.transport.on('close', function () { self.emit('close'); }).on('error', function (err) { self.emit('error', err); }); }
[ "function", "MCS", "(", "transport", ",", "recvOpCode", ",", "sendOpCode", ")", "{", "this", ".", "transport", "=", "transport", ";", "this", ".", "recvOpCode", "=", "recvOpCode", ";", "this", ".", "sendOpCode", "=", "sendOpCode", ";", "this", ".", "channels", "=", "[", "{", "id", ":", "Channel", ".", "MCS_GLOBAL_CHANNEL", ",", "name", ":", "'global'", "}", "]", ";", "this", ".", "channels", ".", "find", "=", "function", "(", "callback", ")", "{", "for", "(", "var", "i", "in", "this", ")", "{", "if", "(", "callback", "(", "this", "[", "i", "]", ")", ")", "return", "this", "[", "i", "]", ";", "}", ";", "}", ";", "// bind events", "var", "self", "=", "this", ";", "this", ".", "transport", ".", "on", "(", "'close'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'close'", ")", ";", "}", ")", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "self", ".", "emit", "(", "'error'", ",", "err", ")", ";", "}", ")", ";", "}" ]
Multi-Channel Services @param transport {events.EventEmitter} transport layer listen (connect, data) events @param recvOpCode {DomainMCSPDU} opcode use in receive automata @param sendOpCode {DomainMCSPDU} opcode use to send message
[ "Multi", "-", "Channel", "Services" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/mcs.js#L125-L143
12,426
citronneur/node-rdpjs
lib/protocol/t125/mcs.js
Client
function Client(transport) { MCS.call(this, transport, DomainMCSPDU.SEND_DATA_INDICATION, DomainMCSPDU.SEND_DATA_REQUEST); // channel context automata this.channelsConnected = 0; // init gcc information this.clientCoreData = gcc.clientCoreData(); this.clientNetworkData = gcc.clientNetworkData(new type.Component([])); this.clientSecurityData = gcc.clientSecurityData(); // must be readed from protocol this.serverCoreData = null; this.serverSecurityData = null; this.serverNetworkData = null; var self = this; this.transport.on('connect', function(s) { self.connect(s); }); }
javascript
function Client(transport) { MCS.call(this, transport, DomainMCSPDU.SEND_DATA_INDICATION, DomainMCSPDU.SEND_DATA_REQUEST); // channel context automata this.channelsConnected = 0; // init gcc information this.clientCoreData = gcc.clientCoreData(); this.clientNetworkData = gcc.clientNetworkData(new type.Component([])); this.clientSecurityData = gcc.clientSecurityData(); // must be readed from protocol this.serverCoreData = null; this.serverSecurityData = null; this.serverNetworkData = null; var self = this; this.transport.on('connect', function(s) { self.connect(s); }); }
[ "function", "Client", "(", "transport", ")", "{", "MCS", ".", "call", "(", "this", ",", "transport", ",", "DomainMCSPDU", ".", "SEND_DATA_INDICATION", ",", "DomainMCSPDU", ".", "SEND_DATA_REQUEST", ")", ";", "// channel context automata", "this", ".", "channelsConnected", "=", "0", ";", "// init gcc information", "this", ".", "clientCoreData", "=", "gcc", ".", "clientCoreData", "(", ")", ";", "this", ".", "clientNetworkData", "=", "gcc", ".", "clientNetworkData", "(", "new", "type", ".", "Component", "(", "[", "]", ")", ")", ";", "this", ".", "clientSecurityData", "=", "gcc", ".", "clientSecurityData", "(", ")", ";", "// must be readed from protocol", "this", ".", "serverCoreData", "=", "null", ";", "this", ".", "serverSecurityData", "=", "null", ";", "this", ".", "serverNetworkData", "=", "null", ";", "var", "self", "=", "this", ";", "this", ".", "transport", ".", "on", "(", "'connect'", ",", "function", "(", "s", ")", "{", "self", ".", "connect", "(", "s", ")", ";", "}", ")", ";", "}" ]
Only main channels handle actually @param transport {event.EventEmitter} bind connect and data events @returns
[ "Only", "main", "channels", "handle", "actually" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/mcs.js#L203-L223
12,427
citronneur/node-rdpjs
lib/protocol/t125/mcs.js
Server
function Server (transport) { MCS.call(this, transport, DomainMCSPDU.SEND_DATA_REQUEST, DomainMCSPDU.SEND_DATA_INDICATION); // must be readed from protocol this.clientCoreData = null; this.clientNetworkData = null; this.clientSecurityData = null; // init gcc information this.serverCoreData = gcc.serverCoreData(); this.serverSecurityData = gcc.serverSecurityData(); this.serverNetworkData = gcc.serverNetworkData(new type.Component([])); var self = this; this.transport.on('connect', function (selectedProtocol) { self.serverCoreData.obj.clientRequestedProtocol.value = selectedProtocol; }).once('data', function (s) { self.recvConnectInitial(s); }); }
javascript
function Server (transport) { MCS.call(this, transport, DomainMCSPDU.SEND_DATA_REQUEST, DomainMCSPDU.SEND_DATA_INDICATION); // must be readed from protocol this.clientCoreData = null; this.clientNetworkData = null; this.clientSecurityData = null; // init gcc information this.serverCoreData = gcc.serverCoreData(); this.serverSecurityData = gcc.serverSecurityData(); this.serverNetworkData = gcc.serverNetworkData(new type.Component([])); var self = this; this.transport.on('connect', function (selectedProtocol) { self.serverCoreData.obj.clientRequestedProtocol.value = selectedProtocol; }).once('data', function (s) { self.recvConnectInitial(s); }); }
[ "function", "Server", "(", "transport", ")", "{", "MCS", ".", "call", "(", "this", ",", "transport", ",", "DomainMCSPDU", ".", "SEND_DATA_REQUEST", ",", "DomainMCSPDU", ".", "SEND_DATA_INDICATION", ")", ";", "// must be readed from protocol", "this", ".", "clientCoreData", "=", "null", ";", "this", ".", "clientNetworkData", "=", "null", ";", "this", ".", "clientSecurityData", "=", "null", ";", "// init gcc information", "this", ".", "serverCoreData", "=", "gcc", ".", "serverCoreData", "(", ")", ";", "this", ".", "serverSecurityData", "=", "gcc", ".", "serverSecurityData", "(", ")", ";", "this", ".", "serverNetworkData", "=", "gcc", ".", "serverNetworkData", "(", "new", "type", ".", "Component", "(", "[", "]", ")", ")", ";", "var", "self", "=", "this", ";", "this", ".", "transport", ".", "on", "(", "'connect'", ",", "function", "(", "selectedProtocol", ")", "{", "self", ".", "serverCoreData", ".", "obj", ".", "clientRequestedProtocol", ".", "value", "=", "selectedProtocol", ";", "}", ")", ".", "once", "(", "'data'", ",", "function", "(", "s", ")", "{", "self", ".", "recvConnectInitial", "(", "s", ")", ";", "}", ")", ";", "}" ]
Server side of MCS layer @param transport
[ "Server", "side", "of", "MCS", "layer" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/t125/mcs.js#L414-L433
12,428
citronneur/node-rdpjs
lib/protocol/tpkt.js
TPKT
function TPKT(transport) { this.transport = transport; // wait 2 bytes this.transport.expect(2); // next state is receive header var self = this; this.transport.once('data', function(s) { self.recvHeader(s); }).on('close', function() { self.emit('close'); }).on('error', function (err) { self.emit('error', err); }); }
javascript
function TPKT(transport) { this.transport = transport; // wait 2 bytes this.transport.expect(2); // next state is receive header var self = this; this.transport.once('data', function(s) { self.recvHeader(s); }).on('close', function() { self.emit('close'); }).on('error', function (err) { self.emit('error', err); }); }
[ "function", "TPKT", "(", "transport", ")", "{", "this", ".", "transport", "=", "transport", ";", "// wait 2 bytes", "this", ".", "transport", ".", "expect", "(", "2", ")", ";", "// next state is receive header", "var", "self", "=", "this", ";", "this", ".", "transport", ".", "once", "(", "'data'", ",", "function", "(", "s", ")", "{", "self", ".", "recvHeader", "(", "s", ")", ";", "}", ")", ".", "on", "(", "'close'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'close'", ")", ";", "}", ")", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "self", ".", "emit", "(", "'error'", ",", "err", ")", ";", "}", ")", ";", "}" ]
TPKT layer of rdp stack
[ "TPKT", "layer", "of", "rdp", "stack" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/tpkt.js#L38-L51
12,429
citronneur/node-rdpjs
lib/protocol/pdu/lic.js
licenseBinaryBlob
function licenseBinaryBlob(blobType) { blobType = blobType || BinaryBlobType.BB_ANY_BLOB; var self = { wBlobType : new type.UInt16Le(blobType, { constant : (blobType === BinaryBlobType.BB_ANY_BLOB)?false:true }), wBlobLen : new type.UInt16Le(function() { return self.blobData.size(); }), blobData : new type.BinaryString(null, { readLength : new type.CallableValue(function() { return self.wBlobLen.value; })}) }; return new type.Component(self); }
javascript
function licenseBinaryBlob(blobType) { blobType = blobType || BinaryBlobType.BB_ANY_BLOB; var self = { wBlobType : new type.UInt16Le(blobType, { constant : (blobType === BinaryBlobType.BB_ANY_BLOB)?false:true }), wBlobLen : new type.UInt16Le(function() { return self.blobData.size(); }), blobData : new type.BinaryString(null, { readLength : new type.CallableValue(function() { return self.wBlobLen.value; })}) }; return new type.Component(self); }
[ "function", "licenseBinaryBlob", "(", "blobType", ")", "{", "blobType", "=", "blobType", "||", "BinaryBlobType", ".", "BB_ANY_BLOB", ";", "var", "self", "=", "{", "wBlobType", ":", "new", "type", ".", "UInt16Le", "(", "blobType", ",", "{", "constant", ":", "(", "blobType", "===", "BinaryBlobType", ".", "BB_ANY_BLOB", ")", "?", "false", ":", "true", "}", ")", ",", "wBlobLen", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "self", ".", "blobData", ".", "size", "(", ")", ";", "}", ")", ",", "blobData", ":", "new", "type", ".", "BinaryString", "(", "null", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "wBlobLen", ".", "value", ";", "}", ")", "}", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
Binary blob to emcompass license information @see http://msdn.microsoft.com/en-us/library/cc240481.aspx @param blobType {BinaryBlobType.*} @returns {type.Component}
[ "Binary", "blob", "to", "emcompass", "license", "information" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/lic.js#L86-L99
12,430
citronneur/node-rdpjs
lib/protocol/pdu/lic.js
licensingErrorMessage
function licensingErrorMessage(opt) { var self = { __TYPE__ : MessageType.ERROR_ALERT, dwErrorCode : new type.UInt32Le(), dwStateTransition : new type.UInt32Le(), blob : licenseBinaryBlob(BinaryBlobType.BB_ANY_BLOB) }; return new type.Component(self, opt); }
javascript
function licensingErrorMessage(opt) { var self = { __TYPE__ : MessageType.ERROR_ALERT, dwErrorCode : new type.UInt32Le(), dwStateTransition : new type.UInt32Le(), blob : licenseBinaryBlob(BinaryBlobType.BB_ANY_BLOB) }; return new type.Component(self, opt); }
[ "function", "licensingErrorMessage", "(", "opt", ")", "{", "var", "self", "=", "{", "__TYPE__", ":", "MessageType", ".", "ERROR_ALERT", ",", "dwErrorCode", ":", "new", "type", ".", "UInt32Le", "(", ")", ",", "dwStateTransition", ":", "new", "type", ".", "UInt32Le", "(", ")", ",", "blob", ":", "licenseBinaryBlob", "(", "BinaryBlobType", ".", "BB_ANY_BLOB", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ",", "opt", ")", ";", "}" ]
Error message in license PDU automata @see http://msdn.microsoft.com/en-us/library/cc240482.aspx @param opt {object} type options @returns {type.Component}
[ "Error", "message", "in", "license", "PDU", "automata" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/lic.js#L107-L116
12,431
citronneur/node-rdpjs
lib/protocol/pdu/lic.js
productInformation
function productInformation() { var self = { dwVersion : new type.UInt32Le(), cbCompanyName : new type.UInt32Le(function() { return self.pbCompanyName.size(); }), // may contain "Microsoft Corporation" from server microsoft pbCompanyName : new type.BinaryString(new Buffer('Microsoft Corporation', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbCompanyName.value; })}), cbProductId : new type.UInt32Le(function() { return self.pbProductId.size(); }), // may contain "A02" from microsoft license server pbProductId : new type.BinaryString(new Buffer('A02', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbProductId.value; })}) }; return new type.Component(self); }
javascript
function productInformation() { var self = { dwVersion : new type.UInt32Le(), cbCompanyName : new type.UInt32Le(function() { return self.pbCompanyName.size(); }), // may contain "Microsoft Corporation" from server microsoft pbCompanyName : new type.BinaryString(new Buffer('Microsoft Corporation', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbCompanyName.value; })}), cbProductId : new type.UInt32Le(function() { return self.pbProductId.size(); }), // may contain "A02" from microsoft license server pbProductId : new type.BinaryString(new Buffer('A02', 'ucs2'), { readLength : new type.CallableValue(function() { return self.cbProductId.value; })}) }; return new type.Component(self); }
[ "function", "productInformation", "(", ")", "{", "var", "self", "=", "{", "dwVersion", ":", "new", "type", ".", "UInt32Le", "(", ")", ",", "cbCompanyName", ":", "new", "type", ".", "UInt32Le", "(", "function", "(", ")", "{", "return", "self", ".", "pbCompanyName", ".", "size", "(", ")", ";", "}", ")", ",", "// may contain \"Microsoft Corporation\" from server microsoft", "pbCompanyName", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'Microsoft Corporation'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbCompanyName", ".", "value", ";", "}", ")", "}", ")", ",", "cbProductId", ":", "new", "type", ".", "UInt32Le", "(", "function", "(", ")", "{", "return", "self", ".", "pbProductId", ".", "size", "(", ")", ";", "}", ")", ",", "// may contain \"A02\" from microsoft license server", "pbProductId", ":", "new", "type", ".", "BinaryString", "(", "new", "Buffer", "(", "'A02'", ",", "'ucs2'", ")", ",", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "cbProductId", ".", "value", ";", "}", ")", "}", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
License product informations @see http://msdn.microsoft.com/en-us/library/cc241915.aspx @returns {type.Component}
[ "License", "product", "informations" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/lic.js#L123-L143
12,432
citronneur/node-rdpjs
lib/protocol/pdu/lic.js
licensePacket
function licensePacket(message) { var self = { bMsgtype : new type.UInt8(function() { return self.licensingMessage.obj.__TYPE__; }), flag : new type.UInt8(Preambule.PREAMBLE_VERSION_3_0), wMsgSize : new type.UInt16Le(function() { return new type.Component(self).size(); }), licensingMessage : message || new type.Factory(function(s) { switch(self.bMsgtype.value) { case MessageType.ERROR_ALERT: self.licensingMessage = licensingErrorMessage({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.LICENSE_REQUEST: self.licensingMessage = serverLicenseRequest({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.NEW_LICENSE_REQUEST: self.licensingMessage = clientNewLicenseRequest({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.PLATFORM_CHALLENGE: self.licensingMessage = serverPlatformChallenge({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.PLATFORM_CHALLENGE_RESPONSE: self.licensingMessage = clientPLatformChallengeResponse({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; default: log.error('unknown license message type ' + self.bMsgtype.value); } }) }; return new type.Component(self); }
javascript
function licensePacket(message) { var self = { bMsgtype : new type.UInt8(function() { return self.licensingMessage.obj.__TYPE__; }), flag : new type.UInt8(Preambule.PREAMBLE_VERSION_3_0), wMsgSize : new type.UInt16Le(function() { return new type.Component(self).size(); }), licensingMessage : message || new type.Factory(function(s) { switch(self.bMsgtype.value) { case MessageType.ERROR_ALERT: self.licensingMessage = licensingErrorMessage({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.LICENSE_REQUEST: self.licensingMessage = serverLicenseRequest({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.NEW_LICENSE_REQUEST: self.licensingMessage = clientNewLicenseRequest({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.PLATFORM_CHALLENGE: self.licensingMessage = serverPlatformChallenge({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; case MessageType.PLATFORM_CHALLENGE_RESPONSE: self.licensingMessage = clientPLatformChallengeResponse({ readLength : new type.CallableValue(function() { return self.wMsgSize.value - 4; })}).read(s); break; default: log.error('unknown license message type ' + self.bMsgtype.value); } }) }; return new type.Component(self); }
[ "function", "licensePacket", "(", "message", ")", "{", "var", "self", "=", "{", "bMsgtype", ":", "new", "type", ".", "UInt8", "(", "function", "(", ")", "{", "return", "self", ".", "licensingMessage", ".", "obj", ".", "__TYPE__", ";", "}", ")", ",", "flag", ":", "new", "type", ".", "UInt8", "(", "Preambule", ".", "PREAMBLE_VERSION_3_0", ")", ",", "wMsgSize", ":", "new", "type", ".", "UInt16Le", "(", "function", "(", ")", "{", "return", "new", "type", ".", "Component", "(", "self", ")", ".", "size", "(", ")", ";", "}", ")", ",", "licensingMessage", ":", "message", "||", "new", "type", ".", "Factory", "(", "function", "(", "s", ")", "{", "switch", "(", "self", ".", "bMsgtype", ".", "value", ")", "{", "case", "MessageType", ".", "ERROR_ALERT", ":", "self", ".", "licensingMessage", "=", "licensingErrorMessage", "(", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "wMsgSize", ".", "value", "-", "4", ";", "}", ")", "}", ")", ".", "read", "(", "s", ")", ";", "break", ";", "case", "MessageType", ".", "LICENSE_REQUEST", ":", "self", ".", "licensingMessage", "=", "serverLicenseRequest", "(", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "wMsgSize", ".", "value", "-", "4", ";", "}", ")", "}", ")", ".", "read", "(", "s", ")", ";", "break", ";", "case", "MessageType", ".", "NEW_LICENSE_REQUEST", ":", "self", ".", "licensingMessage", "=", "clientNewLicenseRequest", "(", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "wMsgSize", ".", "value", "-", "4", ";", "}", ")", "}", ")", ".", "read", "(", "s", ")", ";", "break", ";", "case", "MessageType", ".", "PLATFORM_CHALLENGE", ":", "self", ".", "licensingMessage", "=", "serverPlatformChallenge", "(", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "wMsgSize", ".", "value", "-", "4", ";", "}", ")", "}", ")", ".", "read", "(", "s", ")", ";", "break", ";", "case", "MessageType", ".", "PLATFORM_CHALLENGE_RESPONSE", ":", "self", ".", "licensingMessage", "=", "clientPLatformChallengeResponse", "(", "{", "readLength", ":", "new", "type", ".", "CallableValue", "(", "function", "(", ")", "{", "return", "self", ".", "wMsgSize", ".", "value", "-", "4", ";", "}", ")", "}", ")", ".", "read", "(", "s", ")", ";", "break", ";", "default", ":", "log", ".", "error", "(", "'unknown license message type '", "+", "self", ".", "bMsgtype", ".", "value", ")", ";", "}", "}", ")", "}", ";", "return", "new", "type", ".", "Component", "(", "self", ")", ";", "}" ]
Global license packet @param packet {type.* | null} send packet @returns {type.Component}
[ "Global", "license", "packet" ]
0f487aa6c1f681bde6b416ca5b574e92f9184148
https://github.com/citronneur/node-rdpjs/blob/0f487aa6c1f681bde6b416ca5b574e92f9184148/lib/protocol/pdu/lic.js#L254-L297
12,433
jhnns/rewire
lib/moduleEnv.js
requireProxy
function requireProxy(path) { reset(); currentModule.require = nodeRequire; return nodeRequire.call(currentModule, path); // node's require only works when "this" points to the module }
javascript
function requireProxy(path) { reset(); currentModule.require = nodeRequire; return nodeRequire.call(currentModule, path); // node's require only works when "this" points to the module }
[ "function", "requireProxy", "(", "path", ")", "{", "reset", "(", ")", ";", "currentModule", ".", "require", "=", "nodeRequire", ";", "return", "nodeRequire", ".", "call", "(", "currentModule", ",", "path", ")", ";", "// node's require only works when \"this\" points to the module", "}" ]
Proxies the first require call in order to draw back all changes to the Module.wrapper. Thus our changes don't influence other modules @param {!String} path
[ "Proxies", "the", "first", "require", "call", "in", "order", "to", "draw", "back", "all", "changes", "to", "the", "Module", ".", "wrapper", ".", "Thus", "our", "changes", "don", "t", "influence", "other", "modules" ]
5bea3d816d0258e5204f1b49b08b9fb302ac53e1
https://github.com/jhnns/rewire/blob/5bea3d816d0258e5204f1b49b08b9fb302ac53e1/lib/moduleEnv.js#L77-L81
12,434
jhnns/rewire
lib/getImportGlobalsSrc.js
getImportGlobalsSrc
function getImportGlobalsSrc(ignore) { var key, value, src = "", globalObj = typeof global === "undefined"? window: global; ignore = ignore || []; // global itself can't be overridden because it's the only reference to our real global objects ignore.push("global"); // ignore 'module', 'exports' and 'require' on the global scope, because otherwise our code would // shadow the module-internal variables // @see https://github.com/jhnns/rewire-webpack/pull/6 ignore.push("module", "exports", "require"); for (key in globalObj) { /* jshint forin: false */ if (ignore.indexOf(key) !== -1) { continue; } value = globalObj[key]; // key may be an invalid variable name (e.g. 'a-b') try { eval("var " + key + ";"); src += "var " + key + " = global." + key + "; "; } catch(e) {} } return src; }
javascript
function getImportGlobalsSrc(ignore) { var key, value, src = "", globalObj = typeof global === "undefined"? window: global; ignore = ignore || []; // global itself can't be overridden because it's the only reference to our real global objects ignore.push("global"); // ignore 'module', 'exports' and 'require' on the global scope, because otherwise our code would // shadow the module-internal variables // @see https://github.com/jhnns/rewire-webpack/pull/6 ignore.push("module", "exports", "require"); for (key in globalObj) { /* jshint forin: false */ if (ignore.indexOf(key) !== -1) { continue; } value = globalObj[key]; // key may be an invalid variable name (e.g. 'a-b') try { eval("var " + key + ";"); src += "var " + key + " = global." + key + "; "; } catch(e) {} } return src; }
[ "function", "getImportGlobalsSrc", "(", "ignore", ")", "{", "var", "key", ",", "value", ",", "src", "=", "\"\"", ",", "globalObj", "=", "typeof", "global", "===", "\"undefined\"", "?", "window", ":", "global", ";", "ignore", "=", "ignore", "||", "[", "]", ";", "// global itself can't be overridden because it's the only reference to our real global objects", "ignore", ".", "push", "(", "\"global\"", ")", ";", "// ignore 'module', 'exports' and 'require' on the global scope, because otherwise our code would", "// shadow the module-internal variables", "// @see https://github.com/jhnns/rewire-webpack/pull/6", "ignore", ".", "push", "(", "\"module\"", ",", "\"exports\"", ",", "\"require\"", ")", ";", "for", "(", "key", "in", "globalObj", ")", "{", "/* jshint forin: false */", "if", "(", "ignore", ".", "indexOf", "(", "key", ")", "!==", "-", "1", ")", "{", "continue", ";", "}", "value", "=", "globalObj", "[", "key", "]", ";", "// key may be an invalid variable name (e.g. 'a-b')", "try", "{", "eval", "(", "\"var \"", "+", "key", "+", "\";\"", ")", ";", "src", "+=", "\"var \"", "+", "key", "+", "\" = global.\"", "+", "key", "+", "\"; \"", ";", "}", "catch", "(", "e", ")", "{", "}", "}", "return", "src", ";", "}" ]
Declares all globals with a var and assigns the global object. Thus you're able to override globals without changing the global object itself. Returns something like "var console = global.console; var process = global.process; ..." @return {String}
[ "Declares", "all", "globals", "with", "a", "var", "and", "assigns", "the", "global", "object", ".", "Thus", "you", "re", "able", "to", "override", "globals", "without", "changing", "the", "global", "object", "itself", "." ]
5bea3d816d0258e5204f1b49b08b9fb302ac53e1
https://github.com/jhnns/rewire/blob/5bea3d816d0258e5204f1b49b08b9fb302ac53e1/lib/getImportGlobalsSrc.js#L10-L38
12,435
jhnns/rewire
lib/detectStrictMode.js
detectStrictMode
function detectStrictMode(src) { var singleLine; var multiLine; while ((singleLine = singleLineComment.test(src)) || (multiLine = multiLineComment.test(src))) { if (singleLine) { src = src.replace(singleLineComment, ""); } if (multiLine) { src = src.replace(multiLineComment, ""); } } return strictMode.test(src); }
javascript
function detectStrictMode(src) { var singleLine; var multiLine; while ((singleLine = singleLineComment.test(src)) || (multiLine = multiLineComment.test(src))) { if (singleLine) { src = src.replace(singleLineComment, ""); } if (multiLine) { src = src.replace(multiLineComment, ""); } } return strictMode.test(src); }
[ "function", "detectStrictMode", "(", "src", ")", "{", "var", "singleLine", ";", "var", "multiLine", ";", "while", "(", "(", "singleLine", "=", "singleLineComment", ".", "test", "(", "src", ")", ")", "||", "(", "multiLine", "=", "multiLineComment", ".", "test", "(", "src", ")", ")", ")", "{", "if", "(", "singleLine", ")", "{", "src", "=", "src", ".", "replace", "(", "singleLineComment", ",", "\"\"", ")", ";", "}", "if", "(", "multiLine", ")", "{", "src", "=", "src", ".", "replace", "(", "multiLineComment", ",", "\"\"", ")", ";", "}", "}", "return", "strictMode", ".", "test", "(", "src", ")", ";", "}" ]
Returns true if the source code is intended to run in strict mode. Does not detect "use strict" if it occurs in a nested function. @param {String} src @return {Boolean}
[ "Returns", "true", "if", "the", "source", "code", "is", "intended", "to", "run", "in", "strict", "mode", ".", "Does", "not", "detect", "use", "strict", "if", "it", "occurs", "in", "a", "nested", "function", "." ]
5bea3d816d0258e5204f1b49b08b9fb302ac53e1
https://github.com/jhnns/rewire/blob/5bea3d816d0258e5204f1b49b08b9fb302ac53e1/lib/detectStrictMode.js#L12-L26
12,436
jhnns/rewire
lib/rewire.js
internalRewire
function internalRewire(parentModulePath, targetPath) { var targetModule, prelude, appendix, src; // Checking params if (typeof targetPath !== "string") { throw new TypeError("Filename must be a string"); } // Resolve full filename relative to the parent module targetPath = Module._resolveFilename(targetPath, parentModulePath); // Create testModule as it would be created by require() targetModule = new Module(targetPath, parentModulePath); // We prepend a list of all globals declared with var so they can be overridden (without changing original globals) prelude = getImportGlobalsSrc(); // Wrap module src inside IIFE so that function declarations do not clash with global variables // @see https://github.com/jhnns/rewire/issues/56 prelude += "(function () { "; // We append our special setter and getter. appendix = "\n" + getDefinePropertySrc(); // End of IIFE appendix += "})();"; // Check if the module uses the strict mode. // If so we must ensure that "use strict"; stays at the beginning of the module. src = fs.readFileSync(targetPath, "utf8"); if (detectStrictMode(src) === true) { prelude = ' "use strict"; ' + prelude; } moduleEnv.inject(prelude, appendix); moduleEnv.load(targetModule); return targetModule.exports; }
javascript
function internalRewire(parentModulePath, targetPath) { var targetModule, prelude, appendix, src; // Checking params if (typeof targetPath !== "string") { throw new TypeError("Filename must be a string"); } // Resolve full filename relative to the parent module targetPath = Module._resolveFilename(targetPath, parentModulePath); // Create testModule as it would be created by require() targetModule = new Module(targetPath, parentModulePath); // We prepend a list of all globals declared with var so they can be overridden (without changing original globals) prelude = getImportGlobalsSrc(); // Wrap module src inside IIFE so that function declarations do not clash with global variables // @see https://github.com/jhnns/rewire/issues/56 prelude += "(function () { "; // We append our special setter and getter. appendix = "\n" + getDefinePropertySrc(); // End of IIFE appendix += "})();"; // Check if the module uses the strict mode. // If so we must ensure that "use strict"; stays at the beginning of the module. src = fs.readFileSync(targetPath, "utf8"); if (detectStrictMode(src) === true) { prelude = ' "use strict"; ' + prelude; } moduleEnv.inject(prelude, appendix); moduleEnv.load(targetModule); return targetModule.exports; }
[ "function", "internalRewire", "(", "parentModulePath", ",", "targetPath", ")", "{", "var", "targetModule", ",", "prelude", ",", "appendix", ",", "src", ";", "// Checking params", "if", "(", "typeof", "targetPath", "!==", "\"string\"", ")", "{", "throw", "new", "TypeError", "(", "\"Filename must be a string\"", ")", ";", "}", "// Resolve full filename relative to the parent module", "targetPath", "=", "Module", ".", "_resolveFilename", "(", "targetPath", ",", "parentModulePath", ")", ";", "// Create testModule as it would be created by require()", "targetModule", "=", "new", "Module", "(", "targetPath", ",", "parentModulePath", ")", ";", "// We prepend a list of all globals declared with var so they can be overridden (without changing original globals)", "prelude", "=", "getImportGlobalsSrc", "(", ")", ";", "// Wrap module src inside IIFE so that function declarations do not clash with global variables", "// @see https://github.com/jhnns/rewire/issues/56", "prelude", "+=", "\"(function () { \"", ";", "// We append our special setter and getter.", "appendix", "=", "\"\\n\"", "+", "getDefinePropertySrc", "(", ")", ";", "// End of IIFE", "appendix", "+=", "\"})();\"", ";", "// Check if the module uses the strict mode.", "// If so we must ensure that \"use strict\"; stays at the beginning of the module.", "src", "=", "fs", ".", "readFileSync", "(", "targetPath", ",", "\"utf8\"", ")", ";", "if", "(", "detectStrictMode", "(", "src", ")", "===", "true", ")", "{", "prelude", "=", "' \"use strict\"; '", "+", "prelude", ";", "}", "moduleEnv", ".", "inject", "(", "prelude", ",", "appendix", ")", ";", "moduleEnv", ".", "load", "(", "targetModule", ")", ";", "return", "targetModule", ".", "exports", ";", "}" ]
Does actual rewiring the module. For further documentation @see index.js
[ "Does", "actual", "rewiring", "the", "module", ".", "For", "further", "documentation" ]
5bea3d816d0258e5204f1b49b08b9fb302ac53e1
https://github.com/jhnns/rewire/blob/5bea3d816d0258e5204f1b49b08b9fb302ac53e1/lib/rewire.js#L11-L52
12,437
GroceriStar/groceristar-fetch
src/projects/GroceriStar/groceristar.js
function () { return _.map(groceries, item => { const object = { id: item.id, name: item.name, departmentsCount: item.departments.length } delete object.departments // @TODO ???? return object }) }
javascript
function () { return _.map(groceries, item => { const object = { id: item.id, name: item.name, departmentsCount: item.departments.length } delete object.departments // @TODO ???? return object }) }
[ "function", "(", ")", "{", "return", "_", ".", "map", "(", "groceries", ",", "item", "=>", "{", "const", "object", "=", "{", "id", ":", "item", ".", "id", ",", "name", ":", "item", ".", "name", ",", "departmentsCount", ":", "item", ".", "departments", ".", "length", "}", "delete", "object", ".", "departments", "// @TODO ????", "return", "object", "}", ")", "}" ]
strange turnaround. @TODO can we
[ "strange", "turnaround", "." ]
463012c2053f8fdc188c38ecd454f1d240819656
https://github.com/GroceriStar/groceristar-fetch/blob/463012c2053f8fdc188c38ecd454f1d240819656/src/projects/GroceriStar/groceristar.js#L169-L180
12,438
GroceriStar/groceristar-fetch
src/projects/GroceriStar/groceristar.js
function () { const departments = [] // @TODO this is an example what should be updated. loooooks so bad and unreadable _.forEach(_.range(0, groceries.length), value => departments.push(..._.map(groceries[value]['departments'])) ) return departments }
javascript
function () { const departments = [] // @TODO this is an example what should be updated. loooooks so bad and unreadable _.forEach(_.range(0, groceries.length), value => departments.push(..._.map(groceries[value]['departments'])) ) return departments }
[ "function", "(", ")", "{", "const", "departments", "=", "[", "]", "// @TODO this is an example what should be updated. loooooks so bad and unreadable", "_", ".", "forEach", "(", "_", ".", "range", "(", "0", ",", "groceries", ".", "length", ")", ",", "value", "=>", "departments", ".", "push", "(", "...", "_", ".", "map", "(", "groceries", "[", "value", "]", "[", "'departments'", "]", ")", ")", ")", "return", "departments", "}" ]
i assume this cannot work, because we don't have groceries variable... @TODO
[ "i", "assume", "this", "cannot", "work", "because", "we", "don", "t", "have", "groceries", "variable", "..." ]
463012c2053f8fdc188c38ecd454f1d240819656
https://github.com/GroceriStar/groceristar-fetch/blob/463012c2053f8fdc188c38ecd454f1d240819656/src/projects/GroceriStar/groceristar.js#L183-L191
12,439
matreshkajs/matreshka
src/on/_addtreelistener.js
createTreeListener
function createTreeListener({ handler, restPath }) { const newHandler = function treeListener(changeEvent) { const extendedChangeEvent = { restPath, ...changeEvent }; const { previousValue, value } = changeEvent; // removes listener for all branches of the path on old object if (previousValue && typeof previousValue === 'object') { removeTreeListener(previousValue, restPath, handler); } // adds listener for all branches of "restPath" path on newly assigned object if (value && typeof value === 'object') { addTreeListener(value, restPath, handler); } // call original handler handler.call(this, extendedChangeEvent); }; newHandler._callback = handler; return newHandler; }
javascript
function createTreeListener({ handler, restPath }) { const newHandler = function treeListener(changeEvent) { const extendedChangeEvent = { restPath, ...changeEvent }; const { previousValue, value } = changeEvent; // removes listener for all branches of the path on old object if (previousValue && typeof previousValue === 'object') { removeTreeListener(previousValue, restPath, handler); } // adds listener for all branches of "restPath" path on newly assigned object if (value && typeof value === 'object') { addTreeListener(value, restPath, handler); } // call original handler handler.call(this, extendedChangeEvent); }; newHandler._callback = handler; return newHandler; }
[ "function", "createTreeListener", "(", "{", "handler", ",", "restPath", "}", ")", "{", "const", "newHandler", "=", "function", "treeListener", "(", "changeEvent", ")", "{", "const", "extendedChangeEvent", "=", "{", "restPath", ",", "...", "changeEvent", "}", ";", "const", "{", "previousValue", ",", "value", "}", "=", "changeEvent", ";", "// removes listener for all branches of the path on old object", "if", "(", "previousValue", "&&", "typeof", "previousValue", "===", "'object'", ")", "{", "removeTreeListener", "(", "previousValue", ",", "restPath", ",", "handler", ")", ";", "}", "// adds listener for all branches of \"restPath\" path on newly assigned object", "if", "(", "value", "&&", "typeof", "value", "===", "'object'", ")", "{", "addTreeListener", "(", "value", ",", "restPath", ",", "handler", ")", ";", "}", "// call original handler", "handler", ".", "call", "(", "this", ",", "extendedChangeEvent", ")", ";", "}", ";", "newHandler", ".", "_callback", "=", "handler", ";", "return", "newHandler", ";", "}" ]
creates tree listener
[ "creates", "tree", "listener" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/on/_addtreelistener.js#L5-L30
12,440
matreshkajs/matreshka
src/instantiate.js
defaultUpdateFunction
function defaultUpdateFunction(instance, data) { if (instance.isMatreshkaArray) { instance.recreate(data); } else if (instance.isMatreshkaObject) { instance.setData(data, { replaceData: true }); } else { // for other objects just extend them with given data nofn.assign(instance, data); } }
javascript
function defaultUpdateFunction(instance, data) { if (instance.isMatreshkaArray) { instance.recreate(data); } else if (instance.isMatreshkaObject) { instance.setData(data, { replaceData: true }); } else { // for other objects just extend them with given data nofn.assign(instance, data); } }
[ "function", "defaultUpdateFunction", "(", "instance", ",", "data", ")", "{", "if", "(", "instance", ".", "isMatreshkaArray", ")", "{", "instance", ".", "recreate", "(", "data", ")", ";", "}", "else", "if", "(", "instance", ".", "isMatreshkaObject", ")", "{", "instance", ".", "setData", "(", "data", ",", "{", "replaceData", ":", "true", "}", ")", ";", "}", "else", "{", "// for other objects just extend them with given data", "nofn", ".", "assign", "(", "instance", ",", "data", ")", ";", "}", "}" ]
the function is used when no update function is given
[ "the", "function", "is", "used", "when", "no", "update", "function", "is", "given" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/instantiate.js#L5-L14
12,441
matreshkajs/matreshka
src/instantiate.js
createInstantiateMediator
function createInstantiateMediator({ UsedClass, updateFunction }) { return function mediator(value, previousValue, key, object) { if (previousValue instanceof UsedClass) { updateFunction.call(object, previousValue, value, key); return previousValue; } return new UsedClass(value, object, key); }; }
javascript
function createInstantiateMediator({ UsedClass, updateFunction }) { return function mediator(value, previousValue, key, object) { if (previousValue instanceof UsedClass) { updateFunction.call(object, previousValue, value, key); return previousValue; } return new UsedClass(value, object, key); }; }
[ "function", "createInstantiateMediator", "(", "{", "UsedClass", ",", "updateFunction", "}", ")", "{", "return", "function", "mediator", "(", "value", ",", "previousValue", ",", "key", ",", "object", ")", "{", "if", "(", "previousValue", "instanceof", "UsedClass", ")", "{", "updateFunction", ".", "call", "(", "object", ",", "previousValue", ",", "value", ",", "key", ")", ";", "return", "previousValue", ";", "}", "return", "new", "UsedClass", "(", "value", ",", "object", ",", "key", ")", ";", "}", ";", "}" ]
returns mediator which controls assignments
[ "returns", "mediator", "which", "controls", "assignments" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/instantiate.js#L17-L29
12,442
matreshkajs/matreshka
src/array/pull.js
shift
function shift(arr, index) { for (let i = index; i < arr.length; i++) { arr[i] = arr[i + 1]; } delete arr[arr.length - 1]; arr.length -= 1; }
javascript
function shift(arr, index) { for (let i = index; i < arr.length; i++) { arr[i] = arr[i + 1]; } delete arr[arr.length - 1]; arr.length -= 1; }
[ "function", "shift", "(", "arr", ",", "index", ")", "{", "for", "(", "let", "i", "=", "index", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "arr", "[", "i", "]", "=", "arr", "[", "i", "+", "1", "]", ";", "}", "delete", "arr", "[", "arr", ".", "length", "-", "1", "]", ";", "arr", ".", "length", "-=", "1", ";", "}" ]
removes array item by given index
[ "removes", "array", "item", "by", "given", "index" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/array/pull.js#L5-L11
12,443
matreshkajs/matreshka
src/array/pull.js
pullByValue
function pullByValue(arr, value) { for (let i = 0; i < arr.length; i++) { if (arr[i] === value) { shift(arr, i); return value; } } return undefined; }
javascript
function pullByValue(arr, value) { for (let i = 0; i < arr.length; i++) { if (arr[i] === value) { shift(arr, i); return value; } } return undefined; }
[ "function", "pullByValue", "(", "arr", ",", "value", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "if", "(", "arr", "[", "i", "]", "===", "value", ")", "{", "shift", "(", "arr", ",", "i", ")", ";", "return", "value", ";", "}", "}", "return", "undefined", ";", "}" ]
finds array item that equals to given value and removes it returns removed value
[ "finds", "array", "item", "that", "equals", "to", "given", "value", "and", "removes", "it", "returns", "removed", "value" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/array/pull.js#L15-L24
12,444
matreshkajs/matreshka
src/array/pull.js
pullByIndex
function pullByIndex(arr, index) { if (index < arr.length) { const value = arr[index]; shift(arr, index); return value; } return undefined; }
javascript
function pullByIndex(arr, index) { if (index < arr.length) { const value = arr[index]; shift(arr, index); return value; } return undefined; }
[ "function", "pullByIndex", "(", "arr", ",", "index", ")", "{", "if", "(", "index", "<", "arr", ".", "length", ")", "{", "const", "value", "=", "arr", "[", "index", "]", ";", "shift", "(", "arr", ",", "index", ")", ";", "return", "value", ";", "}", "return", "undefined", ";", "}" ]
removes array item by given index if the index is not over array length returns removed value
[ "removes", "array", "item", "by", "given", "index", "if", "the", "index", "is", "not", "over", "array", "length", "returns", "removed", "value" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/array/pull.js#L28-L36
12,445
matreshkajs/matreshka
src/object/setdata.js
getNotListedKeys
function getNotListedKeys(inObject, fromObject) { const result = []; nofn.forOwn(inObject, (_, key) => { if (!(key in fromObject)) { result.push(key); } }); return result; }
javascript
function getNotListedKeys(inObject, fromObject) { const result = []; nofn.forOwn(inObject, (_, key) => { if (!(key in fromObject)) { result.push(key); } }); return result; }
[ "function", "getNotListedKeys", "(", "inObject", ",", "fromObject", ")", "{", "const", "result", "=", "[", "]", ";", "nofn", ".", "forOwn", "(", "inObject", ",", "(", "_", ",", "key", ")", "=>", "{", "if", "(", "!", "(", "key", "in", "fromObject", ")", ")", "{", "result", ".", "push", "(", "key", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
returns an array of keys listed at inObject but not listed at fromObject
[ "returns", "an", "array", "of", "keys", "listed", "at", "inObject", "but", "not", "listed", "at", "fromObject" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/object/setdata.js#L6-L15
12,446
matreshkajs/matreshka
src/on/_adddomlistener.js
createBindingHandlers
function createBindingHandlers({ fullEventName, domEventHandler, selector }) { return { bindHandler(evt = {}) { const { node } = evt; if (node) { dom.$(node).on(fullEventName, selector, domEventHandler); } }, unbindHandler(evt = {}) { const { node } = evt; if (node) { dom.$(node).off(fullEventName, selector, domEventHandler); } } }; }
javascript
function createBindingHandlers({ fullEventName, domEventHandler, selector }) { return { bindHandler(evt = {}) { const { node } = evt; if (node) { dom.$(node).on(fullEventName, selector, domEventHandler); } }, unbindHandler(evt = {}) { const { node } = evt; if (node) { dom.$(node).off(fullEventName, selector, domEventHandler); } } }; }
[ "function", "createBindingHandlers", "(", "{", "fullEventName", ",", "domEventHandler", ",", "selector", "}", ")", "{", "return", "{", "bindHandler", "(", "evt", "=", "{", "}", ")", "{", "const", "{", "node", "}", "=", "evt", ";", "if", "(", "node", ")", "{", "dom", ".", "$", "(", "node", ")", ".", "on", "(", "fullEventName", ",", "selector", ",", "domEventHandler", ")", ";", "}", "}", ",", "unbindHandler", "(", "evt", "=", "{", "}", ")", "{", "const", "{", "node", "}", "=", "evt", ";", "if", "(", "node", ")", "{", "dom", ".", "$", "(", "node", ")", ".", "off", "(", "fullEventName", ",", "selector", ",", "domEventHandler", ")", ";", "}", "}", "}", ";", "}" ]
returns an object with event handlers used at addDomListener
[ "returns", "an", "object", "with", "event", "handlers", "used", "at", "addDomListener" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/on/_adddomlistener.js#L8-L27
12,447
matreshkajs/matreshka
src/object/_afterinit.js
changeHandler
function changeHandler(eventOptions = {}) { const { key, silent } = eventOptions; const def = defs.get(this); if (key && key in def.keys && !silent) { triggerOne(this, 'set', eventOptions); triggerOne(this, 'modify', eventOptions); } }
javascript
function changeHandler(eventOptions = {}) { const { key, silent } = eventOptions; const def = defs.get(this); if (key && key in def.keys && !silent) { triggerOne(this, 'set', eventOptions); triggerOne(this, 'modify', eventOptions); } }
[ "function", "changeHandler", "(", "eventOptions", "=", "{", "}", ")", "{", "const", "{", "key", ",", "silent", "}", "=", "eventOptions", ";", "const", "def", "=", "defs", ".", "get", "(", "this", ")", ";", "if", "(", "key", "&&", "key", "in", "def", ".", "keys", "&&", "!", "silent", ")", "{", "triggerOne", "(", "this", ",", "'set'", ",", "eventOptions", ")", ";", "triggerOne", "(", "this", ",", "'modify'", ",", "eventOptions", ")", ";", "}", "}" ]
called on change triggers set and modify if data keys are changed
[ "called", "on", "change", "triggers", "set", "and", "modify", "if", "data", "keys", "are", "changed" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/object/_afterinit.js#L30-L38
12,448
matreshkajs/matreshka
src/mediate.js
createMediator
function createMediator({ object, propDef, key, mediator }) { return function propMediator(value) { // args: value, previousValue, key, object itself return mediator.call(object, value, propDef.value, key, object); }; }
javascript
function createMediator({ object, propDef, key, mediator }) { return function propMediator(value) { // args: value, previousValue, key, object itself return mediator.call(object, value, propDef.value, key, object); }; }
[ "function", "createMediator", "(", "{", "object", ",", "propDef", ",", "key", ",", "mediator", "}", ")", "{", "return", "function", "propMediator", "(", "value", ")", "{", "// args: value, previousValue, key, object itself", "return", "mediator", ".", "call", "(", "object", ",", "value", ",", "propDef", ".", "value", ",", "key", ",", "object", ")", ";", "}", ";", "}" ]
creates property mediator
[ "creates", "property", "mediator" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/mediate.js#L8-L18
12,449
matreshkajs/matreshka
src/_dom/mq/on.js
is
function is(node, selector) { return (node.matches || node.webkitMatchesSelector || node.mozMatchesSelector || node.msMatchesSelector || node.oMatchesSelector).call(node, selector); }
javascript
function is(node, selector) { return (node.matches || node.webkitMatchesSelector || node.mozMatchesSelector || node.msMatchesSelector || node.oMatchesSelector).call(node, selector); }
[ "function", "is", "(", "node", ",", "selector", ")", "{", "return", "(", "node", ".", "matches", "||", "node", ".", "webkitMatchesSelector", "||", "node", ".", "mozMatchesSelector", "||", "node", ".", "msMatchesSelector", "||", "node", ".", "oMatchesSelector", ")", ".", "call", "(", "node", ",", "selector", ")", ";", "}" ]
x12345y checks an element against a selector
[ "x12345y", "checks", "an", "element", "against", "a", "selector" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/_dom/mq/on.js#L8-L14
12,450
matreshkajs/matreshka
src/_dom/mq/on.js
delegateHandler
function delegateHandler(evt, selector, handler) { const scopeSelector = `[${randomID}="${randomID}"] `; const splittedSelector = selector.split(','); let matching = ''; for (let i = 0; i < splittedSelector.length; i++) { const sel = splittedSelector[i]; matching += `${i === 0 ? '' : ','}${scopeSelector}${sel},${scopeSelector}${sel} *`; } this.setAttribute(randomID, randomID); if (is(evt.target, matching)) { handler.call(this, evt); } this.removeAttribute(randomID); }
javascript
function delegateHandler(evt, selector, handler) { const scopeSelector = `[${randomID}="${randomID}"] `; const splittedSelector = selector.split(','); let matching = ''; for (let i = 0; i < splittedSelector.length; i++) { const sel = splittedSelector[i]; matching += `${i === 0 ? '' : ','}${scopeSelector}${sel},${scopeSelector}${sel} *`; } this.setAttribute(randomID, randomID); if (is(evt.target, matching)) { handler.call(this, evt); } this.removeAttribute(randomID); }
[ "function", "delegateHandler", "(", "evt", ",", "selector", ",", "handler", ")", "{", "const", "scopeSelector", "=", "`", "${", "randomID", "}", "${", "randomID", "}", "`", ";", "const", "splittedSelector", "=", "selector", ".", "split", "(", "','", ")", ";", "let", "matching", "=", "''", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "splittedSelector", ".", "length", ";", "i", "++", ")", "{", "const", "sel", "=", "splittedSelector", "[", "i", "]", ";", "matching", "+=", "`", "${", "i", "===", "0", "?", "''", ":", "','", "}", "${", "scopeSelector", "}", "${", "sel", "}", "${", "scopeSelector", "}", "${", "sel", "}", "`", ";", "}", "this", ".", "setAttribute", "(", "randomID", ",", "randomID", ")", ";", "if", "(", "is", "(", "evt", ".", "target", ",", "matching", ")", ")", "{", "handler", ".", "call", "(", "this", ",", "evt", ")", ";", "}", "this", ".", "removeAttribute", "(", "randomID", ")", ";", "}" ]
the function is used when a selector is given
[ "the", "function", "is", "used", "when", "a", "selector", "is", "given" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/_dom/mq/on.js#L17-L36
12,451
matreshkajs/matreshka
src/array/mediateitem.js
createItemMediator
function createItemMediator({ arr, mediator }) { return function itemMediator(value, index) { // args: value, old value, index, array itself return mediator.call(arr, value, index, arr); }; }
javascript
function createItemMediator({ arr, mediator }) { return function itemMediator(value, index) { // args: value, old value, index, array itself return mediator.call(arr, value, index, arr); }; }
[ "function", "createItemMediator", "(", "{", "arr", ",", "mediator", "}", ")", "{", "return", "function", "itemMediator", "(", "value", ",", "index", ")", "{", "// args: value, old value, index, array itself", "return", "mediator", ".", "call", "(", "arr", ",", "value", ",", "index", ",", "arr", ")", ";", "}", ";", "}" ]
creates item mediator
[ "creates", "item", "mediator" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/array/mediateitem.js#L4-L12
12,452
matreshkajs/matreshka
src/array/_afterinit.js
modelItemMediator
function modelItemMediator(item, index) { const { Model } = this; // if an item is already instance of Model if (item instanceof Model) { return item; } let itemData; if (item && typeof item.toJSON === 'function') { // if item is not falsy and if it has toJSON method // then retrieve instance data by this method itemData = item.toJSON(false); } else { // if not then use an item as its data itemData = item; } return new Model(itemData, this, index); }
javascript
function modelItemMediator(item, index) { const { Model } = this; // if an item is already instance of Model if (item instanceof Model) { return item; } let itemData; if (item && typeof item.toJSON === 'function') { // if item is not falsy and if it has toJSON method // then retrieve instance data by this method itemData = item.toJSON(false); } else { // if not then use an item as its data itemData = item; } return new Model(itemData, this, index); }
[ "function", "modelItemMediator", "(", "item", ",", "index", ")", "{", "const", "{", "Model", "}", "=", "this", ";", "// if an item is already instance of Model", "if", "(", "item", "instanceof", "Model", ")", "{", "return", "item", ";", "}", "let", "itemData", ";", "if", "(", "item", "&&", "typeof", "item", ".", "toJSON", "===", "'function'", ")", "{", "// if item is not falsy and if it has toJSON method", "// then retrieve instance data by this method", "itemData", "=", "item", ".", "toJSON", "(", "false", ")", ";", "}", "else", "{", "// if not then use an item as its data", "itemData", "=", "item", ";", "}", "return", "new", "Model", "(", "itemData", ",", "this", ",", "index", ")", ";", "}" ]
the function returns array item converted to Model instance
[ "the", "function", "returns", "array", "item", "converted", "to", "Model", "instance" ]
943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb
https://github.com/matreshkajs/matreshka/blob/943ab6b8dd07bdeec7ffe089196fb5dde5a4dabb/src/array/_afterinit.js#L6-L26
12,453
lonelyplanet/backpack-ui
src/utils/grid.js
percentage
function percentage(target, context) { if (target.slice(-1) === "%" || context.slice(-1) === "%") { throw new Error(`Cannot calculate percentage; one or more units appear to be %. Units must be rem or px.`); } if (target.slice(-1) !== context.slice(-1)) { throw new Error("Cannot calculate percentage; units do not appear to match."); } const unit = target.slice(-1) === "x" ? "px" : "rem"; const numbers = _getNumbers([target, context], "static", unit); const result = numbers.reduce((a, b) => a / b) * 100; return _affixValue(result, "fluid"); }
javascript
function percentage(target, context) { if (target.slice(-1) === "%" || context.slice(-1) === "%") { throw new Error(`Cannot calculate percentage; one or more units appear to be %. Units must be rem or px.`); } if (target.slice(-1) !== context.slice(-1)) { throw new Error("Cannot calculate percentage; units do not appear to match."); } const unit = target.slice(-1) === "x" ? "px" : "rem"; const numbers = _getNumbers([target, context], "static", unit); const result = numbers.reduce((a, b) => a / b) * 100; return _affixValue(result, "fluid"); }
[ "function", "percentage", "(", "target", ",", "context", ")", "{", "if", "(", "target", ".", "slice", "(", "-", "1", ")", "===", "\"%\"", "||", "context", ".", "slice", "(", "-", "1", ")", "===", "\"%\"", ")", "{", "throw", "new", "Error", "(", "`", "`", ")", ";", "}", "if", "(", "target", ".", "slice", "(", "-", "1", ")", "!==", "context", ".", "slice", "(", "-", "1", ")", ")", "{", "throw", "new", "Error", "(", "\"Cannot calculate percentage; units do not appear to match.\"", ")", ";", "}", "const", "unit", "=", "target", ".", "slice", "(", "-", "1", ")", "===", "\"x\"", "?", "\"px\"", ":", "\"rem\"", ";", "const", "numbers", "=", "_getNumbers", "(", "[", "target", ",", "context", "]", ",", "\"static\"", ",", "unit", ")", ";", "const", "result", "=", "numbers", ".", "reduce", "(", "(", "a", ",", "b", ")", "=>", "a", "/", "b", ")", "*", "100", ";", "return", "_affixValue", "(", "result", ",", "\"fluid\"", ")", ";", "}" ]
Calculate a percent value from two static values @todo Add better regex matching to validate rem or px only @param {String} target The width of the element that will be converted to a percent @param {String} context The width of the element's container @return {String} Converted value @usage percentage("12rem", "120rem");
[ "Calculate", "a", "percent", "value", "from", "two", "static", "values" ]
999b4cc15b1f0d3186357161340f20ed56ded8bc
https://github.com/lonelyplanet/backpack-ui/blob/999b4cc15b1f0d3186357161340f20ed56ded8bc/src/utils/grid.js#L129-L143
12,454
lonelyplanet/backpack-ui
src/utils/grid.js
gutter
function gutter( math = settings.math, columns = settings.columns, multiplier = 1 ) { const gutterWidth = _calculateGutter(multiplier); const containerWidth = _updateContext( typeof columns === "string" ? parseInt(columns, 10) : columns ); if (math === "static") { return _staticCalculation(gutterWidth); } if (math === "fluid") { return _percent(gutterWidth, containerWidth); } return false; }
javascript
function gutter( math = settings.math, columns = settings.columns, multiplier = 1 ) { const gutterWidth = _calculateGutter(multiplier); const containerWidth = _updateContext( typeof columns === "string" ? parseInt(columns, 10) : columns ); if (math === "static") { return _staticCalculation(gutterWidth); } if (math === "fluid") { return _percent(gutterWidth, containerWidth); } return false; }
[ "function", "gutter", "(", "math", "=", "settings", ".", "math", ",", "columns", "=", "settings", ".", "columns", ",", "multiplier", "=", "1", ")", "{", "const", "gutterWidth", "=", "_calculateGutter", "(", "multiplier", ")", ";", "const", "containerWidth", "=", "_updateContext", "(", "typeof", "columns", "===", "\"string\"", "?", "parseInt", "(", "columns", ",", "10", ")", ":", "columns", ")", ";", "if", "(", "math", "===", "\"static\"", ")", "{", "return", "_staticCalculation", "(", "gutterWidth", ")", ";", "}", "if", "(", "math", "===", "\"fluid\"", ")", "{", "return", "_percent", "(", "gutterWidth", ",", "containerWidth", ")", ";", "}", "return", "false", ";", "}" ]
Output the gutter width @param {string} math Type of calculation, "fluid" or "static"; defaults to global settings @param {number} columns The number of columns; changes context @param {number} multiplier Number to multiply the gutter by @return {function} Function to make calculation
[ "Output", "the", "gutter", "width" ]
999b4cc15b1f0d3186357161340f20ed56ded8bc
https://github.com/lonelyplanet/backpack-ui/blob/999b4cc15b1f0d3186357161340f20ed56ded8bc/src/utils/grid.js#L161-L182
12,455
lonelyplanet/backpack-ui
src/utils/mixins.js
visuallyHidden
function visuallyHidden(focusable) { const focusableStyles = { clip: "auto", clipPath: "none", height: "auto", margin: 0, overflow: "visible", position: "static", whiteSpace: "inherit", width: "auto", }; return Object.assign({}, { border: 0, clipPath: "inset(50%)", display: "inline-block", height: "1px", margin: "-1px", overflow: "hidden", padding: 0, whiteSpace: "nowrap", width: "1px", }, focusable === "focusable" ? { ":active": focusableStyles, ":focus": focusableStyles, } : {}); }
javascript
function visuallyHidden(focusable) { const focusableStyles = { clip: "auto", clipPath: "none", height: "auto", margin: 0, overflow: "visible", position: "static", whiteSpace: "inherit", width: "auto", }; return Object.assign({}, { border: 0, clipPath: "inset(50%)", display: "inline-block", height: "1px", margin: "-1px", overflow: "hidden", padding: 0, whiteSpace: "nowrap", width: "1px", }, focusable === "focusable" ? { ":active": focusableStyles, ":focus": focusableStyles, } : {}); }
[ "function", "visuallyHidden", "(", "focusable", ")", "{", "const", "focusableStyles", "=", "{", "clip", ":", "\"auto\"", ",", "clipPath", ":", "\"none\"", ",", "height", ":", "\"auto\"", ",", "margin", ":", "0", ",", "overflow", ":", "\"visible\"", ",", "position", ":", "\"static\"", ",", "whiteSpace", ":", "\"inherit\"", ",", "width", ":", "\"auto\"", ",", "}", ";", "return", "Object", ".", "assign", "(", "{", "}", ",", "{", "border", ":", "0", ",", "clipPath", ":", "\"inset(50%)\"", ",", "display", ":", "\"inline-block\"", ",", "height", ":", "\"1px\"", ",", "margin", ":", "\"-1px\"", ",", "overflow", ":", "\"hidden\"", ",", "padding", ":", "0", ",", "whiteSpace", ":", "\"nowrap\"", ",", "width", ":", "\"1px\"", ",", "}", ",", "focusable", "===", "\"focusable\"", "?", "{", "\":active\"", ":", "focusableStyles", ",", "\":focus\"", ":", "focusableStyles", ",", "}", ":", "{", "}", ")", ";", "}" ]
Hide only visually, but have available for screen readers @return {Object} CSS styles
[ "Hide", "only", "visually", "but", "have", "available", "for", "screen", "readers" ]
999b4cc15b1f0d3186357161340f20ed56ded8bc
https://github.com/lonelyplanet/backpack-ui/blob/999b4cc15b1f0d3186357161340f20ed56ded8bc/src/utils/mixins.js#L21-L47
12,456
lonelyplanet/backpack-ui
src/utils/mixins.js
blueLink
function blueLink() { return { color: colors.linkPrimary, textDecoration: "none", transition: `color ${timing.fast} ease-in-out`, ":hover": { color: colors.linkPrimaryHover, }, ":active": { color: colors.linkPrimaryHover, }, ":focus": Object.assign({}, outline(), { color: colors.linkPrimaryHover, }), }; }
javascript
function blueLink() { return { color: colors.linkPrimary, textDecoration: "none", transition: `color ${timing.fast} ease-in-out`, ":hover": { color: colors.linkPrimaryHover, }, ":active": { color: colors.linkPrimaryHover, }, ":focus": Object.assign({}, outline(), { color: colors.linkPrimaryHover, }), }; }
[ "function", "blueLink", "(", ")", "{", "return", "{", "color", ":", "colors", ".", "linkPrimary", ",", "textDecoration", ":", "\"none\"", ",", "transition", ":", "`", "${", "timing", ".", "fast", "}", "`", ",", "\":hover\"", ":", "{", "color", ":", "colors", ".", "linkPrimaryHover", ",", "}", ",", "\":active\"", ":", "{", "color", ":", "colors", ".", "linkPrimaryHover", ",", "}", ",", "\":focus\"", ":", "Object", ".", "assign", "(", "{", "}", ",", "outline", "(", ")", ",", "{", "color", ":", "colors", ".", "linkPrimaryHover", ",", "}", ")", ",", "}", ";", "}" ]
Creates a blue hyperlink; for use with inline styles via Radium @return {Object} CSS styles
[ "Creates", "a", "blue", "hyperlink", ";", "for", "use", "with", "inline", "styles", "via", "Radium" ]
999b4cc15b1f0d3186357161340f20ed56ded8bc
https://github.com/lonelyplanet/backpack-ui/blob/999b4cc15b1f0d3186357161340f20ed56ded8bc/src/utils/mixins.js#L53-L71
12,457
lonelyplanet/backpack-ui
src/utils/mixins.js
underlinedLink
function underlinedLink(linkColor = colors.textPrimary) { const underlineOffset = 2; const underlineWeight = 1; const backgroundColor = colors.bgPrimary; const underlineColor = rgba(linkColor, 0.4); return { color: linkColor, position: "relative", textDecoration: "none", transition: `color ${timing.fast} ease`, // Draw the underline with a background gradient backgroundImage: `linear-gradient( to top, transparent, transparent ${underlineOffset}px, ${underlineColor} ${underlineOffset}px, ${underlineColor} ${(underlineOffset + underlineWeight)}px, transparent ${(underlineOffset + underlineWeight)}px )`, // Create breaks in the underline textShadow: `-1px -1px 0 ${backgroundColor}, 1px -1px 0 ${backgroundColor}, -1px 1px 0 ${backgroundColor}, 1px 1px 0 ${backgroundColor}`, }; }
javascript
function underlinedLink(linkColor = colors.textPrimary) { const underlineOffset = 2; const underlineWeight = 1; const backgroundColor = colors.bgPrimary; const underlineColor = rgba(linkColor, 0.4); return { color: linkColor, position: "relative", textDecoration: "none", transition: `color ${timing.fast} ease`, // Draw the underline with a background gradient backgroundImage: `linear-gradient( to top, transparent, transparent ${underlineOffset}px, ${underlineColor} ${underlineOffset}px, ${underlineColor} ${(underlineOffset + underlineWeight)}px, transparent ${(underlineOffset + underlineWeight)}px )`, // Create breaks in the underline textShadow: `-1px -1px 0 ${backgroundColor}, 1px -1px 0 ${backgroundColor}, -1px 1px 0 ${backgroundColor}, 1px 1px 0 ${backgroundColor}`, }; }
[ "function", "underlinedLink", "(", "linkColor", "=", "colors", ".", "textPrimary", ")", "{", "const", "underlineOffset", "=", "2", ";", "const", "underlineWeight", "=", "1", ";", "const", "backgroundColor", "=", "colors", ".", "bgPrimary", ";", "const", "underlineColor", "=", "rgba", "(", "linkColor", ",", "0.4", ")", ";", "return", "{", "color", ":", "linkColor", ",", "position", ":", "\"relative\"", ",", "textDecoration", ":", "\"none\"", ",", "transition", ":", "`", "${", "timing", ".", "fast", "}", "`", ",", "// Draw the underline with a background gradient", "backgroundImage", ":", "`", "${", "underlineOffset", "}", "${", "underlineColor", "}", "${", "underlineOffset", "}", "${", "underlineColor", "}", "${", "(", "underlineOffset", "+", "underlineWeight", ")", "}", "${", "(", "underlineOffset", "+", "underlineWeight", ")", "}", "`", ",", "// Create breaks in the underline", "textShadow", ":", "`", "${", "backgroundColor", "}", "${", "backgroundColor", "}", "${", "backgroundColor", "}", "${", "backgroundColor", "}", "`", ",", "}", ";", "}" ]
Creates a nicely underlined hyperlink @param {String} linkColor Link color @return {Object} CSS styles object
[ "Creates", "a", "nicely", "underlined", "hyperlink" ]
999b4cc15b1f0d3186357161340f20ed56ded8bc
https://github.com/lonelyplanet/backpack-ui/blob/999b4cc15b1f0d3186357161340f20ed56ded8bc/src/utils/mixins.js#L78-L106
12,458
vapid/vapid
lib/middleware/webpack/config.js
config
function config(mode = 'production', assetDirs = [], moduleDirs = [], outputDir = false) { const context = resolve(__dirname, '../../../node_modules'); const entry = _entry(Utils.castArray(assetDirs)); const output = outputDir ? { filename: '[name].js', path: outputDir } : {}; const removeFiles = _removeFiles(entry); const resolveModules = Utils.concat([context], moduleDirs); const devtool = mode === 'development' ? 'source-map' : false; return { mode, context, entry, output, devtool, module: { rules: [ { test: /\.s[ac]ss$/, use: [ { loader: MiniCssExtractPlugin.loader }, { loader: 'css-loader', options: { url: false, sourceMap: true } }, { loader: 'sass-loader', options: { implementation: sass, sourceMap: true } }, { loader: 'resolve-url-loader' }, ], }, ], }, plugins: [ new MiniCssExtractPlugin({ filename: '[name].css', }), new RemoveFilesPlugin({ files: removeFiles, }), ], resolve: { modules: resolveModules, }, }; }
javascript
function config(mode = 'production', assetDirs = [], moduleDirs = [], outputDir = false) { const context = resolve(__dirname, '../../../node_modules'); const entry = _entry(Utils.castArray(assetDirs)); const output = outputDir ? { filename: '[name].js', path: outputDir } : {}; const removeFiles = _removeFiles(entry); const resolveModules = Utils.concat([context], moduleDirs); const devtool = mode === 'development' ? 'source-map' : false; return { mode, context, entry, output, devtool, module: { rules: [ { test: /\.s[ac]ss$/, use: [ { loader: MiniCssExtractPlugin.loader }, { loader: 'css-loader', options: { url: false, sourceMap: true } }, { loader: 'sass-loader', options: { implementation: sass, sourceMap: true } }, { loader: 'resolve-url-loader' }, ], }, ], }, plugins: [ new MiniCssExtractPlugin({ filename: '[name].css', }), new RemoveFilesPlugin({ files: removeFiles, }), ], resolve: { modules: resolveModules, }, }; }
[ "function", "config", "(", "mode", "=", "'production'", ",", "assetDirs", "=", "[", "]", ",", "moduleDirs", "=", "[", "]", ",", "outputDir", "=", "false", ")", "{", "const", "context", "=", "resolve", "(", "__dirname", ",", "'../../../node_modules'", ")", ";", "const", "entry", "=", "_entry", "(", "Utils", ".", "castArray", "(", "assetDirs", ")", ")", ";", "const", "output", "=", "outputDir", "?", "{", "filename", ":", "'[name].js'", ",", "path", ":", "outputDir", "}", ":", "{", "}", ";", "const", "removeFiles", "=", "_removeFiles", "(", "entry", ")", ";", "const", "resolveModules", "=", "Utils", ".", "concat", "(", "[", "context", "]", ",", "moduleDirs", ")", ";", "const", "devtool", "=", "mode", "===", "'development'", "?", "'source-map'", ":", "false", ";", "return", "{", "mode", ",", "context", ",", "entry", ",", "output", ",", "devtool", ",", "module", ":", "{", "rules", ":", "[", "{", "test", ":", "/", "\\.s[ac]ss$", "/", ",", "use", ":", "[", "{", "loader", ":", "MiniCssExtractPlugin", ".", "loader", "}", ",", "{", "loader", ":", "'css-loader'", ",", "options", ":", "{", "url", ":", "false", ",", "sourceMap", ":", "true", "}", "}", ",", "{", "loader", ":", "'sass-loader'", ",", "options", ":", "{", "implementation", ":", "sass", ",", "sourceMap", ":", "true", "}", "}", ",", "{", "loader", ":", "'resolve-url-loader'", "}", ",", "]", ",", "}", ",", "]", ",", "}", ",", "plugins", ":", "[", "new", "MiniCssExtractPlugin", "(", "{", "filename", ":", "'[name].css'", ",", "}", ")", ",", "new", "RemoveFilesPlugin", "(", "{", "files", ":", "removeFiles", ",", "}", ")", ",", "]", ",", "resolve", ":", "{", "modules", ":", "resolveModules", ",", "}", ",", "}", ";", "}" ]
Dynamic config for Webpack @param {string} options @return {Object} Webpack configuration
[ "Dynamic", "config", "for", "Webpack" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/middleware/webpack/config.js#L14-L56
12,459
vapid/vapid
lib/middleware/webpack/config.js
_removeFiles
function _removeFiles(entry) { return Utils.reduce(entry, (memo, value, key) => { if (value[0].match(/\.pack\.s[ac]ss/)) { memo.push(`${key}.js`); } return memo; }, []); }
javascript
function _removeFiles(entry) { return Utils.reduce(entry, (memo, value, key) => { if (value[0].match(/\.pack\.s[ac]ss/)) { memo.push(`${key}.js`); } return memo; }, []); }
[ "function", "_removeFiles", "(", "entry", ")", "{", "return", "Utils", ".", "reduce", "(", "entry", ",", "(", "memo", ",", "value", ",", "key", ")", "=>", "{", "if", "(", "value", "[", "0", "]", ".", "match", "(", "/", "\\.pack\\.s[ac]ss", "/", ")", ")", "{", "memo", ".", "push", "(", "`", "${", "key", "}", "`", ")", ";", "}", "return", "memo", ";", "}", ",", "[", "]", ")", ";", "}" ]
Scans entries for Sass files, and excludes the associated .js garbage files @param {Object} entry @return {array} list of files to remove from the final output
[ "Scans", "entries", "for", "Sass", "files", "and", "excludes", "the", "associated", ".", "js", "garbage", "files" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/middleware/webpack/config.js#L84-L91
12,460
vapid/vapid
lib/deployer.js
_updatePjson
function _updatePjson(siteId) { pjson.vapid.site = siteId; writePkg.sync(pjsonPath, pjson); }
javascript
function _updatePjson(siteId) { pjson.vapid.site = siteId; writePkg.sync(pjsonPath, pjson); }
[ "function", "_updatePjson", "(", "siteId", ")", "{", "pjson", ".", "vapid", ".", "site", "=", "siteId", ";", "writePkg", ".", "sync", "(", "pjsonPath", ",", "pjson", ")", ";", "}" ]
Save the site UUID into package.json @param {string} siteId
[ "Save", "the", "site", "UUID", "into", "package", ".", "json" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L146-L149
12,461
vapid/vapid
lib/deployer.js
_generateManifest
function _generateManifest(siteChecksums, presignedPosts) { return Utils.reduce(siteChecksums, (memo, checksum, path) => { /* eslint-disable-next-line no-param-reassign */ memo[path] = presignedPosts[path].digest; return memo; }, {}); }
javascript
function _generateManifest(siteChecksums, presignedPosts) { return Utils.reduce(siteChecksums, (memo, checksum, path) => { /* eslint-disable-next-line no-param-reassign */ memo[path] = presignedPosts[path].digest; return memo; }, {}); }
[ "function", "_generateManifest", "(", "siteChecksums", ",", "presignedPosts", ")", "{", "return", "Utils", ".", "reduce", "(", "siteChecksums", ",", "(", "memo", ",", "checksum", ",", "path", ")", "=>", "{", "/* eslint-disable-next-line no-param-reassign */", "memo", "[", "path", "]", "=", "presignedPosts", "[", "path", "]", ".", "digest", ";", "return", "memo", ";", "}", ",", "{", "}", ")", ";", "}" ]
Generate a manifest @param {Object} siteChecksums @param {Object} presignedPosts @return {Object} manifest
[ "Generate", "a", "manifest" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L157-L163
12,462
vapid/vapid
lib/deployer.js
_checksums
function _checksums(dir) { const checksums = {}; glob.sync(resolve(dir, '**/!(*.pack.+(s[ac]ss|js))'), { mark: true }).forEach((file) => { if (Utils.endsWith(file, '/')) { return; } const relativePath = relative(dir, file); checksums[relativePath] = Utils.checksum(file); }); return checksums; }
javascript
function _checksums(dir) { const checksums = {}; glob.sync(resolve(dir, '**/!(*.pack.+(s[ac]ss|js))'), { mark: true }).forEach((file) => { if (Utils.endsWith(file, '/')) { return; } const relativePath = relative(dir, file); checksums[relativePath] = Utils.checksum(file); }); return checksums; }
[ "function", "_checksums", "(", "dir", ")", "{", "const", "checksums", "=", "{", "}", ";", "glob", ".", "sync", "(", "resolve", "(", "dir", ",", "'**/!(*.pack.+(s[ac]ss|js))'", ")", ",", "{", "mark", ":", "true", "}", ")", ".", "forEach", "(", "(", "file", ")", "=>", "{", "if", "(", "Utils", ".", "endsWith", "(", "file", ",", "'/'", ")", ")", "{", "return", ";", "}", "const", "relativePath", "=", "relative", "(", "dir", ",", "file", ")", ";", "checksums", "[", "relativePath", "]", "=", "Utils", ".", "checksum", "(", "file", ")", ";", "}", ")", ";", "return", "checksums", ";", "}" ]
Generates a legend of file paths to checksums @param {string} dir @return {Object}
[ "Generates", "a", "legend", "of", "file", "paths", "to", "checksums" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L171-L182
12,463
vapid/vapid
lib/deployer.js
_getPresignedPosts
async function _getPresignedPosts(siteId, checksums) { const endpoint = url.resolve(apiURL, `/sites/${siteId}/presigned_posts`); const body = { checksums }; const response = await got.post(endpoint, { body, json: true, headers: _bearer() }); return response.body.presignedPosts; }
javascript
async function _getPresignedPosts(siteId, checksums) { const endpoint = url.resolve(apiURL, `/sites/${siteId}/presigned_posts`); const body = { checksums }; const response = await got.post(endpoint, { body, json: true, headers: _bearer() }); return response.body.presignedPosts; }
[ "async", "function", "_getPresignedPosts", "(", "siteId", ",", "checksums", ")", "{", "const", "endpoint", "=", "url", ".", "resolve", "(", "apiURL", ",", "`", "${", "siteId", "}", "`", ")", ";", "const", "body", "=", "{", "checksums", "}", ";", "const", "response", "=", "await", "got", ".", "post", "(", "endpoint", ",", "{", "body", ",", "json", ":", "true", ",", "headers", ":", "_bearer", "(", ")", "}", ")", ";", "return", "response", ".", "body", ".", "presignedPosts", ";", "}" ]
Gets presigned posts @param {string} siteId @param {Object} checksums @return {Object}
[ "Gets", "presigned", "posts" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L191-L197
12,464
vapid/vapid
lib/deployer.js
_uploadFiles
async function _uploadFiles(dir, presignedPosts) { const promises = []; const limit = pLimit(5); let uploaded = false; Object.keys(presignedPosts).forEach(async (path) => { const { post } = presignedPosts[path]; if (!post) { Logger.tagged('exists', path, 'blue'); } else { const filePath = resolve(dir, path); const form = new FormData(); Utils.forEach(post.fields, (value, key) => { form.append(key, value); }); form.append('file', fs.createReadStream(filePath)); const promise = limit(() => got.post(post.url, { body: form }).then(() => { Logger.tagged('upload', path); })); promises.push(promise); uploaded = true; } }); await Promise.all(promises); return uploaded; }
javascript
async function _uploadFiles(dir, presignedPosts) { const promises = []; const limit = pLimit(5); let uploaded = false; Object.keys(presignedPosts).forEach(async (path) => { const { post } = presignedPosts[path]; if (!post) { Logger.tagged('exists', path, 'blue'); } else { const filePath = resolve(dir, path); const form = new FormData(); Utils.forEach(post.fields, (value, key) => { form.append(key, value); }); form.append('file', fs.createReadStream(filePath)); const promise = limit(() => got.post(post.url, { body: form }).then(() => { Logger.tagged('upload', path); })); promises.push(promise); uploaded = true; } }); await Promise.all(promises); return uploaded; }
[ "async", "function", "_uploadFiles", "(", "dir", ",", "presignedPosts", ")", "{", "const", "promises", "=", "[", "]", ";", "const", "limit", "=", "pLimit", "(", "5", ")", ";", "let", "uploaded", "=", "false", ";", "Object", ".", "keys", "(", "presignedPosts", ")", ".", "forEach", "(", "async", "(", "path", ")", "=>", "{", "const", "{", "post", "}", "=", "presignedPosts", "[", "path", "]", ";", "if", "(", "!", "post", ")", "{", "Logger", ".", "tagged", "(", "'exists'", ",", "path", ",", "'blue'", ")", ";", "}", "else", "{", "const", "filePath", "=", "resolve", "(", "dir", ",", "path", ")", ";", "const", "form", "=", "new", "FormData", "(", ")", ";", "Utils", ".", "forEach", "(", "post", ".", "fields", ",", "(", "value", ",", "key", ")", "=>", "{", "form", ".", "append", "(", "key", ",", "value", ")", ";", "}", ")", ";", "form", ".", "append", "(", "'file'", ",", "fs", ".", "createReadStream", "(", "filePath", ")", ")", ";", "const", "promise", "=", "limit", "(", "(", ")", "=>", "got", ".", "post", "(", "post", ".", "url", ",", "{", "body", ":", "form", "}", ")", ".", "then", "(", "(", ")", "=>", "{", "Logger", ".", "tagged", "(", "'upload'", ",", "path", ")", ";", "}", ")", ")", ";", "promises", ".", "push", "(", "promise", ")", ";", "uploaded", "=", "true", ";", "}", "}", ")", ";", "await", "Promise", ".", "all", "(", "promises", ")", ";", "return", "uploaded", ";", "}" ]
Upload files to S3 @param {Object} paths @param {Object} presignedPosts
[ "Upload", "files", "to", "S3" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L205-L233
12,465
vapid/vapid
lib/deployer.js
_updateSite
async function _updateSite(siteId, tree, manifest, content) { const endpoint = url.resolve(apiURL, `/sites/${siteId}`); const body = { tree, content, manifest }; const response = await got.post(endpoint, { body, json: true, headers: _bearer() }); return response.body.site; }
javascript
async function _updateSite(siteId, tree, manifest, content) { const endpoint = url.resolve(apiURL, `/sites/${siteId}`); const body = { tree, content, manifest }; const response = await got.post(endpoint, { body, json: true, headers: _bearer() }); return response.body.site; }
[ "async", "function", "_updateSite", "(", "siteId", ",", "tree", ",", "manifest", ",", "content", ")", "{", "const", "endpoint", "=", "url", ".", "resolve", "(", "apiURL", ",", "`", "${", "siteId", "}", "`", ")", ";", "const", "body", "=", "{", "tree", ",", "content", ",", "manifest", "}", ";", "const", "response", "=", "await", "got", ".", "post", "(", "endpoint", ",", "{", "body", ",", "json", ":", "true", ",", "headers", ":", "_bearer", "(", ")", "}", ")", ";", "return", "response", ".", "body", ".", "site", ";", "}" ]
Update the site @param {string} siteId @param {Object} manifest
[ "Update", "the", "site" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L241-L246
12,466
vapid/vapid
lib/deployer.js
_compileAssets
async function _compileAssets(wwwDir, tmpDir) { const nodeDir = resolve(wwwDir, '../node_modules'); const moduleDirs = (function _moduleDirs() { const dirs = [wwwDir]; if (fs.existsSync(nodeDir)) dirs.push(nodeDir); return dirs; }()); const config = webPackConfig('production', tmpDir, moduleDirs, tmpDir); if (Utils.isEmpty(config.entry)) return; const compiler = Webpack(config); await new Promise((_resolve, _reject) => { compiler.run((err, stats) => { if (stats.hasErrors()) { _reject(new Error('Failed to compile assets')); } _resolve(); }); }); }
javascript
async function _compileAssets(wwwDir, tmpDir) { const nodeDir = resolve(wwwDir, '../node_modules'); const moduleDirs = (function _moduleDirs() { const dirs = [wwwDir]; if (fs.existsSync(nodeDir)) dirs.push(nodeDir); return dirs; }()); const config = webPackConfig('production', tmpDir, moduleDirs, tmpDir); if (Utils.isEmpty(config.entry)) return; const compiler = Webpack(config); await new Promise((_resolve, _reject) => { compiler.run((err, stats) => { if (stats.hasErrors()) { _reject(new Error('Failed to compile assets')); } _resolve(); }); }); }
[ "async", "function", "_compileAssets", "(", "wwwDir", ",", "tmpDir", ")", "{", "const", "nodeDir", "=", "resolve", "(", "wwwDir", ",", "'../node_modules'", ")", ";", "const", "moduleDirs", "=", "(", "function", "_moduleDirs", "(", ")", "{", "const", "dirs", "=", "[", "wwwDir", "]", ";", "if", "(", "fs", ".", "existsSync", "(", "nodeDir", ")", ")", "dirs", ".", "push", "(", "nodeDir", ")", ";", "return", "dirs", ";", "}", "(", ")", ")", ";", "const", "config", "=", "webPackConfig", "(", "'production'", ",", "tmpDir", ",", "moduleDirs", ",", "tmpDir", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "config", ".", "entry", ")", ")", "return", ";", "const", "compiler", "=", "Webpack", "(", "config", ")", ";", "await", "new", "Promise", "(", "(", "_resolve", ",", "_reject", ")", "=>", "{", "compiler", ".", "run", "(", "(", "err", ",", "stats", ")", "=>", "{", "if", "(", "stats", ".", "hasErrors", "(", ")", ")", "{", "_reject", "(", "new", "Error", "(", "'Failed to compile assets'", ")", ")", ";", "}", "_resolve", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Compiles Webpack assets
[ "Compiles", "Webpack", "assets" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/deployer.js#L268-L289
12,467
vapid/vapid
assets/dashboard/vendor/html5sortable.js
addData
function addData(element, key, value) { if (value === undefined) { return element && element.h5s && element.h5s.data && element.h5s.data[key]; } else { element.h5s = element.h5s || {}; element.h5s.data = element.h5s.data || {}; element.h5s.data[key] = value; } }
javascript
function addData(element, key, value) { if (value === undefined) { return element && element.h5s && element.h5s.data && element.h5s.data[key]; } else { element.h5s = element.h5s || {}; element.h5s.data = element.h5s.data || {}; element.h5s.data[key] = value; } }
[ "function", "addData", "(", "element", ",", "key", ",", "value", ")", "{", "if", "(", "value", "===", "undefined", ")", "{", "return", "element", "&&", "element", ".", "h5s", "&&", "element", ".", "h5s", ".", "data", "&&", "element", ".", "h5s", ".", "data", "[", "key", "]", ";", "}", "else", "{", "element", ".", "h5s", "=", "element", ".", "h5s", "||", "{", "}", ";", "element", ".", "h5s", ".", "data", "=", "element", ".", "h5s", ".", "data", "||", "{", "}", ";", "element", ".", "h5s", ".", "data", "[", "key", "]", "=", "value", ";", "}", "}" ]
Get or set data on element @param {HTMLElement} element @param {string} key @param {any} value @return {*}
[ "Get", "or", "set", "data", "on", "element" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L18-L27
12,468
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (config) { if (typeof config !== 'object') { throw new Error('You must provide a valid configuration object to the config setter.'); } // combine config with default var mergedConfig = Object.assign({}, config); // add config to map this._config = new Map(Object.entries(mergedConfig)); }
javascript
function (config) { if (typeof config !== 'object') { throw new Error('You must provide a valid configuration object to the config setter.'); } // combine config with default var mergedConfig = Object.assign({}, config); // add config to map this._config = new Map(Object.entries(mergedConfig)); }
[ "function", "(", "config", ")", "{", "if", "(", "typeof", "config", "!==", "'object'", ")", "{", "throw", "new", "Error", "(", "'You must provide a valid configuration object to the config setter.'", ")", ";", "}", "// combine config with default", "var", "mergedConfig", "=", "Object", ".", "assign", "(", "{", "}", ",", "config", ")", ";", "// add config to map", "this", ".", "_config", "=", "new", "Map", "(", "Object", ".", "entries", "(", "mergedConfig", ")", ")", ";", "}" ]
set the configuration of a class instance @method config @param {object} config object of configurations
[ "set", "the", "configuration", "of", "a", "class", "instance" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L80-L88
12,469
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (draggedElement, elementOffset, event) { return { element: draggedElement, posX: event.pageX - elementOffset.left, posY: event.pageY - elementOffset.top }; }
javascript
function (draggedElement, elementOffset, event) { return { element: draggedElement, posX: event.pageX - elementOffset.left, posY: event.pageY - elementOffset.top }; }
[ "function", "(", "draggedElement", ",", "elementOffset", ",", "event", ")", "{", "return", "{", "element", ":", "draggedElement", ",", "posX", ":", "event", ".", "pageX", "-", "elementOffset", ".", "left", ",", "posY", ":", "event", ".", "pageY", "-", "elementOffset", ".", "top", "}", ";", "}" ]
defaultDragImage returns the current item as dragged image @param {HTMLElement} draggedElement - the item that the user drags @param {object} elementOffset - an object with the offsets top, left, right & bottom @param {Event} event - the original drag event object @return {object} with element, posX and posY properties
[ "defaultDragImage", "returns", "the", "current", "item", "as", "dragged", "image" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L424-L430
12,470
vapid/vapid
assets/dashboard/vendor/html5sortable.js
_throttle
function _throttle (fn, threshold) { var _this = this; if (threshold === void 0) { threshold = 250; } // check function if (typeof fn !== 'function') { throw new Error('You must provide a function as the first argument for throttle.'); } // check threshold if (typeof threshold !== 'number') { throw new Error('You must provide a number as the second argument for throttle.'); } var lastEventTimestamp = null; return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } var now = Date.now(); if (lastEventTimestamp === null || now - lastEventTimestamp >= threshold) { lastEventTimestamp = now; fn.apply(_this, args); } }; }
javascript
function _throttle (fn, threshold) { var _this = this; if (threshold === void 0) { threshold = 250; } // check function if (typeof fn !== 'function') { throw new Error('You must provide a function as the first argument for throttle.'); } // check threshold if (typeof threshold !== 'number') { throw new Error('You must provide a number as the second argument for throttle.'); } var lastEventTimestamp = null; return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } var now = Date.now(); if (lastEventTimestamp === null || now - lastEventTimestamp >= threshold) { lastEventTimestamp = now; fn.apply(_this, args); } }; }
[ "function", "_throttle", "(", "fn", ",", "threshold", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "threshold", "===", "void", "0", ")", "{", "threshold", "=", "250", ";", "}", "// check function", "if", "(", "typeof", "fn", "!==", "'function'", ")", "{", "throw", "new", "Error", "(", "'You must provide a function as the first argument for throttle.'", ")", ";", "}", "// check threshold", "if", "(", "typeof", "threshold", "!==", "'number'", ")", "{", "throw", "new", "Error", "(", "'You must provide a number as the second argument for throttle.'", ")", ";", "}", "var", "lastEventTimestamp", "=", "null", ";", "return", "function", "(", ")", "{", "var", "args", "=", "[", "]", ";", "for", "(", "var", "_i", "=", "0", ";", "_i", "<", "arguments", ".", "length", ";", "_i", "++", ")", "{", "args", "[", "_i", "-", "0", "]", "=", "arguments", "[", "_i", "]", ";", "}", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "if", "(", "lastEventTimestamp", "===", "null", "||", "now", "-", "lastEventTimestamp", ">=", "threshold", ")", "{", "lastEventTimestamp", "=", "now", ";", "fn", ".", "apply", "(", "_this", ",", "args", ")", ";", "}", "}", ";", "}" ]
make sure a function is only called once within the given amount of time @param {Function} fn the function to throttle @param {number} threshold time limit for throttling must use function to keep this context
[ "make", "sure", "a", "function", "is", "only", "called", "once", "within", "the", "given", "amount", "of", "time" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L514-L537
12,471
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (items) { removeEventListener(items, 'dragstart'); removeEventListener(items, 'dragend'); removeEventListener(items, 'dragover'); removeEventListener(items, 'dragenter'); removeEventListener(items, 'drop'); removeEventListener(items, 'mouseenter'); removeEventListener(items, 'mouseleave'); }
javascript
function (items) { removeEventListener(items, 'dragstart'); removeEventListener(items, 'dragend'); removeEventListener(items, 'dragover'); removeEventListener(items, 'dragenter'); removeEventListener(items, 'drop'); removeEventListener(items, 'mouseenter'); removeEventListener(items, 'mouseleave'); }
[ "function", "(", "items", ")", "{", "removeEventListener", "(", "items", ",", "'dragstart'", ")", ";", "removeEventListener", "(", "items", ",", "'dragend'", ")", ";", "removeEventListener", "(", "items", ",", "'dragover'", ")", ";", "removeEventListener", "(", "items", ",", "'dragenter'", ")", ";", "removeEventListener", "(", "items", ",", "'drop'", ")", ";", "removeEventListener", "(", "items", ",", "'mouseenter'", ")", ";", "removeEventListener", "(", "items", ",", "'mouseleave'", ")", ";", "}" ]
remove event handlers from items @param {Array|NodeList} items
[ "remove", "event", "handlers", "from", "items" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L594-L602
12,472
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (draggedItem, sortable) { var ditem = draggedItem; if (store(sortable).getConfig('copy') === true) { ditem = draggedItem.cloneNode(true); addAttribute(ditem, 'aria-copied', 'true'); draggedItem.parentElement.appendChild(ditem); ditem.style.display = 'none'; ditem.oldDisplay = draggedItem.style.display; } return ditem; }
javascript
function (draggedItem, sortable) { var ditem = draggedItem; if (store(sortable).getConfig('copy') === true) { ditem = draggedItem.cloneNode(true); addAttribute(ditem, 'aria-copied', 'true'); draggedItem.parentElement.appendChild(ditem); ditem.style.display = 'none'; ditem.oldDisplay = draggedItem.style.display; } return ditem; }
[ "function", "(", "draggedItem", ",", "sortable", ")", "{", "var", "ditem", "=", "draggedItem", ";", "if", "(", "store", "(", "sortable", ")", ".", "getConfig", "(", "'copy'", ")", "===", "true", ")", "{", "ditem", "=", "draggedItem", ".", "cloneNode", "(", "true", ")", ";", "addAttribute", "(", "ditem", ",", "'aria-copied'", ",", "'true'", ")", ";", "draggedItem", ".", "parentElement", ".", "appendChild", "(", "ditem", ")", ";", "ditem", ".", "style", ".", "display", "=", "'none'", ";", "ditem", ".", "oldDisplay", "=", "draggedItem", ".", "style", ".", "display", ";", "}", "return", "ditem", ";", "}" ]
_getDragging returns the current element to drag or a copy of the element. Is Copy Active for sortable @param {HTMLElement} draggedItem - the item that the user drags @param {HTMLElement} sortable a single sortable
[ "_getDragging", "returns", "the", "current", "element", "to", "drag", "or", "a", "copy", "of", "the", "element", ".", "Is", "Copy", "Active", "for", "sortable" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L610-L620
12,473
vapid/vapid
assets/dashboard/vendor/html5sortable.js
findDragElement
function findDragElement(sortableElement, element) { var options = addData(sortableElement, 'opts'); var items = _filter(sortableElement.children, options.items); var itemlist = items.filter(function (ele) { return ele.contains(element); }); return itemlist.length > 0 ? itemlist[0] : element; }
javascript
function findDragElement(sortableElement, element) { var options = addData(sortableElement, 'opts'); var items = _filter(sortableElement.children, options.items); var itemlist = items.filter(function (ele) { return ele.contains(element); }); return itemlist.length > 0 ? itemlist[0] : element; }
[ "function", "findDragElement", "(", "sortableElement", ",", "element", ")", "{", "var", "options", "=", "addData", "(", "sortableElement", ",", "'opts'", ")", ";", "var", "items", "=", "_filter", "(", "sortableElement", ".", "children", ",", "options", ".", "items", ")", ";", "var", "itemlist", "=", "items", ".", "filter", "(", "function", "(", "ele", ")", "{", "return", "ele", ".", "contains", "(", "element", ")", ";", "}", ")", ";", "return", "itemlist", ".", "length", ">", "0", "?", "itemlist", "[", "0", "]", ":", "element", ";", "}" ]
Dragging event is on the sortable element. finds the top child that contains the element. @param {HTMLElement} sortableElement a single sortable @param {HTMLElement} element is that being dragged
[ "Dragging", "event", "is", "on", "the", "sortable", "element", ".", "finds", "the", "top", "child", "that", "contains", "the", "element", "." ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L655-L662
12,474
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (sortableElement) { var opts = addData(sortableElement, 'opts') || {}; var items = _filter(sortableElement.children, opts.items); var handles = _getHandles(items, opts.handle); // remove event handlers & data from sortable removeEventListener(sortableElement, 'dragover'); removeEventListener(sortableElement, 'dragenter'); removeEventListener(sortableElement, 'drop'); // remove event data from sortable _removeSortableData(sortableElement); // remove event handlers & data from items removeEventListener(handles, 'mousedown'); _removeItemEvents(items); _removeItemData(items); }
javascript
function (sortableElement) { var opts = addData(sortableElement, 'opts') || {}; var items = _filter(sortableElement.children, opts.items); var handles = _getHandles(items, opts.handle); // remove event handlers & data from sortable removeEventListener(sortableElement, 'dragover'); removeEventListener(sortableElement, 'dragenter'); removeEventListener(sortableElement, 'drop'); // remove event data from sortable _removeSortableData(sortableElement); // remove event handlers & data from items removeEventListener(handles, 'mousedown'); _removeItemEvents(items); _removeItemData(items); }
[ "function", "(", "sortableElement", ")", "{", "var", "opts", "=", "addData", "(", "sortableElement", ",", "'opts'", ")", "||", "{", "}", ";", "var", "items", "=", "_filter", "(", "sortableElement", ".", "children", ",", "opts", ".", "items", ")", ";", "var", "handles", "=", "_getHandles", "(", "items", ",", "opts", ".", "handle", ")", ";", "// remove event handlers & data from sortable", "removeEventListener", "(", "sortableElement", ",", "'dragover'", ")", ";", "removeEventListener", "(", "sortableElement", ",", "'dragenter'", ")", ";", "removeEventListener", "(", "sortableElement", ",", "'drop'", ")", ";", "// remove event data from sortable", "_removeSortableData", "(", "sortableElement", ")", ";", "// remove event handlers & data from items", "removeEventListener", "(", "handles", ",", "'mousedown'", ")", ";", "_removeItemEvents", "(", "items", ")", ";", "_removeItemData", "(", "items", ")", ";", "}" ]
Destroy the sortable @param {HTMLElement} sortableElement a single sortable
[ "Destroy", "the", "sortable" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L667-L681
12,475
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (sortableElement) { var opts = addData(sortableElement, 'opts'); var items = _filter(sortableElement.children, opts.items); var handles = _getHandles(items, opts.handle); addAttribute(sortableElement, 'aria-dropeffect', 'move'); addData(sortableElement, '_disabled', 'false'); addAttribute(handles, 'draggable', 'true'); // @todo: remove this fix // IE FIX for ghost // can be disabled as it has the side effect that other events // (e.g. click) will be ignored if (opts.disableIEFix === false) { var spanEl = (document || window.document).createElement('span'); if (typeof spanEl.dragDrop === 'function') { addEventListener(handles, 'mousedown', function () { if (items.indexOf(this) !== -1) { this.dragDrop(); } else { var parent = this.parentElement; while (items.indexOf(parent) === -1) { parent = parent.parentElement; } parent.dragDrop(); } }); } } }
javascript
function (sortableElement) { var opts = addData(sortableElement, 'opts'); var items = _filter(sortableElement.children, opts.items); var handles = _getHandles(items, opts.handle); addAttribute(sortableElement, 'aria-dropeffect', 'move'); addData(sortableElement, '_disabled', 'false'); addAttribute(handles, 'draggable', 'true'); // @todo: remove this fix // IE FIX for ghost // can be disabled as it has the side effect that other events // (e.g. click) will be ignored if (opts.disableIEFix === false) { var spanEl = (document || window.document).createElement('span'); if (typeof spanEl.dragDrop === 'function') { addEventListener(handles, 'mousedown', function () { if (items.indexOf(this) !== -1) { this.dragDrop(); } else { var parent = this.parentElement; while (items.indexOf(parent) === -1) { parent = parent.parentElement; } parent.dragDrop(); } }); } } }
[ "function", "(", "sortableElement", ")", "{", "var", "opts", "=", "addData", "(", "sortableElement", ",", "'opts'", ")", ";", "var", "items", "=", "_filter", "(", "sortableElement", ".", "children", ",", "opts", ".", "items", ")", ";", "var", "handles", "=", "_getHandles", "(", "items", ",", "opts", ".", "handle", ")", ";", "addAttribute", "(", "sortableElement", ",", "'aria-dropeffect'", ",", "'move'", ")", ";", "addData", "(", "sortableElement", ",", "'_disabled'", ",", "'false'", ")", ";", "addAttribute", "(", "handles", ",", "'draggable'", ",", "'true'", ")", ";", "// @todo: remove this fix", "// IE FIX for ghost", "// can be disabled as it has the side effect that other events", "// (e.g. click) will be ignored", "if", "(", "opts", ".", "disableIEFix", "===", "false", ")", "{", "var", "spanEl", "=", "(", "document", "||", "window", ".", "document", ")", ".", "createElement", "(", "'span'", ")", ";", "if", "(", "typeof", "spanEl", ".", "dragDrop", "===", "'function'", ")", "{", "addEventListener", "(", "handles", ",", "'mousedown'", ",", "function", "(", ")", "{", "if", "(", "items", ".", "indexOf", "(", "this", ")", "!==", "-", "1", ")", "{", "this", ".", "dragDrop", "(", ")", ";", "}", "else", "{", "var", "parent", "=", "this", ".", "parentElement", ";", "while", "(", "items", ".", "indexOf", "(", "parent", ")", "===", "-", "1", ")", "{", "parent", "=", "parent", ".", "parentElement", ";", "}", "parent", ".", "dragDrop", "(", ")", ";", "}", "}", ")", ";", "}", "}", "}" ]
Enable the sortable @param {HTMLElement} sortableElement a single sortable
[ "Enable", "the", "sortable" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L686-L714
12,476
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (sortableElement) { var opts = addData(sortableElement, 'opts'); var items = _filter(sortableElement.children, opts.items); var handles = _getHandles(items, opts.handle); addAttribute(sortableElement, 'aria-dropeffect', 'none'); addData(sortableElement, '_disabled', 'true'); addAttribute(handles, 'draggable', 'false'); removeEventListener(handles, 'mousedown'); }
javascript
function (sortableElement) { var opts = addData(sortableElement, 'opts'); var items = _filter(sortableElement.children, opts.items); var handles = _getHandles(items, opts.handle); addAttribute(sortableElement, 'aria-dropeffect', 'none'); addData(sortableElement, '_disabled', 'true'); addAttribute(handles, 'draggable', 'false'); removeEventListener(handles, 'mousedown'); }
[ "function", "(", "sortableElement", ")", "{", "var", "opts", "=", "addData", "(", "sortableElement", ",", "'opts'", ")", ";", "var", "items", "=", "_filter", "(", "sortableElement", ".", "children", ",", "opts", ".", "items", ")", ";", "var", "handles", "=", "_getHandles", "(", "items", ",", "opts", ".", "handle", ")", ";", "addAttribute", "(", "sortableElement", ",", "'aria-dropeffect'", ",", "'none'", ")", ";", "addData", "(", "sortableElement", ",", "'_disabled'", ",", "'true'", ")", ";", "addAttribute", "(", "handles", ",", "'draggable'", ",", "'false'", ")", ";", "removeEventListener", "(", "handles", ",", "'mousedown'", ")", ";", "}" ]
Disable the sortable @param {HTMLElement} sortableElement a single sortable
[ "Disable", "the", "sortable" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L719-L727
12,477
vapid/vapid
assets/dashboard/vendor/html5sortable.js
function (e) { var element = e.target; var sortableElement = element.isSortable === true ? element : findSortable(element); element = findDragElement(sortableElement, element); if (!dragging || !_listsConnected(sortableElement, dragging.parentElement) || addData(sortableElement, '_disabled') === 'true') { return; } var options = addData(sortableElement, 'opts'); if (parseInt(options.maxItems) && _filter(sortableElement.children, addData(sortableElement, 'items')).length >= parseInt(options.maxItems) && dragging.parentElement !== sortableElement) { return; } e.preventDefault(); e.stopPropagation(); e.dataTransfer.dropEffect = store(sortableElement).getConfig('copy') === true ? 'copy' : 'move'; debouncedDragOverEnter(sortableElement, element, e.pageY); }
javascript
function (e) { var element = e.target; var sortableElement = element.isSortable === true ? element : findSortable(element); element = findDragElement(sortableElement, element); if (!dragging || !_listsConnected(sortableElement, dragging.parentElement) || addData(sortableElement, '_disabled') === 'true') { return; } var options = addData(sortableElement, 'opts'); if (parseInt(options.maxItems) && _filter(sortableElement.children, addData(sortableElement, 'items')).length >= parseInt(options.maxItems) && dragging.parentElement !== sortableElement) { return; } e.preventDefault(); e.stopPropagation(); e.dataTransfer.dropEffect = store(sortableElement).getConfig('copy') === true ? 'copy' : 'move'; debouncedDragOverEnter(sortableElement, element, e.pageY); }
[ "function", "(", "e", ")", "{", "var", "element", "=", "e", ".", "target", ";", "var", "sortableElement", "=", "element", ".", "isSortable", "===", "true", "?", "element", ":", "findSortable", "(", "element", ")", ";", "element", "=", "findDragElement", "(", "sortableElement", ",", "element", ")", ";", "if", "(", "!", "dragging", "||", "!", "_listsConnected", "(", "sortableElement", ",", "dragging", ".", "parentElement", ")", "||", "addData", "(", "sortableElement", ",", "'_disabled'", ")", "===", "'true'", ")", "{", "return", ";", "}", "var", "options", "=", "addData", "(", "sortableElement", ",", "'opts'", ")", ";", "if", "(", "parseInt", "(", "options", ".", "maxItems", ")", "&&", "_filter", "(", "sortableElement", ".", "children", ",", "addData", "(", "sortableElement", ",", "'items'", ")", ")", ".", "length", ">=", "parseInt", "(", "options", ".", "maxItems", ")", "&&", "dragging", ".", "parentElement", "!==", "sortableElement", ")", "{", "return", ";", "}", "e", ".", "preventDefault", "(", ")", ";", "e", ".", "stopPropagation", "(", ")", ";", "e", ".", "dataTransfer", ".", "dropEffect", "=", "store", "(", "sortableElement", ")", ".", "getConfig", "(", "'copy'", ")", "===", "true", "?", "'copy'", ":", "'move'", ";", "debouncedDragOverEnter", "(", "sortableElement", ",", "element", ",", "e", ".", "pageY", ")", ";", "}" ]
Handle dragover and dragenter events on draggable items
[ "Handle", "dragover", "and", "dragenter", "events", "on", "draggable", "items" ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/assets/dashboard/vendor/html5sortable.js#L1060-L1075
12,478
vapid/vapid
lib/directives/index.js
find
function find(params = {}) { const name = params.type; if (Utils.has(availableDirectives, name)) { return new availableDirectives[name](params); } // Only show warning if someone explicity enters a bad name if (name) { Logger.warn(`Directive type '${name}' does not exist. Falling back to 'text'`); } /* eslint-disable-next-line new-cap */ return new availableDirectives.text(params); }
javascript
function find(params = {}) { const name = params.type; if (Utils.has(availableDirectives, name)) { return new availableDirectives[name](params); } // Only show warning if someone explicity enters a bad name if (name) { Logger.warn(`Directive type '${name}' does not exist. Falling back to 'text'`); } /* eslint-disable-next-line new-cap */ return new availableDirectives.text(params); }
[ "function", "find", "(", "params", "=", "{", "}", ")", "{", "const", "name", "=", "params", ".", "type", ";", "if", "(", "Utils", ".", "has", "(", "availableDirectives", ",", "name", ")", ")", "{", "return", "new", "availableDirectives", "[", "name", "]", "(", "params", ")", ";", "}", "// Only show warning if someone explicity enters a bad name", "if", "(", "name", ")", "{", "Logger", ".", "warn", "(", "`", "${", "name", "}", "`", ")", ";", "}", "/* eslint-disable-next-line new-cap */", "return", "new", "availableDirectives", ".", "text", "(", "params", ")", ";", "}" ]
Lookup function for available directives Falls back to "text" directive if one can't be found. @params {Object} params - options and attributes @return {Directive} - an directive instance
[ "Lookup", "function", "for", "available", "directives", "Falls", "back", "to", "text", "directive", "if", "one", "can", "t", "be", "found", "." ]
a851360c08a8b8577b2f3126596546e20092055c
https://github.com/vapid/vapid/blob/a851360c08a8b8577b2f3126596546e20092055c/lib/directives/index.js#L27-L38
12,479
BasqueVoIPMafia/cordova-plugin-iosrtc
extra/hooks/iosrtc-swift-support.js
getProjectName
function getProjectName(protoPath) { var cordovaConfigPath = path.join(protoPath, 'config.xml'), content = fs.readFileSync(cordovaConfigPath, 'utf-8'); return /<name>([\s\S]*)<\/name>/mi.exec(content)[1].trim(); }
javascript
function getProjectName(protoPath) { var cordovaConfigPath = path.join(protoPath, 'config.xml'), content = fs.readFileSync(cordovaConfigPath, 'utf-8'); return /<name>([\s\S]*)<\/name>/mi.exec(content)[1].trim(); }
[ "function", "getProjectName", "(", "protoPath", ")", "{", "var", "cordovaConfigPath", "=", "path", ".", "join", "(", "protoPath", ",", "'config.xml'", ")", ",", "content", "=", "fs", ".", "readFileSync", "(", "cordovaConfigPath", ",", "'utf-8'", ")", ";", "return", "/", "<name>([\\s\\S]*)<\\/name>", "/", "mi", ".", "exec", "(", "content", ")", "[", "1", "]", ".", "trim", "(", ")", ";", "}" ]
Helpers Returns the project name
[ "Helpers", "Returns", "the", "project", "name" ]
8f0637b84790780a39fe5bf07f939bebfaf56e1a
https://github.com/BasqueVoIPMafia/cordova-plugin-iosrtc/blob/8f0637b84790780a39fe5bf07f939bebfaf56e1a/extra/hooks/iosrtc-swift-support.js#L28-L34
12,480
mkoryak/floatThead
dist/jquery.floatThead.js
getOffsetWidth
function getOffsetWidth(el) { var rect = el.getBoundingClientRect(); return rect.width || rect.right - rect.left; }
javascript
function getOffsetWidth(el) { var rect = el.getBoundingClientRect(); return rect.width || rect.right - rect.left; }
[ "function", "getOffsetWidth", "(", "el", ")", "{", "var", "rect", "=", "el", ".", "getBoundingClientRect", "(", ")", ";", "return", "rect", ".", "width", "||", "rect", ".", "right", "-", "rect", ".", "left", ";", "}" ]
returns fractional pixel widths
[ "returns", "fractional", "pixel", "widths" ]
ab47d739d005f24ff0308a7a20fa566a7a343a11
https://github.com/mkoryak/floatThead/blob/ab47d739d005f24ff0308a7a20fa566a7a343a11/dist/jquery.floatThead.js#L197-L200
12,481
mkoryak/floatThead
dist/jquery.floatThead.js
columnNum
function columnNum(){ var count; var $headerColumns = $header.find(opts.headerCellSelector); if(existingColGroup){ count = $tableColGroup.find('col').length; } else { count = 0; $headerColumns.each(function () { count += parseInt(($(this).attr('colspan') || 1), 10); }); } if(count !== lastColumnCount){ lastColumnCount = count; var cells = [], cols = [], psuedo = [], content; for(var x = 0; x < count; x++){ content = $headerColumns.eq(x).text(); cells.push('<th class="floatThead-col" aria-label="'+content+'"/>'); cols.push('<col/>'); psuedo.push( $('<fthtd>').css({ 'display': 'table-cell', 'height': 0, 'width': 'auto' }) ); } cols = cols.join(''); cells = cells.join(''); if(createElements){ $fthRow.empty(); $fthRow.append(psuedo); $fthCells = $fthRow.find('fthtd'); } $sizerRow.html(cells); $sizerCells = $sizerRow.find("th"); if(!existingColGroup){ $tableColGroup.html(cols); } $tableCells = $tableColGroup.find('col'); $floatColGroup.html(cols); $headerCells = $floatColGroup.find("col"); } return count; }
javascript
function columnNum(){ var count; var $headerColumns = $header.find(opts.headerCellSelector); if(existingColGroup){ count = $tableColGroup.find('col').length; } else { count = 0; $headerColumns.each(function () { count += parseInt(($(this).attr('colspan') || 1), 10); }); } if(count !== lastColumnCount){ lastColumnCount = count; var cells = [], cols = [], psuedo = [], content; for(var x = 0; x < count; x++){ content = $headerColumns.eq(x).text(); cells.push('<th class="floatThead-col" aria-label="'+content+'"/>'); cols.push('<col/>'); psuedo.push( $('<fthtd>').css({ 'display': 'table-cell', 'height': 0, 'width': 'auto' }) ); } cols = cols.join(''); cells = cells.join(''); if(createElements){ $fthRow.empty(); $fthRow.append(psuedo); $fthCells = $fthRow.find('fthtd'); } $sizerRow.html(cells); $sizerCells = $sizerRow.find("th"); if(!existingColGroup){ $tableColGroup.html(cols); } $tableCells = $tableColGroup.find('col'); $floatColGroup.html(cols); $headerCells = $floatColGroup.find("col"); } return count; }
[ "function", "columnNum", "(", ")", "{", "var", "count", ";", "var", "$headerColumns", "=", "$header", ".", "find", "(", "opts", ".", "headerCellSelector", ")", ";", "if", "(", "existingColGroup", ")", "{", "count", "=", "$tableColGroup", ".", "find", "(", "'col'", ")", ".", "length", ";", "}", "else", "{", "count", "=", "0", ";", "$headerColumns", ".", "each", "(", "function", "(", ")", "{", "count", "+=", "parseInt", "(", "(", "$", "(", "this", ")", ".", "attr", "(", "'colspan'", ")", "||", "1", ")", ",", "10", ")", ";", "}", ")", ";", "}", "if", "(", "count", "!==", "lastColumnCount", ")", "{", "lastColumnCount", "=", "count", ";", "var", "cells", "=", "[", "]", ",", "cols", "=", "[", "]", ",", "psuedo", "=", "[", "]", ",", "content", ";", "for", "(", "var", "x", "=", "0", ";", "x", "<", "count", ";", "x", "++", ")", "{", "content", "=", "$headerColumns", ".", "eq", "(", "x", ")", ".", "text", "(", ")", ";", "cells", ".", "push", "(", "'<th class=\"floatThead-col\" aria-label=\"'", "+", "content", "+", "'\"/>'", ")", ";", "cols", ".", "push", "(", "'<col/>'", ")", ";", "psuedo", ".", "push", "(", "$", "(", "'<fthtd>'", ")", ".", "css", "(", "{", "'display'", ":", "'table-cell'", ",", "'height'", ":", "0", ",", "'width'", ":", "'auto'", "}", ")", ")", ";", "}", "cols", "=", "cols", ".", "join", "(", "''", ")", ";", "cells", "=", "cells", ".", "join", "(", "''", ")", ";", "if", "(", "createElements", ")", "{", "$fthRow", ".", "empty", "(", ")", ";", "$fthRow", ".", "append", "(", "psuedo", ")", ";", "$fthCells", "=", "$fthRow", ".", "find", "(", "'fthtd'", ")", ";", "}", "$sizerRow", ".", "html", "(", "cells", ")", ";", "$sizerCells", "=", "$sizerRow", ".", "find", "(", "\"th\"", ")", ";", "if", "(", "!", "existingColGroup", ")", "{", "$tableColGroup", ".", "html", "(", "cols", ")", ";", "}", "$tableCells", "=", "$tableColGroup", ".", "find", "(", "'col'", ")", ";", "$floatColGroup", ".", "html", "(", "cols", ")", ";", "$headerCells", "=", "$floatColGroup", ".", "find", "(", "\"col\"", ")", ";", "}", "return", "count", ";", "}" ]
get the number of columns and also rebuild resizer rows if the count is different than the last count
[ "get", "the", "number", "of", "columns", "and", "also", "rebuild", "resizer", "rows", "if", "the", "count", "is", "different", "than", "the", "last", "count" ]
ab47d739d005f24ff0308a7a20fa566a7a343a11
https://github.com/mkoryak/floatThead/blob/ab47d739d005f24ff0308a7a20fa566a7a343a11/dist/jquery.floatThead.js#L523-L570
12,482
mkoryak/floatThead
dist/jquery.floatThead.js
calculateScrollBarSize
function calculateScrollBarSize(){ //this should happen after the floating table has been positioned if($scrollContainer.length){ if(opts.support && opts.support.perfectScrollbar && $scrollContainer.data().perfectScrollbar){ scrollbarOffset = {horizontal:0, vertical:0}; } else { if($scrollContainer.css('overflow-x') == 'scroll'){ scrollbarOffset.horizontal = scrollbarWidth; } else { var sw = $scrollContainer.width(), tw = tableWidth($table, $fthCells); var offsetv = sh < th ? scrollbarWidth : 0; scrollbarOffset.horizontal = sw - offsetv < tw ? scrollbarWidth : 0; } if($scrollContainer.css('overflow-y') == 'scroll'){ scrollbarOffset.vertical = scrollbarWidth; } else { var sh = $scrollContainer.height(), th = $table.height(); var offseth = sw < tw ? scrollbarWidth : 0; scrollbarOffset.vertical = sh - offseth < th ? scrollbarWidth : 0; } } } }
javascript
function calculateScrollBarSize(){ //this should happen after the floating table has been positioned if($scrollContainer.length){ if(opts.support && opts.support.perfectScrollbar && $scrollContainer.data().perfectScrollbar){ scrollbarOffset = {horizontal:0, vertical:0}; } else { if($scrollContainer.css('overflow-x') == 'scroll'){ scrollbarOffset.horizontal = scrollbarWidth; } else { var sw = $scrollContainer.width(), tw = tableWidth($table, $fthCells); var offsetv = sh < th ? scrollbarWidth : 0; scrollbarOffset.horizontal = sw - offsetv < tw ? scrollbarWidth : 0; } if($scrollContainer.css('overflow-y') == 'scroll'){ scrollbarOffset.vertical = scrollbarWidth; } else { var sh = $scrollContainer.height(), th = $table.height(); var offseth = sw < tw ? scrollbarWidth : 0; scrollbarOffset.vertical = sh - offseth < th ? scrollbarWidth : 0; } } } }
[ "function", "calculateScrollBarSize", "(", ")", "{", "//this should happen after the floating table has been positioned", "if", "(", "$scrollContainer", ".", "length", ")", "{", "if", "(", "opts", ".", "support", "&&", "opts", ".", "support", ".", "perfectScrollbar", "&&", "$scrollContainer", ".", "data", "(", ")", ".", "perfectScrollbar", ")", "{", "scrollbarOffset", "=", "{", "horizontal", ":", "0", ",", "vertical", ":", "0", "}", ";", "}", "else", "{", "if", "(", "$scrollContainer", ".", "css", "(", "'overflow-x'", ")", "==", "'scroll'", ")", "{", "scrollbarOffset", ".", "horizontal", "=", "scrollbarWidth", ";", "}", "else", "{", "var", "sw", "=", "$scrollContainer", ".", "width", "(", ")", ",", "tw", "=", "tableWidth", "(", "$table", ",", "$fthCells", ")", ";", "var", "offsetv", "=", "sh", "<", "th", "?", "scrollbarWidth", ":", "0", ";", "scrollbarOffset", ".", "horizontal", "=", "sw", "-", "offsetv", "<", "tw", "?", "scrollbarWidth", ":", "0", ";", "}", "if", "(", "$scrollContainer", ".", "css", "(", "'overflow-y'", ")", "==", "'scroll'", ")", "{", "scrollbarOffset", ".", "vertical", "=", "scrollbarWidth", ";", "}", "else", "{", "var", "sh", "=", "$scrollContainer", ".", "height", "(", ")", ",", "th", "=", "$table", ".", "height", "(", ")", ";", "var", "offseth", "=", "sw", "<", "tw", "?", "scrollbarWidth", ":", "0", ";", "scrollbarOffset", ".", "vertical", "=", "sh", "-", "offseth", "<", "th", "?", "scrollbarWidth", ":", "0", ";", "}", "}", "}", "}" ]
checks if THIS table has scrollbars, and finds their widths
[ "checks", "if", "THIS", "table", "has", "scrollbars", "and", "finds", "their", "widths" ]
ab47d739d005f24ff0308a7a20fa566a7a343a11
https://github.com/mkoryak/floatThead/blob/ab47d739d005f24ff0308a7a20fa566a7a343a11/dist/jquery.floatThead.js#L884-L905
12,483
ExactTarget/fuelux
index.js
function (options, callback) { // build dataSource based with options var resp = { count: data.repeater.listData.length, items: [], page: options.pageIndex }; // get start and end limits for JSON var i, l; resp.pages = Math.ceil(resp.count / (options.pageSize || 50)); i = options.pageIndex * (options.pageSize || 50); l = i + (options.pageSize || 50); l = (l <= resp.count) ? l : resp.count; resp.start = i + 1; resp.end = l; // setup columns for list view resp.columns = [ { label: 'Common Name', property: 'commonName', sortable: true, width: 600 }, { label: 'Latin Name', property: 'latinName', sortable: true, width: 600 }, { label: 'Appearance', property: 'appearance', sortable: true }, { label: 'Sound', property: 'sound', sortable: true } ]; // add sample items to datasource for (i; i < l; i++) { // from data.js resp.items.push(data.repeater.listData[i]); } resp.items = sort(resp.items, options.sortProperty, options.sortDirection); // call and simulate latency setTimeout(function () { callback(resp); }, loadDelays[Math.floor(Math.random() * 4)]); }
javascript
function (options, callback) { // build dataSource based with options var resp = { count: data.repeater.listData.length, items: [], page: options.pageIndex }; // get start and end limits for JSON var i, l; resp.pages = Math.ceil(resp.count / (options.pageSize || 50)); i = options.pageIndex * (options.pageSize || 50); l = i + (options.pageSize || 50); l = (l <= resp.count) ? l : resp.count; resp.start = i + 1; resp.end = l; // setup columns for list view resp.columns = [ { label: 'Common Name', property: 'commonName', sortable: true, width: 600 }, { label: 'Latin Name', property: 'latinName', sortable: true, width: 600 }, { label: 'Appearance', property: 'appearance', sortable: true }, { label: 'Sound', property: 'sound', sortable: true } ]; // add sample items to datasource for (i; i < l; i++) { // from data.js resp.items.push(data.repeater.listData[i]); } resp.items = sort(resp.items, options.sortProperty, options.sortDirection); // call and simulate latency setTimeout(function () { callback(resp); }, loadDelays[Math.floor(Math.random() * 4)]); }
[ "function", "(", "options", ",", "callback", ")", "{", "// build dataSource based with options", "var", "resp", "=", "{", "count", ":", "data", ".", "repeater", ".", "listData", ".", "length", ",", "items", ":", "[", "]", ",", "page", ":", "options", ".", "pageIndex", "}", ";", "// get start and end limits for JSON", "var", "i", ",", "l", ";", "resp", ".", "pages", "=", "Math", ".", "ceil", "(", "resp", ".", "count", "/", "(", "options", ".", "pageSize", "||", "50", ")", ")", ";", "i", "=", "options", ".", "pageIndex", "*", "(", "options", ".", "pageSize", "||", "50", ")", ";", "l", "=", "i", "+", "(", "options", ".", "pageSize", "||", "50", ")", ";", "l", "=", "(", "l", "<=", "resp", ".", "count", ")", "?", "l", ":", "resp", ".", "count", ";", "resp", ".", "start", "=", "i", "+", "1", ";", "resp", ".", "end", "=", "l", ";", "// setup columns for list view", "resp", ".", "columns", "=", "[", "{", "label", ":", "'Common Name'", ",", "property", ":", "'commonName'", ",", "sortable", ":", "true", ",", "width", ":", "600", "}", ",", "{", "label", ":", "'Latin Name'", ",", "property", ":", "'latinName'", ",", "sortable", ":", "true", ",", "width", ":", "600", "}", ",", "{", "label", ":", "'Appearance'", ",", "property", ":", "'appearance'", ",", "sortable", ":", "true", "}", ",", "{", "label", ":", "'Sound'", ",", "property", ":", "'sound'", ",", "sortable", ":", "true", "}", "]", ";", "// add sample items to datasource", "for", "(", "i", ";", "i", "<", "l", ";", "i", "++", ")", "{", "// from data.js", "resp", ".", "items", ".", "push", "(", "data", ".", "repeater", ".", "listData", "[", "i", "]", ")", ";", "}", "resp", ".", "items", "=", "sort", "(", "resp", ".", "items", ",", "options", ".", "sortProperty", ",", "options", ".", "sortDirection", ")", ";", "// call and simulate latency", "setTimeout", "(", "function", "(", ")", "{", "callback", "(", "resp", ")", ";", "}", ",", "loadDelays", "[", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "4", ")", "]", ")", ";", "}" ]
list view setup
[ "list", "view", "setup" ]
f7596fecac00c0a3506cb150d16a229e57a23e25
https://github.com/ExactTarget/fuelux/blob/f7596fecac00c0a3506cb150d16a229e57a23e25/index.js#L552-L608
12,484
ExactTarget/fuelux
index.js
function (options, callback) { var sampleImageCategories = ['abstract', 'animals', 'business', 'cats', 'city', 'food', 'nature', 'technics', 'transport']; var numItems = 200; // build dataSource based with options var resp = { count: numItems, items: [], pages: (Math.ceil(numItems / (options.pageSize || 30))), page: options.pageIndex }; // get start and end limits for JSON var i, l; i = options.pageIndex * (options.pageSize || 30); l = i + (options.pageSize || 30); resp.start = i + 1; resp.end = l; // add sample items to datasource for (i; i < l; i++) { resp.items.push({ name: ('Thumbnail ' + (i + 1)), src: 'http://lorempixel.com/65/65/' + sampleImageCategories[Math.floor(Math.random() * 9)] + '/?_=' + i }); } // call and simulate latency setTimeout(function () { callback(resp); }, loadDelays[Math.floor(Math.random() * 4)]); }
javascript
function (options, callback) { var sampleImageCategories = ['abstract', 'animals', 'business', 'cats', 'city', 'food', 'nature', 'technics', 'transport']; var numItems = 200; // build dataSource based with options var resp = { count: numItems, items: [], pages: (Math.ceil(numItems / (options.pageSize || 30))), page: options.pageIndex }; // get start and end limits for JSON var i, l; i = options.pageIndex * (options.pageSize || 30); l = i + (options.pageSize || 30); resp.start = i + 1; resp.end = l; // add sample items to datasource for (i; i < l; i++) { resp.items.push({ name: ('Thumbnail ' + (i + 1)), src: 'http://lorempixel.com/65/65/' + sampleImageCategories[Math.floor(Math.random() * 9)] + '/?_=' + i }); } // call and simulate latency setTimeout(function () { callback(resp); }, loadDelays[Math.floor(Math.random() * 4)]); }
[ "function", "(", "options", ",", "callback", ")", "{", "var", "sampleImageCategories", "=", "[", "'abstract'", ",", "'animals'", ",", "'business'", ",", "'cats'", ",", "'city'", ",", "'food'", ",", "'nature'", ",", "'technics'", ",", "'transport'", "]", ";", "var", "numItems", "=", "200", ";", "// build dataSource based with options", "var", "resp", "=", "{", "count", ":", "numItems", ",", "items", ":", "[", "]", ",", "pages", ":", "(", "Math", ".", "ceil", "(", "numItems", "/", "(", "options", ".", "pageSize", "||", "30", ")", ")", ")", ",", "page", ":", "options", ".", "pageIndex", "}", ";", "// get start and end limits for JSON", "var", "i", ",", "l", ";", "i", "=", "options", ".", "pageIndex", "*", "(", "options", ".", "pageSize", "||", "30", ")", ";", "l", "=", "i", "+", "(", "options", ".", "pageSize", "||", "30", ")", ";", "resp", ".", "start", "=", "i", "+", "1", ";", "resp", ".", "end", "=", "l", ";", "// add sample items to datasource", "for", "(", "i", ";", "i", "<", "l", ";", "i", "++", ")", "{", "resp", ".", "items", ".", "push", "(", "{", "name", ":", "(", "'Thumbnail '", "+", "(", "i", "+", "1", ")", ")", ",", "src", ":", "'http://lorempixel.com/65/65/'", "+", "sampleImageCategories", "[", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "9", ")", "]", "+", "'/?_='", "+", "i", "}", ")", ";", "}", "// call and simulate latency", "setTimeout", "(", "function", "(", ")", "{", "callback", "(", "resp", ")", ";", "}", ",", "loadDelays", "[", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "4", ")", "]", ")", ";", "}" ]
thumbnail view setup
[ "thumbnail", "view", "setup" ]
f7596fecac00c0a3506cb150d16a229e57a23e25
https://github.com/ExactTarget/fuelux/blob/f7596fecac00c0a3506cb150d16a229e57a23e25/index.js#L612-L643
12,485
toomuchdesign/re-reselect
src/index.js
function(...args) { const cacheKey = keySelector(...args); if (isValidCacheKey(cacheKey)) { let cacheResponse = cache.get(cacheKey); if (cacheResponse === undefined) { cacheResponse = selectorCreator(...funcs); cache.set(cacheKey, cacheResponse); } return cacheResponse(...args); } console.warn( `[re-reselect] Invalid cache key "${cacheKey}" has been returned by keySelector function.` ); return undefined; }
javascript
function(...args) { const cacheKey = keySelector(...args); if (isValidCacheKey(cacheKey)) { let cacheResponse = cache.get(cacheKey); if (cacheResponse === undefined) { cacheResponse = selectorCreator(...funcs); cache.set(cacheKey, cacheResponse); } return cacheResponse(...args); } console.warn( `[re-reselect] Invalid cache key "${cacheKey}" has been returned by keySelector function.` ); return undefined; }
[ "function", "(", "...", "args", ")", "{", "const", "cacheKey", "=", "keySelector", "(", "...", "args", ")", ";", "if", "(", "isValidCacheKey", "(", "cacheKey", ")", ")", "{", "let", "cacheResponse", "=", "cache", ".", "get", "(", "cacheKey", ")", ";", "if", "(", "cacheResponse", "===", "undefined", ")", "{", "cacheResponse", "=", "selectorCreator", "(", "...", "funcs", ")", ";", "cache", ".", "set", "(", "cacheKey", ",", "cacheResponse", ")", ";", "}", "return", "cacheResponse", "(", "...", "args", ")", ";", "}", "console", ".", "warn", "(", "`", "${", "cacheKey", "}", "`", ")", ";", "return", "undefined", ";", "}" ]
Application receives this function
[ "Application", "receives", "this", "function" ]
263c998e466c8aae5aa60cb617efa4fd1d71f008
https://github.com/toomuchdesign/re-reselect/blob/263c998e466c8aae5aa60cb617efa4fd1d71f008/src/index.js#L32-L49
12,486
mozilla/protocol
gulpfile.js/tasks/compress-js.js
compressJS
function compressJS() { let tasks = []; Object.keys(config.tasks).forEach((key) => { let val = config.tasks[key]; tasks.push(gulp.src(val.src) .pipe(plumber({ errorHandler: handleErrors })) .pipe(uglify()) .pipe(rename(config.rename)) .pipe(gulp.dest(val.dest))); }); return merge(tasks); }
javascript
function compressJS() { let tasks = []; Object.keys(config.tasks).forEach((key) => { let val = config.tasks[key]; tasks.push(gulp.src(val.src) .pipe(plumber({ errorHandler: handleErrors })) .pipe(uglify()) .pipe(rename(config.rename)) .pipe(gulp.dest(val.dest))); }); return merge(tasks); }
[ "function", "compressJS", "(", ")", "{", "let", "tasks", "=", "[", "]", ";", "Object", ".", "keys", "(", "config", ".", "tasks", ")", ".", "forEach", "(", "(", "key", ")", "=>", "{", "let", "val", "=", "config", ".", "tasks", "[", "key", "]", ";", "tasks", ".", "push", "(", "gulp", ".", "src", "(", "val", ".", "src", ")", ".", "pipe", "(", "plumber", "(", "{", "errorHandler", ":", "handleErrors", "}", ")", ")", ".", "pipe", "(", "uglify", "(", ")", ")", ".", "pipe", "(", "rename", "(", "config", ".", "rename", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "val", ".", "dest", ")", ")", ")", ";", "}", ")", ";", "return", "merge", "(", "tasks", ")", ";", "}" ]
Create minified versions of all JS assets.
[ "Create", "minified", "versions", "of", "all", "JS", "assets", "." ]
9d9f5bd8bd8f45a477bcb852e88abdad4b40974d
https://github.com/mozilla/protocol/blob/9d9f5bd8bd8f45a477bcb852e88abdad4b40974d/gulpfile.js/tasks/compress-js.js#L12-L25
12,487
mozilla/protocol
gulpfile.js/tasks/watch.js
watchTask
function watchTask() { gulp.watch(config.watchers.static, copyStaticFiles); gulp.watch(config.watchers.css, gulp.series(lintCSS, compileSass)); gulp.watch(config.watchers.js, gulp.series(lintJS, concatJS, copyJS)); gulp.watch(config.watchers.drizzle, drizzleTask); }
javascript
function watchTask() { gulp.watch(config.watchers.static, copyStaticFiles); gulp.watch(config.watchers.css, gulp.series(lintCSS, compileSass)); gulp.watch(config.watchers.js, gulp.series(lintJS, concatJS, copyJS)); gulp.watch(config.watchers.drizzle, drizzleTask); }
[ "function", "watchTask", "(", ")", "{", "gulp", ".", "watch", "(", "config", ".", "watchers", ".", "static", ",", "copyStaticFiles", ")", ";", "gulp", ".", "watch", "(", "config", ".", "watchers", ".", "css", ",", "gulp", ".", "series", "(", "lintCSS", ",", "compileSass", ")", ")", ";", "gulp", ".", "watch", "(", "config", ".", "watchers", ".", "js", ",", "gulp", ".", "series", "(", "lintJS", ",", "concatJS", ",", "copyJS", ")", ")", ";", "gulp", ".", "watch", "(", "config", ".", "watchers", ".", "drizzle", ",", "drizzleTask", ")", ";", "}" ]
Watch files for changes & rebuild.
[ "Watch", "files", "for", "changes", "&", "rebuild", "." ]
9d9f5bd8bd8f45a477bcb852e88abdad4b40974d
https://github.com/mozilla/protocol/blob/9d9f5bd8bd8f45a477bcb852e88abdad4b40974d/gulpfile.js/tasks/watch.js#L14-L19
12,488
mozilla/protocol
gulpfile.js/tasks/compress-css.js
compressCSS
function compressCSS() { let tasks = []; Object.keys(config.tasks).forEach((key) => { let val = config.tasks[key]; tasks.push(gulp.src(val.src) .pipe(cleanCSS({processImport: false})) .pipe(rename(config.rename)) .pipe(gulp.dest(val.dest))); }); return merge(tasks); }
javascript
function compressCSS() { let tasks = []; Object.keys(config.tasks).forEach((key) => { let val = config.tasks[key]; tasks.push(gulp.src(val.src) .pipe(cleanCSS({processImport: false})) .pipe(rename(config.rename)) .pipe(gulp.dest(val.dest))); }); return merge(tasks); }
[ "function", "compressCSS", "(", ")", "{", "let", "tasks", "=", "[", "]", ";", "Object", ".", "keys", "(", "config", ".", "tasks", ")", ".", "forEach", "(", "(", "key", ")", "=>", "{", "let", "val", "=", "config", ".", "tasks", "[", "key", "]", ";", "tasks", ".", "push", "(", "gulp", ".", "src", "(", "val", ".", "src", ")", ".", "pipe", "(", "cleanCSS", "(", "{", "processImport", ":", "false", "}", ")", ")", ".", "pipe", "(", "rename", "(", "config", ".", "rename", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "val", ".", "dest", ")", ")", ")", ";", "}", ")", ";", "return", "merge", "(", "tasks", ")", ";", "}" ]
Create minified versions of all CSS assets.
[ "Create", "minified", "versions", "of", "all", "CSS", "assets", "." ]
9d9f5bd8bd8f45a477bcb852e88abdad4b40974d
https://github.com/mozilla/protocol/blob/9d9f5bd8bd8f45a477bcb852e88abdad4b40974d/gulpfile.js/tasks/compress-css.js#L10-L22
12,489
mozilla/protocol
src/assets/js/protocol/protocol-newsletter.js
initEmailForm
function initEmailForm() { var newsletterForm = document.getElementById('newsletter-form'); var submitButton = document.getElementById('newsletter-submit'); var formDetails = document.getElementById('newsletter-details'); var emailField = document.querySelector('.mzp-js-email-field'); var formExpanded = window.getComputedStyle(formDetails).display === 'none' ? false : true; function emailFormShowDetails() { if (!formExpanded) { formDetails.style.display = 'block'; formExpanded = true; } } emailField.addEventListener('focus', function() { emailFormShowDetails(); }); submitButton.addEventListener('click', function(e) { if (!formExpanded) { e.preventDefault(); emailFormShowDetails(); } }); newsletterForm.addEventListener('submit', function(e) { if (!formExpanded) { e.preventDefault(); emailFormShowDetails(); } }); }
javascript
function initEmailForm() { var newsletterForm = document.getElementById('newsletter-form'); var submitButton = document.getElementById('newsletter-submit'); var formDetails = document.getElementById('newsletter-details'); var emailField = document.querySelector('.mzp-js-email-field'); var formExpanded = window.getComputedStyle(formDetails).display === 'none' ? false : true; function emailFormShowDetails() { if (!formExpanded) { formDetails.style.display = 'block'; formExpanded = true; } } emailField.addEventListener('focus', function() { emailFormShowDetails(); }); submitButton.addEventListener('click', function(e) { if (!formExpanded) { e.preventDefault(); emailFormShowDetails(); } }); newsletterForm.addEventListener('submit', function(e) { if (!formExpanded) { e.preventDefault(); emailFormShowDetails(); } }); }
[ "function", "initEmailForm", "(", ")", "{", "var", "newsletterForm", "=", "document", ".", "getElementById", "(", "'newsletter-form'", ")", ";", "var", "submitButton", "=", "document", ".", "getElementById", "(", "'newsletter-submit'", ")", ";", "var", "formDetails", "=", "document", ".", "getElementById", "(", "'newsletter-details'", ")", ";", "var", "emailField", "=", "document", ".", "querySelector", "(", "'.mzp-js-email-field'", ")", ";", "var", "formExpanded", "=", "window", ".", "getComputedStyle", "(", "formDetails", ")", ".", "display", "===", "'none'", "?", "false", ":", "true", ";", "function", "emailFormShowDetails", "(", ")", "{", "if", "(", "!", "formExpanded", ")", "{", "formDetails", ".", "style", ".", "display", "=", "'block'", ";", "formExpanded", "=", "true", ";", "}", "}", "emailField", ".", "addEventListener", "(", "'focus'", ",", "function", "(", ")", "{", "emailFormShowDetails", "(", ")", ";", "}", ")", ";", "submitButton", ".", "addEventListener", "(", "'click'", ",", "function", "(", "e", ")", "{", "if", "(", "!", "formExpanded", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "emailFormShowDetails", "(", ")", ";", "}", "}", ")", ";", "newsletterForm", ".", "addEventListener", "(", "'submit'", ",", "function", "(", "e", ")", "{", "if", "(", "!", "formExpanded", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "emailFormShowDetails", "(", ")", ";", "}", "}", ")", ";", "}" ]
!! This file assumes only one signup form per page !! Expand email form on input focus or submit if details aren't visible
[ "!!", "This", "file", "assumes", "only", "one", "signup", "form", "per", "page", "!!", "Expand", "email", "form", "on", "input", "focus", "or", "submit", "if", "details", "aren", "t", "visible" ]
9d9f5bd8bd8f45a477bcb852e88abdad4b40974d
https://github.com/mozilla/protocol/blob/9d9f5bd8bd8f45a477bcb852e88abdad4b40974d/src/assets/js/protocol/protocol-newsletter.js#L11-L42
12,490
mozilla/protocol
gulpfile.js/tasks/copy-js.js
copyJS
function copyJS() { let tasks = []; Object.keys(config).forEach((key) => { let val = config[key]; tasks.push(gulp.src(val.src).pipe(gulp.dest(val.dest))); }); return merge(tasks); }
javascript
function copyJS() { let tasks = []; Object.keys(config).forEach((key) => { let val = config[key]; tasks.push(gulp.src(val.src).pipe(gulp.dest(val.dest))); }); return merge(tasks); }
[ "function", "copyJS", "(", ")", "{", "let", "tasks", "=", "[", "]", ";", "Object", ".", "keys", "(", "config", ")", ".", "forEach", "(", "(", "key", ")", "=>", "{", "let", "val", "=", "config", "[", "key", "]", ";", "tasks", ".", "push", "(", "gulp", ".", "src", "(", "val", ".", "src", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "val", ".", "dest", ")", ")", ")", ";", "}", ")", ";", "return", "merge", "(", "tasks", ")", ";", "}" ]
Copy across all original JS files for distribution.
[ "Copy", "across", "all", "original", "JS", "files", "for", "distribution", "." ]
9d9f5bd8bd8f45a477bcb852e88abdad4b40974d
https://github.com/mozilla/protocol/blob/9d9f5bd8bd8f45a477bcb852e88abdad4b40974d/gulpfile.js/tasks/copy-js.js#L8-L16
12,491
mozilla/protocol
gulpfile.js/tasks/concat-js.js
concatJS
function concatJS() { let tasks = []; Object.keys(config).forEach((key) => { let val = config[key]; tasks.push(gulp.src(val.src) .pipe(plumber({ errorHandler: handleErrors })) .pipe(concat(key + '.js')) .pipe(gulp.dest(val.dest))); }); return merge(tasks); }
javascript
function concatJS() { let tasks = []; Object.keys(config).forEach((key) => { let val = config[key]; tasks.push(gulp.src(val.src) .pipe(plumber({ errorHandler: handleErrors })) .pipe(concat(key + '.js')) .pipe(gulp.dest(val.dest))); }); return merge(tasks); }
[ "function", "concatJS", "(", ")", "{", "let", "tasks", "=", "[", "]", ";", "Object", ".", "keys", "(", "config", ")", ".", "forEach", "(", "(", "key", ")", "=>", "{", "let", "val", "=", "config", "[", "key", "]", ";", "tasks", ".", "push", "(", "gulp", ".", "src", "(", "val", ".", "src", ")", ".", "pipe", "(", "plumber", "(", "{", "errorHandler", ":", "handleErrors", "}", ")", ")", ".", "pipe", "(", "concat", "(", "key", "+", "'.js'", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "val", ".", "dest", ")", ")", ")", ";", "}", ")", ";", "return", "merge", "(", "tasks", ")", ";", "}" ]
Concatenate docs JS files.
[ "Concatenate", "docs", "JS", "files", "." ]
9d9f5bd8bd8f45a477bcb852e88abdad4b40974d
https://github.com/mozilla/protocol/blob/9d9f5bd8bd8f45a477bcb852e88abdad4b40974d/gulpfile.js/tasks/concat-js.js#L11-L23
12,492
omnidan/node-emoji
lib/emoji.js
stripColons
function stripColons (str) { var colonIndex = str.indexOf(':'); if (colonIndex > -1) { // :emoji: (http://www.emoji-cheat-sheet.com/) if (colonIndex === str.length - 1) { str = str.substring(0, colonIndex); return stripColons(str); } else { str = str.substr(colonIndex + 1); return stripColons(str); } } return str; }
javascript
function stripColons (str) { var colonIndex = str.indexOf(':'); if (colonIndex > -1) { // :emoji: (http://www.emoji-cheat-sheet.com/) if (colonIndex === str.length - 1) { str = str.substring(0, colonIndex); return stripColons(str); } else { str = str.substr(colonIndex + 1); return stripColons(str); } } return str; }
[ "function", "stripColons", "(", "str", ")", "{", "var", "colonIndex", "=", "str", ".", "indexOf", "(", "':'", ")", ";", "if", "(", "colonIndex", ">", "-", "1", ")", "{", "// :emoji: (http://www.emoji-cheat-sheet.com/)", "if", "(", "colonIndex", "===", "str", ".", "length", "-", "1", ")", "{", "str", "=", "str", ".", "substring", "(", "0", ",", "colonIndex", ")", ";", "return", "stripColons", "(", "str", ")", ";", "}", "else", "{", "str", "=", "str", ".", "substr", "(", "colonIndex", "+", "1", ")", ";", "return", "stripColons", "(", "str", ")", ";", "}", "}", "return", "str", ";", "}" ]
Removes colons on either side of the string if present @param {string} str @return {string}
[ "Removes", "colons", "on", "either", "side", "of", "the", "string", "if", "present" ]
e6d9acb85692f5c5d6a156b04aa0de4d353c5b33
https://github.com/omnidan/node-emoji/blob/e6d9acb85692f5c5d6a156b04aa0de4d353c5b33/lib/emoji.js#L24-L38
12,493
laverdet/node-fibers
future.js
function() { if (!this.resolved) { throw new Error('Future must resolve before value is ready'); } else if (this.error) { // Link the stack traces up var error = this.error; var localStack = {}; Error.captureStackTrace(localStack, Future.prototype.get); var futureStack = Object.getOwnPropertyDescriptor(error, 'futureStack'); if (!futureStack) { futureStack = Object.getOwnPropertyDescriptor(error, 'stack'); if (futureStack) { Object.defineProperty(error, 'futureStack', futureStack); } } if (futureStack && futureStack.get) { Object.defineProperty(error, 'stack', { get: function() { var stack = futureStack.get.apply(error); if (stack) { stack = stack.split('\n'); return [stack[0]] .concat(localStack.stack.split('\n').slice(1)) .concat(' - - - - -') .concat(stack.slice(1)) .join('\n'); } else { return localStack.stack; } }, set: function(stack) { Object.defineProperty(error, 'stack', { value: stack, configurable: true, enumerable: false, writable: true, }); }, configurable: true, enumerable: false, }); } throw error; } else { return this.value; } }
javascript
function() { if (!this.resolved) { throw new Error('Future must resolve before value is ready'); } else if (this.error) { // Link the stack traces up var error = this.error; var localStack = {}; Error.captureStackTrace(localStack, Future.prototype.get); var futureStack = Object.getOwnPropertyDescriptor(error, 'futureStack'); if (!futureStack) { futureStack = Object.getOwnPropertyDescriptor(error, 'stack'); if (futureStack) { Object.defineProperty(error, 'futureStack', futureStack); } } if (futureStack && futureStack.get) { Object.defineProperty(error, 'stack', { get: function() { var stack = futureStack.get.apply(error); if (stack) { stack = stack.split('\n'); return [stack[0]] .concat(localStack.stack.split('\n').slice(1)) .concat(' - - - - -') .concat(stack.slice(1)) .join('\n'); } else { return localStack.stack; } }, set: function(stack) { Object.defineProperty(error, 'stack', { value: stack, configurable: true, enumerable: false, writable: true, }); }, configurable: true, enumerable: false, }); } throw error; } else { return this.value; } }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "resolved", ")", "{", "throw", "new", "Error", "(", "'Future must resolve before value is ready'", ")", ";", "}", "else", "if", "(", "this", ".", "error", ")", "{", "// Link the stack traces up", "var", "error", "=", "this", ".", "error", ";", "var", "localStack", "=", "{", "}", ";", "Error", ".", "captureStackTrace", "(", "localStack", ",", "Future", ".", "prototype", ".", "get", ")", ";", "var", "futureStack", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "error", ",", "'futureStack'", ")", ";", "if", "(", "!", "futureStack", ")", "{", "futureStack", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "error", ",", "'stack'", ")", ";", "if", "(", "futureStack", ")", "{", "Object", ".", "defineProperty", "(", "error", ",", "'futureStack'", ",", "futureStack", ")", ";", "}", "}", "if", "(", "futureStack", "&&", "futureStack", ".", "get", ")", "{", "Object", ".", "defineProperty", "(", "error", ",", "'stack'", ",", "{", "get", ":", "function", "(", ")", "{", "var", "stack", "=", "futureStack", ".", "get", ".", "apply", "(", "error", ")", ";", "if", "(", "stack", ")", "{", "stack", "=", "stack", ".", "split", "(", "'\\n'", ")", ";", "return", "[", "stack", "[", "0", "]", "]", ".", "concat", "(", "localStack", ".", "stack", ".", "split", "(", "'\\n'", ")", ".", "slice", "(", "1", ")", ")", ".", "concat", "(", "' - - - - -'", ")", ".", "concat", "(", "stack", ".", "slice", "(", "1", ")", ")", ".", "join", "(", "'\\n'", ")", ";", "}", "else", "{", "return", "localStack", ".", "stack", ";", "}", "}", ",", "set", ":", "function", "(", "stack", ")", "{", "Object", ".", "defineProperty", "(", "error", ",", "'stack'", ",", "{", "value", ":", "stack", ",", "configurable", ":", "true", ",", "enumerable", ":", "false", ",", "writable", ":", "true", ",", "}", ")", ";", "}", ",", "configurable", ":", "true", ",", "enumerable", ":", "false", ",", "}", ")", ";", "}", "throw", "error", ";", "}", "else", "{", "return", "this", ".", "value", ";", "}", "}" ]
Return the value of this future. If the future hasn't resolved yet this will throw an error.
[ "Return", "the", "value", "of", "this", "future", ".", "If", "the", "future", "hasn", "t", "resolved", "yet", "this", "will", "throw", "an", "error", "." ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L208-L254
12,494
laverdet/node-fibers
future.js
function(value) { if (this.resolved) { throw new Error('Future resolved more than once'); } this.value = value; this.resolved = true; var callbacks = this.callbacks; if (callbacks) { delete this.callbacks; for (var ii = 0; ii < callbacks.length; ++ii) { try { var ref = callbacks[ii]; if (ref[1]) { ref[1](value); } else { ref[0](undefined, value); } } catch(ex) { // console.log('Resolve cb threw', String(ex.stack || ex.message || ex)); process.nextTick(function() { throw(ex); }); } } } }
javascript
function(value) { if (this.resolved) { throw new Error('Future resolved more than once'); } this.value = value; this.resolved = true; var callbacks = this.callbacks; if (callbacks) { delete this.callbacks; for (var ii = 0; ii < callbacks.length; ++ii) { try { var ref = callbacks[ii]; if (ref[1]) { ref[1](value); } else { ref[0](undefined, value); } } catch(ex) { // console.log('Resolve cb threw', String(ex.stack || ex.message || ex)); process.nextTick(function() { throw(ex); }); } } } }
[ "function", "(", "value", ")", "{", "if", "(", "this", ".", "resolved", ")", "{", "throw", "new", "Error", "(", "'Future resolved more than once'", ")", ";", "}", "this", ".", "value", "=", "value", ";", "this", ".", "resolved", "=", "true", ";", "var", "callbacks", "=", "this", ".", "callbacks", ";", "if", "(", "callbacks", ")", "{", "delete", "this", ".", "callbacks", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "callbacks", ".", "length", ";", "++", "ii", ")", "{", "try", "{", "var", "ref", "=", "callbacks", "[", "ii", "]", ";", "if", "(", "ref", "[", "1", "]", ")", "{", "ref", "[", "1", "]", "(", "value", ")", ";", "}", "else", "{", "ref", "[", "0", "]", "(", "undefined", ",", "value", ")", ";", "}", "}", "catch", "(", "ex", ")", "{", "// console.log('Resolve cb threw', String(ex.stack || ex.message || ex));", "process", ".", "nextTick", "(", "function", "(", ")", "{", "throw", "(", "ex", ")", ";", "}", ")", ";", "}", "}", "}", "}" ]
Mark this future as returned. All pending callbacks will be invoked immediately.
[ "Mark", "this", "future", "as", "returned", ".", "All", "pending", "callbacks", "will", "be", "invoked", "immediately", "." ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L259-L285
12,495
laverdet/node-fibers
future.js
function(error) { if (this.resolved) { throw new Error('Future resolved more than once'); } else if (!error) { throw new Error('Must throw non-empty error'); } this.error = error; this.resolved = true; var callbacks = this.callbacks; if (callbacks) { delete this.callbacks; for (var ii = 0; ii < callbacks.length; ++ii) { try { var ref = callbacks[ii]; if (ref[1]) { ref[0].throw(error); } else { ref[0](error); } } catch(ex) { // console.log('Resolve cb threw', String(ex.stack || ex.message || ex)); process.nextTick(function() { throw(ex); }); } } } }
javascript
function(error) { if (this.resolved) { throw new Error('Future resolved more than once'); } else if (!error) { throw new Error('Must throw non-empty error'); } this.error = error; this.resolved = true; var callbacks = this.callbacks; if (callbacks) { delete this.callbacks; for (var ii = 0; ii < callbacks.length; ++ii) { try { var ref = callbacks[ii]; if (ref[1]) { ref[0].throw(error); } else { ref[0](error); } } catch(ex) { // console.log('Resolve cb threw', String(ex.stack || ex.message || ex)); process.nextTick(function() { throw(ex); }); } } } }
[ "function", "(", "error", ")", "{", "if", "(", "this", ".", "resolved", ")", "{", "throw", "new", "Error", "(", "'Future resolved more than once'", ")", ";", "}", "else", "if", "(", "!", "error", ")", "{", "throw", "new", "Error", "(", "'Must throw non-empty error'", ")", ";", "}", "this", ".", "error", "=", "error", ";", "this", ".", "resolved", "=", "true", ";", "var", "callbacks", "=", "this", ".", "callbacks", ";", "if", "(", "callbacks", ")", "{", "delete", "this", ".", "callbacks", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "callbacks", ".", "length", ";", "++", "ii", ")", "{", "try", "{", "var", "ref", "=", "callbacks", "[", "ii", "]", ";", "if", "(", "ref", "[", "1", "]", ")", "{", "ref", "[", "0", "]", ".", "throw", "(", "error", ")", ";", "}", "else", "{", "ref", "[", "0", "]", "(", "error", ")", ";", "}", "}", "catch", "(", "ex", ")", "{", "// console.log('Resolve cb threw', String(ex.stack || ex.message || ex));", "process", ".", "nextTick", "(", "function", "(", ")", "{", "throw", "(", "ex", ")", ";", "}", ")", ";", "}", "}", "}", "}" ]
Throw from this future as returned. All pending callbacks will be invoked immediately.
[ "Throw", "from", "this", "future", "as", "returned", ".", "All", "pending", "callbacks", "will", "be", "invoked", "immediately", "." ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L290-L318
12,496
laverdet/node-fibers
future.js
function(arg1, arg2) { if (this.resolved) { if (arg2) { if (this.error) { arg1.throw(this.error); } else { arg2(this.value); } } else { arg1(this.error, this.value); } } else { (this.callbacks = this.callbacks || []).push([arg1, arg2]); } return this; }
javascript
function(arg1, arg2) { if (this.resolved) { if (arg2) { if (this.error) { arg1.throw(this.error); } else { arg2(this.value); } } else { arg1(this.error, this.value); } } else { (this.callbacks = this.callbacks || []).push([arg1, arg2]); } return this; }
[ "function", "(", "arg1", ",", "arg2", ")", "{", "if", "(", "this", ".", "resolved", ")", "{", "if", "(", "arg2", ")", "{", "if", "(", "this", ".", "error", ")", "{", "arg1", ".", "throw", "(", "this", ".", "error", ")", ";", "}", "else", "{", "arg2", "(", "this", ".", "value", ")", ";", "}", "}", "else", "{", "arg1", "(", "this", ".", "error", ",", "this", ".", "value", ")", ";", "}", "}", "else", "{", "(", "this", ".", "callbacks", "=", "this", ".", "callbacks", "||", "[", "]", ")", ".", "push", "(", "[", "arg1", ",", "arg2", "]", ")", ";", "}", "return", "this", ";", "}" ]
Waits for this future to resolve and then invokes a callback. If two arguments are passed, the first argument is a future which will be thrown to in the case of error, and the second is a function(val){} callback. If only one argument is passed it is a standard function(err, val){} callback.
[ "Waits", "for", "this", "future", "to", "resolve", "and", "then", "invokes", "a", "callback", "." ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L362-L377
12,497
laverdet/node-fibers
future.js
function(futures) { this.resolve(function(err) { if (!err) { return; } if (futures instanceof Array) { for (var ii = 0; ii < futures.length; ++ii) { futures[ii].throw(err); } } else { futures.throw(err); } }); return this; }
javascript
function(futures) { this.resolve(function(err) { if (!err) { return; } if (futures instanceof Array) { for (var ii = 0; ii < futures.length; ++ii) { futures[ii].throw(err); } } else { futures.throw(err); } }); return this; }
[ "function", "(", "futures", ")", "{", "this", ".", "resolve", "(", "function", "(", "err", ")", "{", "if", "(", "!", "err", ")", "{", "return", ";", "}", "if", "(", "futures", "instanceof", "Array", ")", "{", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "futures", ".", "length", ";", "++", "ii", ")", "{", "futures", "[", "ii", "]", ".", "throw", "(", "err", ")", ";", "}", "}", "else", "{", "futures", ".", "throw", "(", "err", ")", ";", "}", "}", ")", ";", "return", "this", ";", "}" ]
Propogate only errors to an another future or array of futures.
[ "Propogate", "only", "errors", "to", "an", "another", "future", "or", "array", "of", "futures", "." ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L408-L422
12,498
laverdet/node-fibers
future.js
function() { var that = this; return new Promise(function(resolve, reject) { that.resolve(function(err, val) { if (err) { reject(err); } else { resolve(val); } }); }); }
javascript
function() { var that = this; return new Promise(function(resolve, reject) { that.resolve(function(err, val) { if (err) { reject(err); } else { resolve(val); } }); }); }
[ "function", "(", ")", "{", "var", "that", "=", "this", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "that", ".", "resolve", "(", "function", "(", "err", ",", "val", ")", "{", "if", "(", "err", ")", "{", "reject", "(", "err", ")", ";", "}", "else", "{", "resolve", "(", "val", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
Returns an ES6 Promise
[ "Returns", "an", "ES6", "Promise" ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L427-L438
12,499
laverdet/node-fibers
future.js
FiberFuture
function FiberFuture(fn, context, args) { this.fn = fn; this.context = context; this.args = args; this.started = false; var that = this; process.nextTick(function() { if (!that.started) { that.started = true; Fiber(function() { try { that.return(fn.apply(context, args)); } catch(e) { that.throw(e); } }).run(); } }); }
javascript
function FiberFuture(fn, context, args) { this.fn = fn; this.context = context; this.args = args; this.started = false; var that = this; process.nextTick(function() { if (!that.started) { that.started = true; Fiber(function() { try { that.return(fn.apply(context, args)); } catch(e) { that.throw(e); } }).run(); } }); }
[ "function", "FiberFuture", "(", "fn", ",", "context", ",", "args", ")", "{", "this", ".", "fn", "=", "fn", ";", "this", ".", "context", "=", "context", ";", "this", ".", "args", "=", "args", ";", "this", ".", "started", "=", "false", ";", "var", "that", "=", "this", ";", "process", ".", "nextTick", "(", "function", "(", ")", "{", "if", "(", "!", "that", ".", "started", ")", "{", "that", ".", "started", "=", "true", ";", "Fiber", "(", "function", "(", ")", "{", "try", "{", "that", ".", "return", "(", "fn", ".", "apply", "(", "context", ",", "args", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "that", ".", "throw", "(", "e", ")", ";", "}", "}", ")", ".", "run", "(", ")", ";", "}", "}", ")", ";", "}" ]
A function call which loads inside a fiber automatically and returns a future.
[ "A", "function", "call", "which", "loads", "inside", "a", "fiber", "automatically", "and", "returns", "a", "future", "." ]
5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f
https://github.com/laverdet/node-fibers/blob/5c24f960bc8d2a5a4e1aaf5de5ded3587566a86f/future.js#L456-L474