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
15,900
sympmarc/SPServices
src/value-added/SPScriptAudit.js
coreScript
function coreScript(src) { var coreScriptLocations = ["WebResource.axd", "_layouts"]; for (var i = 0; i < coreScriptLocations.length; i++) { if (src.indexOf(coreScriptLocations[i]) > -1) { return true; } } return false; }
javascript
function coreScript(src) { var coreScriptLocations = ["WebResource.axd", "_layouts"]; for (var i = 0; i < coreScriptLocations.length; i++) { if (src.indexOf(coreScriptLocations[i]) > -1) { return true; } } return false; }
[ "function", "coreScript", "(", "src", ")", "{", "var", "coreScriptLocations", "=", "[", "\"WebResource.axd\"", ",", "\"_layouts\"", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "coreScriptLocations", ".", "length", ";", "i", "++", ")", "{", "if", "(", "src", ".", "indexOf", "(", "coreScriptLocations", "[", "i", "]", ")", ">", "-", "1", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
End of function getScriptAttribute Check to see if the script reference is part of SharePoint core so that we can ignore it
[ "End", "of", "function", "getScriptAttribute", "Check", "to", "see", "if", "the", "script", "reference", "is", "part", "of", "SharePoint", "core", "so", "that", "we", "can", "ignore", "it" ]
7ff0d24658d1d354a937bc82ab21cb6352025ea3
https://github.com/sympmarc/SPServices/blob/7ff0d24658d1d354a937bc82ab21cb6352025ea3/src/value-added/SPScriptAudit.js#L248-L256
15,901
jantimon/iconfont-webpack-plugin
lib/icons-to-woff.js
getSvgHeight
function getSvgHeight (svg, filename) { const parseSvg = /<svg[^>]+height\s*=\s*["']?(\d+)\s*(pt|px|)["']?/i.exec(svg); if (!parseSvg) { throw new Error(`could not read height for '${filename}'.`); } return parseSvg[1]; }
javascript
function getSvgHeight (svg, filename) { const parseSvg = /<svg[^>]+height\s*=\s*["']?(\d+)\s*(pt|px|)["']?/i.exec(svg); if (!parseSvg) { throw new Error(`could not read height for '${filename}'.`); } return parseSvg[1]; }
[ "function", "getSvgHeight", "(", "svg", ",", "filename", ")", "{", "const", "parseSvg", "=", "/", "<svg[^>]+height\\s*=\\s*[\"']?(\\d+)\\s*(pt|px|)[\"']?", "/", "i", ".", "exec", "(", "svg", ")", ";", "if", "(", "!", "parseSvg", ")", "{", "throw", "new", "Error", "(", "`", "${", "filename", "}", "`", ")", ";", "}", "return", "parseSvg", "[", "1", "]", ";", "}" ]
Reads the height of the svg @param {String} svg the svg content @param {String} filename the file name for error reporting @return {Number} height
[ "Reads", "the", "height", "of", "the", "svg" ]
c180d5218b8173f80d65f9779f880487bc172a5a
https://github.com/jantimon/iconfont-webpack-plugin/blob/c180d5218b8173f80d65f9779f880487bc172a5a/lib/icons-to-woff.js#L76-L82
15,902
ssbc/secret-stack
core.js
function (address, cb) { setupMultiserver() ms_client.client(coearseAddress(address), function (err, stream) { return err ? cb(err) : cb(null, setupRPC(stream, null, true)) }) }
javascript
function (address, cb) { setupMultiserver() ms_client.client(coearseAddress(address), function (err, stream) { return err ? cb(err) : cb(null, setupRPC(stream, null, true)) }) }
[ "function", "(", "address", ",", "cb", ")", "{", "setupMultiserver", "(", ")", "ms_client", ".", "client", "(", "coearseAddress", "(", "address", ")", ",", "function", "(", "err", ",", "stream", ")", "{", "return", "err", "?", "cb", "(", "err", ")", ":", "cb", "(", "null", ",", "setupRPC", "(", "stream", ",", "null", ",", "true", ")", ")", "}", ")", "}" ]
cannot be called remote.
[ "cannot", "be", "called", "remote", "." ]
195151ad97b0c5e8954e72f35c4cca193fb47e60
https://github.com/ssbc/secret-stack/blob/195151ad97b0c5e8954e72f35c4cca193fb47e60/core.js#L216-L221
15,903
yyx990803/pod
lib/api.js
function (done) { fs.readdir(globalConfig.root, function (err, files) { if (err) return callback(err) async.map(files, function (f, next) { if (f !== 'apps' && f !== 'repos') { f = globalConfig.root + '/' + f pruned.push(f) removeFile(f, next) } else { next() } }, done) }) }
javascript
function (done) { fs.readdir(globalConfig.root, function (err, files) { if (err) return callback(err) async.map(files, function (f, next) { if (f !== 'apps' && f !== 'repos') { f = globalConfig.root + '/' + f pruned.push(f) removeFile(f, next) } else { next() } }, done) }) }
[ "function", "(", "done", ")", "{", "fs", ".", "readdir", "(", "globalConfig", ".", "root", ",", "function", "(", "err", ",", "files", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", "async", ".", "map", "(", "files", ",", "function", "(", "f", ",", "next", ")", "{", "if", "(", "f", "!==", "'apps'", "&&", "f", "!==", "'repos'", ")", "{", "f", "=", "globalConfig", ".", "root", "+", "'/'", "+", "f", "pruned", ".", "push", "(", "f", ")", "removeFile", "(", "f", ",", "next", ")", "}", "else", "{", "next", "(", ")", "}", "}", ",", "done", ")", "}", ")", "}" ]
clean root dir
[ "clean", "root", "dir" ]
97a546c2c632466898947a6ad3480ce6e7e4f99e
https://github.com/yyx990803/pod/blob/97a546c2c632466898947a6ad3480ce6e7e4f99e/lib/api.js#L276-L289
15,904
edimuj/cordova-plugin-audioinput
src/browser/AudioInputCaptureProxy.js
initialize
function initialize(success, error, opts) { console.log("AudioInputCaptureProxy: initialize: " + JSON.stringify(opts)); onInitialized = success; if (!intialized) { sampleRate = opts[0] || sampleRate; bufferSize = opts[1] || bufferSize; channels = opts[2] || channels; format = opts[3] || format; audioSourceType = opts[4] || audioSourceType; fileUrl = opts[5] || fileUrl; if (fileUrl) { window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; if (window.webkitStorageInfo && window.webkitStorageInfo.requestQuota) { // Chrome/Android requires calling requestQuota first window.webkitStorageInfo.requestQuota( /file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT, 10 * 1024 * 1024, function (grantedBytes) { console.log("AudioInputCaptureProxy: Granted " + grantedBytes + " bytes storage"); window.requestFileSystem( /file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT, 10 * 1024 * 1024, function (fs) { console.log("AudioInputCaptureProxy: Got file system: " + fs.name); fileSystem = fs; intialized = true; onInitialized(); }, error); }, error); } else { // Firefox and Safari/iOS require calling requestFileSystem directly window.requestFileSystem( /file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT, 10 * 1024 * 1024, function (fs) { console.log("AudioInputCaptureProxy: Got file system: " + fs.name); fileSystem = fs; intialized = true; onInitialized(); }, error); } return; } // fileUrl set intialized = true; } // !initialized onInitialized(); }
javascript
function initialize(success, error, opts) { console.log("AudioInputCaptureProxy: initialize: " + JSON.stringify(opts)); onInitialized = success; if (!intialized) { sampleRate = opts[0] || sampleRate; bufferSize = opts[1] || bufferSize; channels = opts[2] || channels; format = opts[3] || format; audioSourceType = opts[4] || audioSourceType; fileUrl = opts[5] || fileUrl; if (fileUrl) { window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; if (window.webkitStorageInfo && window.webkitStorageInfo.requestQuota) { // Chrome/Android requires calling requestQuota first window.webkitStorageInfo.requestQuota( /file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT, 10 * 1024 * 1024, function (grantedBytes) { console.log("AudioInputCaptureProxy: Granted " + grantedBytes + " bytes storage"); window.requestFileSystem( /file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT, 10 * 1024 * 1024, function (fs) { console.log("AudioInputCaptureProxy: Got file system: " + fs.name); fileSystem = fs; intialized = true; onInitialized(); }, error); }, error); } else { // Firefox and Safari/iOS require calling requestFileSystem directly window.requestFileSystem( /file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT, 10 * 1024 * 1024, function (fs) { console.log("AudioInputCaptureProxy: Got file system: " + fs.name); fileSystem = fs; intialized = true; onInitialized(); }, error); } return; } // fileUrl set intialized = true; } // !initialized onInitialized(); }
[ "function", "initialize", "(", "success", ",", "error", ",", "opts", ")", "{", "console", ".", "log", "(", "\"AudioInputCaptureProxy: initialize: \"", "+", "JSON", ".", "stringify", "(", "opts", ")", ")", ";", "onInitialized", "=", "success", ";", "if", "(", "!", "intialized", ")", "{", "sampleRate", "=", "opts", "[", "0", "]", "||", "sampleRate", ";", "bufferSize", "=", "opts", "[", "1", "]", "||", "bufferSize", ";", "channels", "=", "opts", "[", "2", "]", "||", "channels", ";", "format", "=", "opts", "[", "3", "]", "||", "format", ";", "audioSourceType", "=", "opts", "[", "4", "]", "||", "audioSourceType", ";", "fileUrl", "=", "opts", "[", "5", "]", "||", "fileUrl", ";", "if", "(", "fileUrl", ")", "{", "window", ".", "requestFileSystem", "=", "window", ".", "requestFileSystem", "||", "window", ".", "webkitRequestFileSystem", ";", "if", "(", "window", ".", "webkitStorageInfo", "&&", "window", ".", "webkitStorageInfo", ".", "requestQuota", ")", "{", "// Chrome/Android requires calling requestQuota first", "window", ".", "webkitStorageInfo", ".", "requestQuota", "(", "/", "file:\\/\\/\\/temporary.*", "/", ".", "test", "(", "fileUrl", ")", "?", "window", ".", "TEMPORARY", ":", "window", ".", "PERSISTENT", ",", "10", "*", "1024", "*", "1024", ",", "function", "(", "grantedBytes", ")", "{", "console", ".", "log", "(", "\"AudioInputCaptureProxy: Granted \"", "+", "grantedBytes", "+", "\" bytes storage\"", ")", ";", "window", ".", "requestFileSystem", "(", "/", "file:\\/\\/\\/temporary.*", "/", ".", "test", "(", "fileUrl", ")", "?", "window", ".", "TEMPORARY", ":", "window", ".", "PERSISTENT", ",", "10", "*", "1024", "*", "1024", ",", "function", "(", "fs", ")", "{", "console", ".", "log", "(", "\"AudioInputCaptureProxy: Got file system: \"", "+", "fs", ".", "name", ")", ";", "fileSystem", "=", "fs", ";", "intialized", "=", "true", ";", "onInitialized", "(", ")", ";", "}", ",", "error", ")", ";", "}", ",", "error", ")", ";", "}", "else", "{", "// Firefox and Safari/iOS require calling requestFileSystem directly", "window", ".", "requestFileSystem", "(", "/", "file:\\/\\/\\/temporary.*", "/", ".", "test", "(", "fileUrl", ")", "?", "window", ".", "TEMPORARY", ":", "window", ".", "PERSISTENT", ",", "10", "*", "1024", "*", "1024", ",", "function", "(", "fs", ")", "{", "console", ".", "log", "(", "\"AudioInputCaptureProxy: Got file system: \"", "+", "fs", ".", "name", ")", ";", "fileSystem", "=", "fs", ";", "intialized", "=", "true", ";", "onInitialized", "(", ")", ";", "}", ",", "error", ")", ";", "}", "return", ";", "}", "// fileUrl set", "intialized", "=", "true", ";", "}", "// !initialized", "onInitialized", "(", ")", ";", "}" ]
2017-10-29 robert@fromont.net.nz Implement as a Cordova plugin for the 'browser' platform Public:
[ "2017", "-", "10", "-", "29", "robert" ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/src/browser/AudioInputCaptureProxy.js#L24-L72
15,905
edimuj/cordova-plugin-audioinput
src/browser/AudioInputCaptureProxy.js
gotBuffers
function gotBuffers(wav) { if (channels == 1) { audioRecorder.exportMonoWAV(doneEncoding, wav); } else { audioRecorder.exportWAV(doneEncoding, wav); } }
javascript
function gotBuffers(wav) { if (channels == 1) { audioRecorder.exportMonoWAV(doneEncoding, wav); } else { audioRecorder.exportWAV(doneEncoding, wav); } }
[ "function", "gotBuffers", "(", "wav", ")", "{", "if", "(", "channels", "==", "1", ")", "{", "audioRecorder", ".", "exportMonoWAV", "(", "doneEncoding", ",", "wav", ")", ";", "}", "else", "{", "audioRecorder", ".", "exportWAV", "(", "doneEncoding", ",", "wav", ")", ";", "}", "}" ]
callback from recorder invoked when recordin is finished
[ "callback", "from", "recorder", "invoked", "when", "recordin", "is", "finished" ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/src/browser/AudioInputCaptureProxy.js#L218-L225
15,906
edimuj/cordova-plugin-audioinput
demo/file-demo.js
function () { if (window.cordova && window.cordova.file && window.audioinput) { initUIEvents(); consoleMessage("Use 'Start Capture' to begin..."); // Subscribe to audioinput events // window.addEventListener('audioinput', onAudioInputCapture, false); window.addEventListener('audioinputerror', onAudioInputError, false); } else { consoleMessage("Missing: cordova-plugin-file or cordova-plugin-audioinput!"); disableAllButtons(); } }
javascript
function () { if (window.cordova && window.cordova.file && window.audioinput) { initUIEvents(); consoleMessage("Use 'Start Capture' to begin..."); // Subscribe to audioinput events // window.addEventListener('audioinput', onAudioInputCapture, false); window.addEventListener('audioinputerror', onAudioInputError, false); } else { consoleMessage("Missing: cordova-plugin-file or cordova-plugin-audioinput!"); disableAllButtons(); } }
[ "function", "(", ")", "{", "if", "(", "window", ".", "cordova", "&&", "window", ".", "cordova", ".", "file", "&&", "window", ".", "audioinput", ")", "{", "initUIEvents", "(", ")", ";", "consoleMessage", "(", "\"Use 'Start Capture' to begin...\"", ")", ";", "// Subscribe to audioinput events", "//", "window", ".", "addEventListener", "(", "'audioinput'", ",", "onAudioInputCapture", ",", "false", ")", ";", "window", ".", "addEventListener", "(", "'audioinputerror'", ",", "onAudioInputError", ",", "false", ")", ";", "}", "else", "{", "consoleMessage", "(", "\"Missing: cordova-plugin-file or cordova-plugin-audioinput!\"", ")", ";", "disableAllButtons", "(", ")", ";", "}", "}" ]
When cordova fires the deviceready event, we initialize everything needed for audio input.
[ "When", "cordova", "fires", "the", "deviceready", "event", "we", "initialize", "everything", "needed", "for", "audio", "input", "." ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/demo/file-demo.js#L168-L185
15,907
edimuj/cordova-plugin-audioinput
demo/utils.js
function (bufferSize, numberOfIterations) { var bufSize = bufferSize || 16000, iterations = numberOfIterations || 100; for (var i = 0; i < iterations; i++) { var data = []; for (var k = 0; k < bufSize; k++) { data.push((parseFloat(Math.random() * 1.0) - 0.5)); } // Dispatch an event var event = new CustomEvent('audioinput'); event.data = data; window.dispatchEvent(event); } }
javascript
function (bufferSize, numberOfIterations) { var bufSize = bufferSize || 16000, iterations = numberOfIterations || 100; for (var i = 0; i < iterations; i++) { var data = []; for (var k = 0; k < bufSize; k++) { data.push((parseFloat(Math.random() * 1.0) - 0.5)); } // Dispatch an event var event = new CustomEvent('audioinput'); event.data = data; window.dispatchEvent(event); } }
[ "function", "(", "bufferSize", ",", "numberOfIterations", ")", "{", "var", "bufSize", "=", "bufferSize", "||", "16000", ",", "iterations", "=", "numberOfIterations", "||", "100", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "iterations", ";", "i", "++", ")", "{", "var", "data", "=", "[", "]", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "bufSize", ";", "k", "++", ")", "{", "data", ".", "push", "(", "(", "parseFloat", "(", "Math", ".", "random", "(", ")", "*", "1.0", ")", "-", "0.5", ")", ")", ";", "}", "// Dispatch an event", "var", "event", "=", "new", "CustomEvent", "(", "'audioinput'", ")", ";", "event", ".", "data", "=", "data", ";", "window", ".", "dispatchEvent", "(", "event", ")", ";", "}", "}" ]
Generates some random audio input data and dispatches an audioinput event for each buffer @param bufferSize @param numberOfIterations
[ "Generates", "some", "random", "audio", "input", "data", "and", "dispatches", "an", "audioinput", "event", "for", "each", "buffer" ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/demo/utils.js#L35-L52
15,908
edimuj/cordova-plugin-audioinput
demo/events-demo.js
function () { var duration = 50; // Check if there is any data in the queue if (audioDataQueue.length > 0) { // Concatenate up to concatenateMaxChunks data arrays from the queue var concatenatedData = []; for (var i = 0; i < concatenateMaxChunks; i++) { if (audioDataQueue.length === 0) { break; } concatenatedData = concatenatedData.concat(audioDataQueue.shift()); } // Play the audio duration = playAudio(concatenatedData) * 1000; } // Still capturing? Then call myself to continue consuming incoming data. if (window.audioinput && audioinput.isCapturing()) { timerGetNextAudio = setTimeout(getNextToPlay, duration); } }
javascript
function () { var duration = 50; // Check if there is any data in the queue if (audioDataQueue.length > 0) { // Concatenate up to concatenateMaxChunks data arrays from the queue var concatenatedData = []; for (var i = 0; i < concatenateMaxChunks; i++) { if (audioDataQueue.length === 0) { break; } concatenatedData = concatenatedData.concat(audioDataQueue.shift()); } // Play the audio duration = playAudio(concatenatedData) * 1000; } // Still capturing? Then call myself to continue consuming incoming data. if (window.audioinput && audioinput.isCapturing()) { timerGetNextAudio = setTimeout(getNextToPlay, duration); } }
[ "function", "(", ")", "{", "var", "duration", "=", "50", ";", "// Check if there is any data in the queue", "if", "(", "audioDataQueue", ".", "length", ">", "0", ")", "{", "// Concatenate up to concatenateMaxChunks data arrays from the queue", "var", "concatenatedData", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "concatenateMaxChunks", ";", "i", "++", ")", "{", "if", "(", "audioDataQueue", ".", "length", "===", "0", ")", "{", "break", ";", "}", "concatenatedData", "=", "concatenatedData", ".", "concat", "(", "audioDataQueue", ".", "shift", "(", ")", ")", ";", "}", "// Play the audio", "duration", "=", "playAudio", "(", "concatenatedData", ")", "*", "1000", ";", "}", "// Still capturing? Then call myself to continue consuming incoming data.", "if", "(", "window", ".", "audioinput", "&&", "audioinput", ".", "isCapturing", "(", ")", ")", "{", "timerGetNextAudio", "=", "setTimeout", "(", "getNextToPlay", ",", "duration", ")", ";", "}", "}" ]
Consume data from the audioinput queue and calls the playAudio method
[ "Consume", "data", "from", "the", "audioinput", "queue", "and", "calls", "the", "playAudio", "method" ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/demo/events-demo.js#L56-L79
15,909
edimuj/cordova-plugin-audioinput
demo/events-demo.js
function (data) { try { // Create an audio buffer to hold the data var audioBuffer = audioContext.createBuffer(captureCfg.channels, (data.length / captureCfg.channels), captureCfg.sampleRate); // Initialize the audio buffer with the data if (captureCfg.channels > 1) { // For multiple channels (stereo) we assume that the data is interleaved for (var i = 0; i < captureCfg.channels; i++) { var chdata = [], index = 0; while (index < data.length) { chdata.push(data[index + i]); index += parseInt(captureCfg.channels); } audioBuffer.getChannelData(i).set(chdata); } } else { // For just one channels (mono) audioBuffer.getChannelData(0).set(data); } // Create a buffer source based on the audio buffer var source = audioContext.createBufferSource(); source.buffer = audioBuffer; // Connect the buffer source to the gain node source.connect(micGainNode); // Play the audio immediately source.start(0); // Increase the debug counter for played data totalPlayedData += data.length; // Return the duration of the sound so that we can play the next sound when ended. return audioBuffer.duration; } catch(e) { alert("playAudio exception: " + e); return 100; } }
javascript
function (data) { try { // Create an audio buffer to hold the data var audioBuffer = audioContext.createBuffer(captureCfg.channels, (data.length / captureCfg.channels), captureCfg.sampleRate); // Initialize the audio buffer with the data if (captureCfg.channels > 1) { // For multiple channels (stereo) we assume that the data is interleaved for (var i = 0; i < captureCfg.channels; i++) { var chdata = [], index = 0; while (index < data.length) { chdata.push(data[index + i]); index += parseInt(captureCfg.channels); } audioBuffer.getChannelData(i).set(chdata); } } else { // For just one channels (mono) audioBuffer.getChannelData(0).set(data); } // Create a buffer source based on the audio buffer var source = audioContext.createBufferSource(); source.buffer = audioBuffer; // Connect the buffer source to the gain node source.connect(micGainNode); // Play the audio immediately source.start(0); // Increase the debug counter for played data totalPlayedData += data.length; // Return the duration of the sound so that we can play the next sound when ended. return audioBuffer.duration; } catch(e) { alert("playAudio exception: " + e); return 100; } }
[ "function", "(", "data", ")", "{", "try", "{", "// Create an audio buffer to hold the data", "var", "audioBuffer", "=", "audioContext", ".", "createBuffer", "(", "captureCfg", ".", "channels", ",", "(", "data", ".", "length", "/", "captureCfg", ".", "channels", ")", ",", "captureCfg", ".", "sampleRate", ")", ";", "// Initialize the audio buffer with the data", "if", "(", "captureCfg", ".", "channels", ">", "1", ")", "{", "// For multiple channels (stereo) we assume that the data is interleaved", "for", "(", "var", "i", "=", "0", ";", "i", "<", "captureCfg", ".", "channels", ";", "i", "++", ")", "{", "var", "chdata", "=", "[", "]", ",", "index", "=", "0", ";", "while", "(", "index", "<", "data", ".", "length", ")", "{", "chdata", ".", "push", "(", "data", "[", "index", "+", "i", "]", ")", ";", "index", "+=", "parseInt", "(", "captureCfg", ".", "channels", ")", ";", "}", "audioBuffer", ".", "getChannelData", "(", "i", ")", ".", "set", "(", "chdata", ")", ";", "}", "}", "else", "{", "// For just one channels (mono)", "audioBuffer", ".", "getChannelData", "(", "0", ")", ".", "set", "(", "data", ")", ";", "}", "// Create a buffer source based on the audio buffer", "var", "source", "=", "audioContext", ".", "createBufferSource", "(", ")", ";", "source", ".", "buffer", "=", "audioBuffer", ";", "// Connect the buffer source to the gain node", "source", ".", "connect", "(", "micGainNode", ")", ";", "// Play the audio immediately", "source", ".", "start", "(", "0", ")", ";", "// Increase the debug counter for played data", "totalPlayedData", "+=", "data", ".", "length", ";", "// Return the duration of the sound so that we can play the next sound when ended.", "return", "audioBuffer", ".", "duration", ";", "}", "catch", "(", "e", ")", "{", "alert", "(", "\"playAudio exception: \"", "+", "e", ")", ";", "return", "100", ";", "}", "}" ]
Play audio from data using the Web Audio API
[ "Play", "audio", "from", "data", "using", "the", "Web", "Audio", "API" ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/demo/events-demo.js#L85-L131
15,910
edimuj/cordova-plugin-audioinput
demo/events-demo.js
function () { try { window.AudioContext = window.AudioContext || window.webkitAudioContext; audioContext = new window.AudioContext(); consoleMessage("Web Audio Context is ready"); } catch (e) { consoleMessage('Web Audio API is not supported in this browser: ' + e); return false; } // Create a gain node for volume control micGainNode = audioContext.createGain(); // Connect the gain node to the speaker micGainNode.connect(audioContext.destination); return true; }
javascript
function () { try { window.AudioContext = window.AudioContext || window.webkitAudioContext; audioContext = new window.AudioContext(); consoleMessage("Web Audio Context is ready"); } catch (e) { consoleMessage('Web Audio API is not supported in this browser: ' + e); return false; } // Create a gain node for volume control micGainNode = audioContext.createGain(); // Connect the gain node to the speaker micGainNode.connect(audioContext.destination); return true; }
[ "function", "(", ")", "{", "try", "{", "window", ".", "AudioContext", "=", "window", ".", "AudioContext", "||", "window", ".", "webkitAudioContext", ";", "audioContext", "=", "new", "window", ".", "AudioContext", "(", ")", ";", "consoleMessage", "(", "\"Web Audio Context is ready\"", ")", ";", "}", "catch", "(", "e", ")", "{", "consoleMessage", "(", "'Web Audio API is not supported in this browser: '", "+", "e", ")", ";", "return", "false", ";", "}", "// Create a gain node for volume control", "micGainNode", "=", "audioContext", ".", "createGain", "(", ")", ";", "// Connect the gain node to the speaker", "micGainNode", ".", "connect", "(", "audioContext", ".", "destination", ")", ";", "return", "true", ";", "}" ]
Creates the Web Audio Context and audio nodes for output.
[ "Creates", "the", "Web", "Audio", "Context", "and", "audio", "nodes", "for", "output", "." ]
9458b48584e7538483c5e4fa049bd441c1ee9d7c
https://github.com/edimuj/cordova-plugin-audioinput/blob/9458b48584e7538483c5e4fa049bd441c1ee9d7c/demo/events-demo.js#L137-L155
15,911
m-e-conroy/angular-dialog-service
dist/dialogs.js
function(header,msg,opts){ opts = _setOpts(opts); return $uibModal.open({ templateUrl : '/dialogs/notify.html', controller : 'notifyDialogCtrl', backdrop: opts.bd, backdropClass: opts.bdc, keyboard: opts.kb, windowClass: opts.wc, size: opts.ws, animation: opts.anim, resolve : { data : function(){ return { header : angular.copy(header), msg : angular.copy(msg), fa : _fa, btnMessages: opts.btnMessages }; } } }); // end modal.open }
javascript
function(header,msg,opts){ opts = _setOpts(opts); return $uibModal.open({ templateUrl : '/dialogs/notify.html', controller : 'notifyDialogCtrl', backdrop: opts.bd, backdropClass: opts.bdc, keyboard: opts.kb, windowClass: opts.wc, size: opts.ws, animation: opts.anim, resolve : { data : function(){ return { header : angular.copy(header), msg : angular.copy(msg), fa : _fa, btnMessages: opts.btnMessages }; } } }); // end modal.open }
[ "function", "(", "header", ",", "msg", ",", "opts", ")", "{", "opts", "=", "_setOpts", "(", "opts", ")", ";", "return", "$uibModal", ".", "open", "(", "{", "templateUrl", ":", "'/dialogs/notify.html'", ",", "controller", ":", "'notifyDialogCtrl'", ",", "backdrop", ":", "opts", ".", "bd", ",", "backdropClass", ":", "opts", ".", "bdc", ",", "keyboard", ":", "opts", ".", "kb", ",", "windowClass", ":", "opts", ".", "wc", ",", "size", ":", "opts", ".", "ws", ",", "animation", ":", "opts", ".", "anim", ",", "resolve", ":", "{", "data", ":", "function", "(", ")", "{", "return", "{", "header", ":", "angular", ".", "copy", "(", "header", ")", ",", "msg", ":", "angular", ".", "copy", "(", "msg", ")", ",", "fa", ":", "_fa", ",", "btnMessages", ":", "opts", ".", "btnMessages", "}", ";", "}", "}", "}", ")", ";", "// end modal.open", "}" ]
end wait Notify Dialog @param header string @param msg string @param opts object
[ "end", "wait", "Notify", "Dialog" ]
e5425c0fbc82536ebc90c1bf43eb06eab505e1c0
https://github.com/m-e-conroy/angular-dialog-service/blob/e5425c0fbc82536ebc90c1bf43eb06eab505e1c0/dist/dialogs.js#L387-L410
15,912
m-e-conroy/angular-dialog-service
dist/dialogs.js
function(url,ctrlr,data,opts,ctrlAs){ var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; opts = _setOpts(opts); return $uibModal.open({ templateUrl : url, controller : ctrlr, controllerAs : ctrlAs, keyboard : opts.kb, backdrop : opts.bd, backdropClass: opts.bdc, windowClass: opts.wc, size: opts.ws, animation: opts.anim, resolve : { data : function() { if(copy) return angular.copy(data); else return data; } } }); // end modal.open }
javascript
function(url,ctrlr,data,opts,ctrlAs){ var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; opts = _setOpts(opts); return $uibModal.open({ templateUrl : url, controller : ctrlr, controllerAs : ctrlAs, keyboard : opts.kb, backdrop : opts.bd, backdropClass: opts.bdc, windowClass: opts.wc, size: opts.ws, animation: opts.anim, resolve : { data : function() { if(copy) return angular.copy(data); else return data; } } }); // end modal.open }
[ "function", "(", "url", ",", "ctrlr", ",", "data", ",", "opts", ",", "ctrlAs", ")", "{", "var", "copy", "=", "(", "opts", "&&", "angular", ".", "isDefined", "(", "opts", ".", "copy", ")", ")", "?", "opts", ".", "copy", ":", "_copy", ";", "opts", "=", "_setOpts", "(", "opts", ")", ";", "return", "$uibModal", ".", "open", "(", "{", "templateUrl", ":", "url", ",", "controller", ":", "ctrlr", ",", "controllerAs", ":", "ctrlAs", ",", "keyboard", ":", "opts", ".", "kb", ",", "backdrop", ":", "opts", ".", "bd", ",", "backdropClass", ":", "opts", ".", "bdc", ",", "windowClass", ":", "opts", ".", "wc", ",", "size", ":", "opts", ".", "ws", ",", "animation", ":", "opts", ".", "anim", ",", "resolve", ":", "{", "data", ":", "function", "(", ")", "{", "if", "(", "copy", ")", "return", "angular", ".", "copy", "(", "data", ")", ";", "else", "return", "data", ";", "}", "}", "}", ")", ";", "// end modal.open", "}" ]
end confirm Create Custom Dialog @param url string @param ctrlr string @param data object @param opts object
[ "end", "confirm", "Create", "Custom", "Dialog" ]
e5425c0fbc82536ebc90c1bf43eb06eab505e1c0
https://github.com/m-e-conroy/angular-dialog-service/blob/e5425c0fbc82536ebc90c1bf43eb06eab505e1c0/dist/dialogs.js#L452-L475
15,913
m-e-conroy/angular-dialog-service
src/dialogs-services.js
function(component, data, opts) { var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; opts = _setOpts(opts); return $uibModal.open({ component : component, keyboard : opts.kb, backdrop : opts.bd, backdropClass: opts.bdc, windowClass: opts.wc, size: opts.ws, animation: opts.anim, resolve : { data : function() { if(copy) return angular.copy(data); else return data; } } }); // end modal.open }
javascript
function(component, data, opts) { var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; opts = _setOpts(opts); return $uibModal.open({ component : component, keyboard : opts.kb, backdrop : opts.bd, backdropClass: opts.bdc, windowClass: opts.wc, size: opts.ws, animation: opts.anim, resolve : { data : function() { if(copy) return angular.copy(data); else return data; } } }); // end modal.open }
[ "function", "(", "component", ",", "data", ",", "opts", ")", "{", "var", "copy", "=", "(", "opts", "&&", "angular", ".", "isDefined", "(", "opts", ".", "copy", ")", ")", "?", "opts", ".", "copy", ":", "_copy", ";", "opts", "=", "_setOpts", "(", "opts", ")", ";", "return", "$uibModal", ".", "open", "(", "{", "component", ":", "component", ",", "keyboard", ":", "opts", ".", "kb", ",", "backdrop", ":", "opts", ".", "bd", ",", "backdropClass", ":", "opts", ".", "bdc", ",", "windowClass", ":", "opts", ".", "wc", ",", "size", ":", "opts", ".", "ws", ",", "animation", ":", "opts", ".", "anim", ",", "resolve", ":", "{", "data", ":", "function", "(", ")", "{", "if", "(", "copy", ")", "return", "angular", ".", "copy", "(", "data", ")", ";", "else", "return", "data", ";", "}", "}", "}", ")", ";", "// end modal.open", "}" ]
end confirm Create Custom Dialog specifying a component @param component string @param data object @param opts object
[ "end", "confirm", "Create", "Custom", "Dialog", "specifying", "a", "component" ]
e5425c0fbc82536ebc90c1bf43eb06eab505e1c0
https://github.com/m-e-conroy/angular-dialog-service/blob/e5425c0fbc82536ebc90c1bf43eb06eab505e1c0/src/dialogs-services.js#L263-L284
15,914
tonyganch/gonzales-pe
src/scss/tokenizer.js
pushToken
function pushToken(type, value, column) { tokens.push({ tn: tn++, ln: ln, col: column, type: type, value: value }); }
javascript
function pushToken(type, value, column) { tokens.push({ tn: tn++, ln: ln, col: column, type: type, value: value }); }
[ "function", "pushToken", "(", "type", ",", "value", ",", "column", ")", "{", "tokens", ".", "push", "(", "{", "tn", ":", "tn", "++", ",", "ln", ":", "ln", ",", "col", ":", "column", ",", "type", ":", "type", ",", "value", ":", "value", "}", ")", ";", "}" ]
Add a token to the token list @param {string} type @param {string} value
[ "Add", "a", "token", "to", "the", "token", "list" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/scss/tokenizer.js#L60-L68
15,915
tonyganch/gonzales-pe
src/scss/tokenizer.js
parseMLComment
function parseMLComment(css) { var start = pos; // Read the string until we meet `*/`. // Since we already know first 2 characters (`/*`), start reading // from `pos + 2`: for (pos += 2; pos < css.length; pos++) { if (css.charAt(pos) === '*' && css.charAt(pos + 1) === '/') { pos++; break; } } // Add full comment (including `/*` and `*/`) to the list of tokens: var comment = css.substring(start, pos + 1); pushToken(TokenType.CommentML, comment, col); var newlines = comment.split('\n'); if (newlines.length > 1) { ln += newlines.length - 1; col = newlines[newlines.length - 1].length; } else { col += (pos - start); } }
javascript
function parseMLComment(css) { var start = pos; // Read the string until we meet `*/`. // Since we already know first 2 characters (`/*`), start reading // from `pos + 2`: for (pos += 2; pos < css.length; pos++) { if (css.charAt(pos) === '*' && css.charAt(pos + 1) === '/') { pos++; break; } } // Add full comment (including `/*` and `*/`) to the list of tokens: var comment = css.substring(start, pos + 1); pushToken(TokenType.CommentML, comment, col); var newlines = comment.split('\n'); if (newlines.length > 1) { ln += newlines.length - 1; col = newlines[newlines.length - 1].length; } else { col += (pos - start); } }
[ "function", "parseMLComment", "(", "css", ")", "{", "var", "start", "=", "pos", ";", "// Read the string until we meet `*/`.", "// Since we already know first 2 characters (`/*`), start reading", "// from `pos + 2`:", "for", "(", "pos", "+=", "2", ";", "pos", "<", "css", ".", "length", ";", "pos", "++", ")", "{", "if", "(", "css", ".", "charAt", "(", "pos", ")", "===", "'*'", "&&", "css", ".", "charAt", "(", "pos", "+", "1", ")", "===", "'/'", ")", "{", "pos", "++", ";", "break", ";", "}", "}", "// Add full comment (including `/*` and `*/`) to the list of tokens:", "var", "comment", "=", "css", ".", "substring", "(", "start", ",", "pos", "+", "1", ")", ";", "pushToken", "(", "TokenType", ".", "CommentML", ",", "comment", ",", "col", ")", ";", "var", "newlines", "=", "comment", ".", "split", "(", "'\\n'", ")", ";", "if", "(", "newlines", ".", "length", ">", "1", ")", "{", "ln", "+=", "newlines", ".", "length", "-", "1", ";", "col", "=", "newlines", "[", "newlines", ".", "length", "-", "1", "]", ".", "length", ";", "}", "else", "{", "col", "+=", "(", "pos", "-", "start", ")", ";", "}", "}" ]
Parse a multiline comment @param {string} css Unparsed part of CSS string
[ "Parse", "a", "multiline", "comment" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/scss/tokenizer.js#L186-L210
15,916
tonyganch/gonzales-pe
src/scss/tokenizer.js
parseSLComment
function parseSLComment(css) { var start = pos; // Read the string until we meet line break. // Since we already know first 2 characters (`//`), start reading // from `pos + 2`: for (pos += 2; pos < css.length; pos++) { if (css.charAt(pos) === '\n' || css.charAt(pos) === '\r') { break; } } // Add comment (including `//` and line break) to the list of tokens: pushToken(TokenType.CommentSL, css.substring(start, pos--), col); col += pos - start; }
javascript
function parseSLComment(css) { var start = pos; // Read the string until we meet line break. // Since we already know first 2 characters (`//`), start reading // from `pos + 2`: for (pos += 2; pos < css.length; pos++) { if (css.charAt(pos) === '\n' || css.charAt(pos) === '\r') { break; } } // Add comment (including `//` and line break) to the list of tokens: pushToken(TokenType.CommentSL, css.substring(start, pos--), col); col += pos - start; }
[ "function", "parseSLComment", "(", "css", ")", "{", "var", "start", "=", "pos", ";", "// Read the string until we meet line break.", "// Since we already know first 2 characters (`//`), start reading", "// from `pos + 2`:", "for", "(", "pos", "+=", "2", ";", "pos", "<", "css", ".", "length", ";", "pos", "++", ")", "{", "if", "(", "css", ".", "charAt", "(", "pos", ")", "===", "'\\n'", "||", "css", ".", "charAt", "(", "pos", ")", "===", "'\\r'", ")", "{", "break", ";", "}", "}", "// Add comment (including `//` and line break) to the list of tokens:", "pushToken", "(", "TokenType", ".", "CommentSL", ",", "css", ".", "substring", "(", "start", ",", "pos", "--", ")", ",", "col", ")", ";", "col", "+=", "pos", "-", "start", ";", "}" ]
Parse a single line comment @param {string} css Unparsed part of CSS string
[ "Parse", "a", "single", "line", "comment" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/scss/tokenizer.js#L216-L231
15,917
tonyganch/gonzales-pe
src/scss/tokenizer.js
getTokens
function getTokens(css) { // Parse string, character by character: for (pos = 0; pos < css.length; col++, pos++) { c = css.charAt(pos); cn = css.charAt(pos + 1); // If we meet `/*`, it's a start of a multiline comment. // Parse following characters as a multiline comment: if (c === '/' && cn === '*') { parseMLComment(css); } // If we meet `//` and it is not a part of url: else if (!urlMode && c === '/' && cn === '/') { // If we're currently inside a block, treat `//` as a start // of identifier. Else treat `//` as a start of a single-line // comment: parseSLComment(css); } // If current character is a double or single quote, it's a start // of a string: else if (c === '"' || c === "'") { parseString(css, c); } // If current character is a space: else if (c === ' ') { parseSpaces(css); } // If current character is `=`, it must be combined with next `=` else if (c === '=' && cn === '=') { parseEquality(css); } // If we meet `!=`, this must be inequality else if (c === '!' && cn === '=') { parseInequality(css); } // If current character is a punctuation mark: else if (c in Punctuation) { // Check for CRLF here or just LF if (c === '\r' && cn === '\n' || c === '\n') { // If \r we know the next character is \n due to statement above // so we push a CRLF token type to the token list and importantly // skip the next character so as not to double count newlines or // columns etc if (c === '\r') { pushToken(TokenType.Newline, '\r\n', col); pos++; // If CRLF skip the next character and push crlf token } else if (c === '\n') { // If just a LF newline and not part of CRLF newline we can just // push punctuation as usual pushToken(Punctuation[c], c, col); } ln++; // Go to next line col = 0; // Reset the column count } else if (c !== '\r' && c !== '\n') { // Handle all other punctuation and add to list of tokens pushToken(Punctuation[c], c, col); }// Go to next line if (c === ')') urlMode = false; // Exit url mode else if (c === '\t' && tabSize > 1) col += (tabSize - 1); } // If current character is a decimal digit: else if (isDecimalDigit(c)) { parseDecimalNumber(css); } // If current character is anything else: else { parseIdentifier(css); } } return tokens; }
javascript
function getTokens(css) { // Parse string, character by character: for (pos = 0; pos < css.length; col++, pos++) { c = css.charAt(pos); cn = css.charAt(pos + 1); // If we meet `/*`, it's a start of a multiline comment. // Parse following characters as a multiline comment: if (c === '/' && cn === '*') { parseMLComment(css); } // If we meet `//` and it is not a part of url: else if (!urlMode && c === '/' && cn === '/') { // If we're currently inside a block, treat `//` as a start // of identifier. Else treat `//` as a start of a single-line // comment: parseSLComment(css); } // If current character is a double or single quote, it's a start // of a string: else if (c === '"' || c === "'") { parseString(css, c); } // If current character is a space: else if (c === ' ') { parseSpaces(css); } // If current character is `=`, it must be combined with next `=` else if (c === '=' && cn === '=') { parseEquality(css); } // If we meet `!=`, this must be inequality else if (c === '!' && cn === '=') { parseInequality(css); } // If current character is a punctuation mark: else if (c in Punctuation) { // Check for CRLF here or just LF if (c === '\r' && cn === '\n' || c === '\n') { // If \r we know the next character is \n due to statement above // so we push a CRLF token type to the token list and importantly // skip the next character so as not to double count newlines or // columns etc if (c === '\r') { pushToken(TokenType.Newline, '\r\n', col); pos++; // If CRLF skip the next character and push crlf token } else if (c === '\n') { // If just a LF newline and not part of CRLF newline we can just // push punctuation as usual pushToken(Punctuation[c], c, col); } ln++; // Go to next line col = 0; // Reset the column count } else if (c !== '\r' && c !== '\n') { // Handle all other punctuation and add to list of tokens pushToken(Punctuation[c], c, col); }// Go to next line if (c === ')') urlMode = false; // Exit url mode else if (c === '\t' && tabSize > 1) col += (tabSize - 1); } // If current character is a decimal digit: else if (isDecimalDigit(c)) { parseDecimalNumber(css); } // If current character is anything else: else { parseIdentifier(css); } } return tokens; }
[ "function", "getTokens", "(", "css", ")", "{", "// Parse string, character by character:", "for", "(", "pos", "=", "0", ";", "pos", "<", "css", ".", "length", ";", "col", "++", ",", "pos", "++", ")", "{", "c", "=", "css", ".", "charAt", "(", "pos", ")", ";", "cn", "=", "css", ".", "charAt", "(", "pos", "+", "1", ")", ";", "// If we meet `/*`, it's a start of a multiline comment.", "// Parse following characters as a multiline comment:", "if", "(", "c", "===", "'/'", "&&", "cn", "===", "'*'", ")", "{", "parseMLComment", "(", "css", ")", ";", "}", "// If we meet `//` and it is not a part of url:", "else", "if", "(", "!", "urlMode", "&&", "c", "===", "'/'", "&&", "cn", "===", "'/'", ")", "{", "// If we're currently inside a block, treat `//` as a start", "// of identifier. Else treat `//` as a start of a single-line", "// comment:", "parseSLComment", "(", "css", ")", ";", "}", "// If current character is a double or single quote, it's a start", "// of a string:", "else", "if", "(", "c", "===", "'\"'", "||", "c", "===", "\"'\"", ")", "{", "parseString", "(", "css", ",", "c", ")", ";", "}", "// If current character is a space:", "else", "if", "(", "c", "===", "' '", ")", "{", "parseSpaces", "(", "css", ")", ";", "}", "// If current character is `=`, it must be combined with next `=`", "else", "if", "(", "c", "===", "'='", "&&", "cn", "===", "'='", ")", "{", "parseEquality", "(", "css", ")", ";", "}", "// If we meet `!=`, this must be inequality", "else", "if", "(", "c", "===", "'!'", "&&", "cn", "===", "'='", ")", "{", "parseInequality", "(", "css", ")", ";", "}", "// If current character is a punctuation mark:", "else", "if", "(", "c", "in", "Punctuation", ")", "{", "// Check for CRLF here or just LF", "if", "(", "c", "===", "'\\r'", "&&", "cn", "===", "'\\n'", "||", "c", "===", "'\\n'", ")", "{", "// If \\r we know the next character is \\n due to statement above", "// so we push a CRLF token type to the token list and importantly", "// skip the next character so as not to double count newlines or", "// columns etc", "if", "(", "c", "===", "'\\r'", ")", "{", "pushToken", "(", "TokenType", ".", "Newline", ",", "'\\r\\n'", ",", "col", ")", ";", "pos", "++", ";", "// If CRLF skip the next character and push crlf token", "}", "else", "if", "(", "c", "===", "'\\n'", ")", "{", "// If just a LF newline and not part of CRLF newline we can just", "// push punctuation as usual", "pushToken", "(", "Punctuation", "[", "c", "]", ",", "c", ",", "col", ")", ";", "}", "ln", "++", ";", "// Go to next line", "col", "=", "0", ";", "// Reset the column count", "}", "else", "if", "(", "c", "!==", "'\\r'", "&&", "c", "!==", "'\\n'", ")", "{", "// Handle all other punctuation and add to list of tokens", "pushToken", "(", "Punctuation", "[", "c", "]", ",", "c", ",", "col", ")", ";", "}", "// Go to next line", "if", "(", "c", "===", "')'", ")", "urlMode", "=", "false", ";", "// Exit url mode", "else", "if", "(", "c", "===", "'\\t'", "&&", "tabSize", ">", "1", ")", "col", "+=", "(", "tabSize", "-", "1", ")", ";", "}", "// If current character is a decimal digit:", "else", "if", "(", "isDecimalDigit", "(", "c", ")", ")", "{", "parseDecimalNumber", "(", "css", ")", ";", "}", "// If current character is anything else:", "else", "{", "parseIdentifier", "(", "css", ")", ";", "}", "}", "return", "tokens", ";", "}" ]
Convert a CSS string to a list of tokens @param {string} css CSS string @returns {Array} List of tokens @private
[ "Convert", "a", "CSS", "string", "to", "a", "list", "of", "tokens" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/scss/tokenizer.js#L239-L319
15,918
tonyganch/gonzales-pe
src/sass/parse.js
checkArgument
function checkArgument(i) { let l; if (l = checkBrackets(i)) tokens[i].argument_child = 1; else if (l = checkParentheses(i)) tokens[i].argument_child = 2; else if (l = checkSingleValueDeclaration(i)) tokens[i].argument_child = 3; else if (l = checkFunctionsList(i)) tokens[i].argument_child = 4; else if (l = checkFunction(i)) tokens[i].argument_child = 5; else if (l = checkVariablesList(i)) tokens[i].argument_child = 6; else if (l = checkVariable(i)) tokens[i].argument_child = 7; else if (l = checkSC(i)) tokens[i].argument_child = 8; else if (l = checkDelim(i)) tokens[i].argument_child = 9; else if (l = checkDeclDelim(i)) tokens[i].argument_child = 10; else if (l = checkString(i)) tokens[i].argument_child = 11; else if (l = checkPercentage(i)) tokens[i].argument_child = 12; else if (l = checkDimension(i)) tokens[i].argument_child = 13; else if (l = checkNumber(i)) tokens[i].argument_child = 14; else if (l = checkUri(i)) tokens[i].argument_child = 15; else if (l = checkInterpolation(i)) tokens[i].argument_child = 16; else if (l = checkIdent(i)) tokens[i].argument_child = 17; else if (l = checkVhash(i)) tokens[i].argument_child = 18; else if (l = checkCustomProperty(i)) tokens[i].argument_child = 19; else if (l = checkOperator(i)) tokens[i].argument_child = 20; else if (l = checkUnary(i)) tokens[i].argument_child = 21; else if (l = checkParentSelector(i)) tokens[i].argument_child = 22; else if (l = checkImportant(i)) tokens[i].argument_child = 23; else if (l = checkGlobal(i)) tokens[i].argument_child = 24; else if (l = checkDefault(i)) tokens[i].argument_child = 25; else if (l = checkOptional(i)) tokens[i].argument_child = 26; return l; }
javascript
function checkArgument(i) { let l; if (l = checkBrackets(i)) tokens[i].argument_child = 1; else if (l = checkParentheses(i)) tokens[i].argument_child = 2; else if (l = checkSingleValueDeclaration(i)) tokens[i].argument_child = 3; else if (l = checkFunctionsList(i)) tokens[i].argument_child = 4; else if (l = checkFunction(i)) tokens[i].argument_child = 5; else if (l = checkVariablesList(i)) tokens[i].argument_child = 6; else if (l = checkVariable(i)) tokens[i].argument_child = 7; else if (l = checkSC(i)) tokens[i].argument_child = 8; else if (l = checkDelim(i)) tokens[i].argument_child = 9; else if (l = checkDeclDelim(i)) tokens[i].argument_child = 10; else if (l = checkString(i)) tokens[i].argument_child = 11; else if (l = checkPercentage(i)) tokens[i].argument_child = 12; else if (l = checkDimension(i)) tokens[i].argument_child = 13; else if (l = checkNumber(i)) tokens[i].argument_child = 14; else if (l = checkUri(i)) tokens[i].argument_child = 15; else if (l = checkInterpolation(i)) tokens[i].argument_child = 16; else if (l = checkIdent(i)) tokens[i].argument_child = 17; else if (l = checkVhash(i)) tokens[i].argument_child = 18; else if (l = checkCustomProperty(i)) tokens[i].argument_child = 19; else if (l = checkOperator(i)) tokens[i].argument_child = 20; else if (l = checkUnary(i)) tokens[i].argument_child = 21; else if (l = checkParentSelector(i)) tokens[i].argument_child = 22; else if (l = checkImportant(i)) tokens[i].argument_child = 23; else if (l = checkGlobal(i)) tokens[i].argument_child = 24; else if (l = checkDefault(i)) tokens[i].argument_child = 25; else if (l = checkOptional(i)) tokens[i].argument_child = 26; return l; }
[ "function", "checkArgument", "(", "i", ")", "{", "let", "l", ";", "if", "(", "l", "=", "checkBrackets", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "1", ";", "else", "if", "(", "l", "=", "checkParentheses", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "2", ";", "else", "if", "(", "l", "=", "checkSingleValueDeclaration", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "3", ";", "else", "if", "(", "l", "=", "checkFunctionsList", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "4", ";", "else", "if", "(", "l", "=", "checkFunction", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "5", ";", "else", "if", "(", "l", "=", "checkVariablesList", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "6", ";", "else", "if", "(", "l", "=", "checkVariable", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "7", ";", "else", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "8", ";", "else", "if", "(", "l", "=", "checkDelim", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "9", ";", "else", "if", "(", "l", "=", "checkDeclDelim", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "10", ";", "else", "if", "(", "l", "=", "checkString", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "11", ";", "else", "if", "(", "l", "=", "checkPercentage", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "12", ";", "else", "if", "(", "l", "=", "checkDimension", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "13", ";", "else", "if", "(", "l", "=", "checkNumber", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "14", ";", "else", "if", "(", "l", "=", "checkUri", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "15", ";", "else", "if", "(", "l", "=", "checkInterpolation", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "16", ";", "else", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "17", ";", "else", "if", "(", "l", "=", "checkVhash", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "18", ";", "else", "if", "(", "l", "=", "checkCustomProperty", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "19", ";", "else", "if", "(", "l", "=", "checkOperator", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "20", ";", "else", "if", "(", "l", "=", "checkUnary", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "21", ";", "else", "if", "(", "l", "=", "checkParentSelector", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "22", ";", "else", "if", "(", "l", "=", "checkImportant", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "23", ";", "else", "if", "(", "l", "=", "checkGlobal", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "24", ";", "else", "if", "(", "l", "=", "checkDefault", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "25", ";", "else", "if", "(", "l", "=", "checkOptional", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "26", ";", "return", "l", ";", "}" ]
Checks if token is valid to be part of arguments list @param {number} i Token's index number @return {number} Length of argument
[ "Checks", "if", "token", "is", "valid", "to", "be", "part", "of", "arguments", "list" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L473-L504
15,919
tonyganch/gonzales-pe
src/sass/parse.js
getClass
function getClass() { const type = NodeType.ClassType; const token = tokens[pos]; const line = token.ln; const column = token.col; const end = token.classEnd; let content = []; // Skip `.` pos++; while (pos < end) { if (checkIdentOrInterpolation(pos)) { content = content.concat(getIdentOrInterpolation()); } else break; } return newNode(type, content, line, column); }
javascript
function getClass() { const type = NodeType.ClassType; const token = tokens[pos]; const line = token.ln; const column = token.col; const end = token.classEnd; let content = []; // Skip `.` pos++; while (pos < end) { if (checkIdentOrInterpolation(pos)) { content = content.concat(getIdentOrInterpolation()); } else break; } return newNode(type, content, line, column); }
[ "function", "getClass", "(", ")", "{", "const", "type", "=", "NodeType", ".", "ClassType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "end", "=", "token", ".", "classEnd", ";", "let", "content", "=", "[", "]", ";", "// Skip `.`", "pos", "++", ";", "while", "(", "pos", "<", "end", ")", "{", "if", "(", "checkIdentOrInterpolation", "(", "pos", ")", ")", "{", "content", "=", "content", ".", "concat", "(", "getIdentOrInterpolation", "(", ")", ")", ";", "}", "else", "break", ";", "}", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Gets node with a class selector. @return {!Node}
[ "Gets", "node", "with", "a", "class", "selector", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1285-L1303
15,920
tonyganch/gonzales-pe
src/sass/parse.js
getCommentSL
function getCommentSL() { const type = NodeType.CommentSLType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = tokens[pos++].value.substring(2); const end = !content ? [line, column + 1] : getLastPosition(content, line, column + 2); return newNode(type, content, line, column, end); }
javascript
function getCommentSL() { const type = NodeType.CommentSLType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = tokens[pos++].value.substring(2); const end = !content ? [line, column + 1] : getLastPosition(content, line, column + 2); return newNode(type, content, line, column, end); }
[ "function", "getCommentSL", "(", ")", "{", "const", "type", "=", "NodeType", ".", "CommentSLType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "tokens", "[", "pos", "++", "]", ".", "value", ".", "substring", "(", "2", ")", ";", "const", "end", "=", "!", "content", "?", "[", "line", ",", "column", "+", "1", "]", ":", "getLastPosition", "(", "content", ",", "line", ",", "column", "+", "2", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with a single-line comment. @return {Array} `['commentSL', x]` where `x` is comment's message (without `//`)
[ "Get", "node", "with", "a", "single", "-", "line", "comment", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1517-L1527
15,921
tonyganch/gonzales-pe
src/sass/parse.js
checkDeclDelim
function checkDeclDelim(i) { if (i >= tokensLength) return 0; return (tokens[i].type === TokenType.Newline || tokens[i].type === TokenType.Semicolon) ? 1 : 0; }
javascript
function checkDeclDelim(i) { if (i >= tokensLength) return 0; return (tokens[i].type === TokenType.Newline || tokens[i].type === TokenType.Semicolon) ? 1 : 0; }
[ "function", "checkDeclDelim", "(", "i", ")", "{", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "return", "(", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "Newline", "||", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "Semicolon", ")", "?", "1", ":", "0", ";", "}" ]
Check if token is a semicolon @param {number} i Token's index number @return {number} `1` if token is a semicolon, otherwise `0`
[ "Check", "if", "token", "is", "a", "semicolon" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1819-L1824
15,922
tonyganch/gonzales-pe
src/sass/parse.js
getDeclDelim
function getDeclDelim() { const type = NodeType.DeclDelimType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = '\n'; pos++; return newNode(type, content, line, column); }
javascript
function getDeclDelim() { const type = NodeType.DeclDelimType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = '\n'; pos++; return newNode(type, content, line, column); }
[ "function", "getDeclDelim", "(", ")", "{", "const", "type", "=", "NodeType", ".", "DeclDelimType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "'\\n'", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a semicolon @return {Array} `['declDelim']`
[ "Get", "node", "with", "a", "semicolon" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1830-L1840
15,923
tonyganch/gonzales-pe
src/sass/parse.js
getDefault
function getDefault() { const type = NodeType.DefaultType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = joinValues(pos, token.defaultEnd); pos = token.defaultEnd + 1; return newNode(type, content, line, column); }
javascript
function getDefault() { const type = NodeType.DefaultType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = joinValues(pos, token.defaultEnd); pos = token.defaultEnd + 1; return newNode(type, content, line, column); }
[ "function", "getDefault", "(", ")", "{", "const", "type", "=", "NodeType", ".", "DefaultType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "joinValues", "(", "pos", ",", "token", ".", "defaultEnd", ")", ";", "pos", "=", "token", ".", "defaultEnd", "+", "1", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a `!default` word @return {Array} `['default', sc]` where `sc` is optional whitespace
[ "Get", "node", "with", "a", "!default", "word" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1868-L1878
15,924
tonyganch/gonzales-pe
src/sass/parse.js
getDelim
function getDelim() { const type = NodeType.DelimType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = ','; pos++; return newNode(type, content, line, column); }
javascript
function getDelim() { const type = NodeType.DelimType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = ','; pos++; return newNode(type, content, line, column); }
[ "function", "getDelim", "(", ")", "{", "const", "type", "=", "NodeType", ".", "DelimType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "','", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a comma @return {Array} `['delim']`
[ "Get", "node", "with", "a", "comma" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1893-L1903
15,925
tonyganch/gonzales-pe
src/sass/parse.js
getDimension
function getDimension() { const type = NodeType.DimensionType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [ getNumber(), getUnit() ]; return newNode(type, content, line, column); }
javascript
function getDimension() { const type = NodeType.DimensionType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [ getNumber(), getUnit() ]; return newNode(type, content, line, column); }
[ "function", "getDimension", "(", ")", "{", "const", "type", "=", "NodeType", ".", "DimensionType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "[", "getNumber", "(", ")", ",", "getUnit", "(", ")", "]", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node of a number with dimension unit @return {Node}
[ "Get", "node", "of", "a", "number", "with", "dimension", "unit" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L1925-L1936
15,926
tonyganch/gonzales-pe
src/sass/parse.js
getFunctionsList
function getFunctionsList() { const type = NodeType.FunctionsListType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [getFunction()]; const end = getLastPosition(content, line, column, 3); // Skip `...`. pos += 3; return newNode(type, content, line, column, end); }
javascript
function getFunctionsList() { const type = NodeType.FunctionsListType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [getFunction()]; const end = getLastPosition(content, line, column, 3); // Skip `...`. pos += 3; return newNode(type, content, line, column, end); }
[ "function", "getFunctionsList", "(", ")", "{", "const", "type", "=", "NodeType", ".", "FunctionsListType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "[", "getFunction", "(", ")", "]", ";", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "3", ")", ";", "// Skip `...`.", "pos", "+=", "3", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with a functions list @returns {Array}
[ "Get", "node", "with", "a", "functions", "list" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L2134-L2146
15,927
tonyganch/gonzales-pe
src/sass/parse.js
getIdent
function getIdent() { const type = NodeType.IdentType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = joinValues(pos, tokens[pos].ident_last); pos = tokens[pos].ident_last + 1; return newNode(type, content, line, column); }
javascript
function getIdent() { const type = NodeType.IdentType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = joinValues(pos, tokens[pos].ident_last); pos = tokens[pos].ident_last + 1; return newNode(type, content, line, column); }
[ "function", "getIdent", "(", ")", "{", "const", "type", "=", "NodeType", ".", "IdentType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "joinValues", "(", "pos", ",", "tokens", "[", "pos", "]", ".", "ident_last", ")", ";", "pos", "=", "tokens", "[", "pos", "]", ".", "ident_last", "+", "1", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with an identifier @return {Array} `['ident', x]` where `x` is identifier's name
[ "Get", "node", "with", "an", "identifier" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L2226-L2236
15,928
tonyganch/gonzales-pe
src/sass/parse.js
checkImportant
function checkImportant(i) { const start = i; let l; if (i >= tokensLength || tokens[i++].type !== TokenType.ExclamationMark) return 0; if (l = checkSC(i)) i += l; if (tokens[i].value === 'important') { tokens[start].importantEnd = i; return i - start + 1; } else { return 0; } }
javascript
function checkImportant(i) { const start = i; let l; if (i >= tokensLength || tokens[i++].type !== TokenType.ExclamationMark) return 0; if (l = checkSC(i)) i += l; if (tokens[i].value === 'important') { tokens[start].importantEnd = i; return i - start + 1; } else { return 0; } }
[ "function", "checkImportant", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", "||", "tokens", "[", "i", "++", "]", ".", "type", "!==", "TokenType", ".", "ExclamationMark", ")", "return", "0", ";", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "i", "+=", "l", ";", "if", "(", "tokens", "[", "i", "]", ".", "value", "===", "'important'", ")", "{", "tokens", "[", "start", "]", ".", "importantEnd", "=", "i", ";", "return", "i", "-", "start", "+", "1", ";", "}", "else", "{", "return", "0", ";", "}", "}" ]
Check if token is part of `!important` word @param {number} i Token's index number @return {number}
[ "Check", "if", "token", "is", "part", "of", "!important", "word" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L2309-L2324
15,929
tonyganch/gonzales-pe
src/sass/parse.js
checkInclude
function checkInclude(i) { let l; if (i >= tokensLength) return 0; if (l = checkIncludeWithKeyframes1(i)) tokens[i].include_type = 9; else if (l = checkInclude1(i)) tokens[i].include_type = 1; else if (l = checkInclude2(i)) tokens[i].include_type = 2; else if (l = checkInclude3(i)) tokens[i].include_type = 3; else if (l = checkInclude4(i)) tokens[i].include_type = 4; else if (l = checkIncludeWithKeyframes2(i)) tokens[i].include_type = 10; else if (l = checkInclude5(i)) tokens[i].include_type = 5; else if (l = checkInclude6(i)) tokens[i].include_type = 6; else if (l = checkInclude7(i)) tokens[i].include_type = 7; else if (l = checkInclude8(i)) tokens[i].include_type = 8; return l; }
javascript
function checkInclude(i) { let l; if (i >= tokensLength) return 0; if (l = checkIncludeWithKeyframes1(i)) tokens[i].include_type = 9; else if (l = checkInclude1(i)) tokens[i].include_type = 1; else if (l = checkInclude2(i)) tokens[i].include_type = 2; else if (l = checkInclude3(i)) tokens[i].include_type = 3; else if (l = checkInclude4(i)) tokens[i].include_type = 4; else if (l = checkIncludeWithKeyframes2(i)) tokens[i].include_type = 10; else if (l = checkInclude5(i)) tokens[i].include_type = 5; else if (l = checkInclude6(i)) tokens[i].include_type = 6; else if (l = checkInclude7(i)) tokens[i].include_type = 7; else if (l = checkInclude8(i)) tokens[i].include_type = 8; return l; }
[ "function", "checkInclude", "(", "i", ")", "{", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "l", "=", "checkIncludeWithKeyframes1", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "9", ";", "else", "if", "(", "l", "=", "checkInclude1", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "1", ";", "else", "if", "(", "l", "=", "checkInclude2", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "2", ";", "else", "if", "(", "l", "=", "checkInclude3", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "3", ";", "else", "if", "(", "l", "=", "checkInclude4", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "4", ";", "else", "if", "(", "l", "=", "checkIncludeWithKeyframes2", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "10", ";", "else", "if", "(", "l", "=", "checkInclude5", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "5", ";", "else", "if", "(", "l", "=", "checkInclude6", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "6", ";", "else", "if", "(", "l", "=", "checkInclude7", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "7", ";", "else", "if", "(", "l", "=", "checkInclude8", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "8", ";", "return", "l", ";", "}" ]
Check if token is part of an included mixin (`@include` or `@extend` directive). @param {number} i Token's index number @return {number} Length of the included mixin
[ "Check", "if", "token", "is", "part", "of", "an", "included", "mixin", "(" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L2348-L2365
15,930
tonyganch/gonzales-pe
src/sass/parse.js
getInterpolation
function getInterpolation() { const type = NodeType.InterpolationType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; // Skip `#{`: pos += 2; while (pos < tokensLength && tokens[pos].type !== TokenType.RightCurlyBracket) { const body = getArgument(); if (typeof body.content === 'string') content.push(body); else content = content.concat(body); } const end = getLastPosition(content, line, column, 1); // Skip `}`: pos++; return newNode(type, content, line, column, end); }
javascript
function getInterpolation() { const type = NodeType.InterpolationType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; // Skip `#{`: pos += 2; while (pos < tokensLength && tokens[pos].type !== TokenType.RightCurlyBracket) { const body = getArgument(); if (typeof body.content === 'string') content.push(body); else content = content.concat(body); } const end = getLastPosition(content, line, column, 1); // Skip `}`: pos++; return newNode(type, content, line, column, end); }
[ "function", "getInterpolation", "(", ")", "{", "const", "type", "=", "NodeType", ".", "InterpolationType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "// Skip `#{`:", "pos", "+=", "2", ";", "while", "(", "pos", "<", "tokensLength", "&&", "tokens", "[", "pos", "]", ".", "type", "!==", "TokenType", ".", "RightCurlyBracket", ")", "{", "const", "body", "=", "getArgument", "(", ")", ";", "if", "(", "typeof", "body", ".", "content", "===", "'string'", ")", "content", ".", "push", "(", "body", ")", ";", "else", "content", "=", "content", ".", "concat", "(", "body", ")", ";", "}", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "1", ")", ";", "// Skip `}`:", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with an interpolated variable @return {Array} `['interpolation', x]`
[ "Get", "node", "with", "an", "interpolated", "variable" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L2896-L2919
15,931
tonyganch/gonzales-pe
src/sass/parse.js
checkKeyframesRule
function checkKeyframesRule(i) { const start = i; let l; if (i >= tokensLength) return 0; if (l = checkAtkeyword(i)) i += l; else return 0; const atruleName = joinValues2(i - l, l); if (atruleName.toLowerCase().indexOf('keyframes') === -1) return 0; if (l = checkSC(i)) i += l; else return 0; if (l = checkIdentOrInterpolation(i) || checkPseudoc(i)) i += l; else return 0; if (l = checkSC(i)) i += l; if (l = checkKeyframesBlocks(i)) i += l; else return 0; return i - start; }
javascript
function checkKeyframesRule(i) { const start = i; let l; if (i >= tokensLength) return 0; if (l = checkAtkeyword(i)) i += l; else return 0; const atruleName = joinValues2(i - l, l); if (atruleName.toLowerCase().indexOf('keyframes') === -1) return 0; if (l = checkSC(i)) i += l; else return 0; if (l = checkIdentOrInterpolation(i) || checkPseudoc(i)) i += l; else return 0; if (l = checkSC(i)) i += l; if (l = checkKeyframesBlocks(i)) i += l; else return 0; return i - start; }
[ "function", "checkKeyframesRule", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "l", "=", "checkAtkeyword", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "const", "atruleName", "=", "joinValues2", "(", "i", "-", "l", ",", "l", ")", ";", "if", "(", "atruleName", ".", "toLowerCase", "(", ")", ".", "indexOf", "(", "'keyframes'", ")", "===", "-", "1", ")", "return", "0", ";", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkIdentOrInterpolation", "(", "i", ")", "||", "checkPseudoc", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "i", "+=", "l", ";", "if", "(", "l", "=", "checkKeyframesBlocks", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of a @keyframes rule. @param {number} i Token's index number @return {number} Length of the @keyframes rule
[ "Check", "if", "token", "is", "part", "of", "a" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3018-L3042
15,932
tonyganch/gonzales-pe
src/sass/parse.js
checkKeyframesSelector
function checkKeyframesSelector(i) { const start = i; let l; if (i >= tokensLength) return 0; if (l = checkIdent(i)) { // Valid selectors are only `from` and `to`. const selector = joinValues2(i, l); if (selector !== 'from' && selector !== 'to') return 0; i += l; tokens[start].keyframesSelectorType = 1; } else if (l = checkPercentage(i)) { i += l; tokens[start].keyframesSelectorType = 2; } else if (l = checkInterpolation(i)) { i += l; tokens[start].keyframesSelectorType = 3; } else { return 0; } return i - start; }
javascript
function checkKeyframesSelector(i) { const start = i; let l; if (i >= tokensLength) return 0; if (l = checkIdent(i)) { // Valid selectors are only `from` and `to`. const selector = joinValues2(i, l); if (selector !== 'from' && selector !== 'to') return 0; i += l; tokens[start].keyframesSelectorType = 1; } else if (l = checkPercentage(i)) { i += l; tokens[start].keyframesSelectorType = 2; } else if (l = checkInterpolation(i)) { i += l; tokens[start].keyframesSelectorType = 3; } else { return 0; } return i - start; }
[ "function", "checkKeyframesSelector", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "{", "// Valid selectors are only `from` and `to`.", "const", "selector", "=", "joinValues2", "(", "i", ",", "l", ")", ";", "if", "(", "selector", "!==", "'from'", "&&", "selector", "!==", "'to'", ")", "return", "0", ";", "i", "+=", "l", ";", "tokens", "[", "start", "]", ".", "keyframesSelectorType", "=", "1", ";", "}", "else", "if", "(", "l", "=", "checkPercentage", "(", "i", ")", ")", "{", "i", "+=", "l", ";", "tokens", "[", "start", "]", ".", "keyframesSelectorType", "=", "2", ";", "}", "else", "if", "(", "l", "=", "checkInterpolation", "(", "i", ")", ")", "{", "i", "+=", "l", ";", "tokens", "[", "start", "]", ".", "keyframesSelectorType", "=", "3", ";", "}", "else", "{", "return", "0", ";", "}", "return", "i", "-", "start", ";", "}" ]
Check a single keyframe selector - `5%`, `from` etc @param {Number} i @return {Number}
[ "Check", "a", "single", "keyframe", "selector", "-", "5%", "from", "etc" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3076-L3100
15,933
tonyganch/gonzales-pe
src/sass/parse.js
getLoop
function getLoop() { const type = NodeType.LoopType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; content.push(getAtkeyword()); while (pos < tokensLength) { if (checkBlock(pos)) { content.push(getBlock()); break; } else if (checkVariable(pos)) content.push(getVariable()); else if (checkNumber(pos)) content.push(getNumber()); else if (checkInterpolation(pos)) content.push(getInterpolation()); else if (checkIdent(pos)) content.push(getIdent()); else if (checkOperator(pos)) content.push(getOperator()); else if (checkCombinator(pos)) content.push(getCombinator()); else if (checkSC(pos)) content = content.concat(getSC()); else if (checkString(pos)) content.push(getString()); } return newNode(type, content, line, column); }
javascript
function getLoop() { const type = NodeType.LoopType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; content.push(getAtkeyword()); while (pos < tokensLength) { if (checkBlock(pos)) { content.push(getBlock()); break; } else if (checkVariable(pos)) content.push(getVariable()); else if (checkNumber(pos)) content.push(getNumber()); else if (checkInterpolation(pos)) content.push(getInterpolation()); else if (checkIdent(pos)) content.push(getIdent()); else if (checkOperator(pos)) content.push(getOperator()); else if (checkCombinator(pos)) content.push(getCombinator()); else if (checkSC(pos)) content = content.concat(getSC()); else if (checkString(pos)) content.push(getString()); } return newNode(type, content, line, column); }
[ "function", "getLoop", "(", ")", "{", "const", "type", "=", "NodeType", ".", "LoopType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "content", ".", "push", "(", "getAtkeyword", "(", ")", ")", ";", "while", "(", "pos", "<", "tokensLength", ")", "{", "if", "(", "checkBlock", "(", "pos", ")", ")", "{", "content", ".", "push", "(", "getBlock", "(", ")", ")", ";", "break", ";", "}", "else", "if", "(", "checkVariable", "(", "pos", ")", ")", "content", ".", "push", "(", "getVariable", "(", ")", ")", ";", "else", "if", "(", "checkNumber", "(", "pos", ")", ")", "content", ".", "push", "(", "getNumber", "(", ")", ")", ";", "else", "if", "(", "checkInterpolation", "(", "pos", ")", ")", "content", ".", "push", "(", "getInterpolation", "(", ")", ")", ";", "else", "if", "(", "checkIdent", "(", "pos", ")", ")", "content", ".", "push", "(", "getIdent", "(", ")", ")", ";", "else", "if", "(", "checkOperator", "(", "pos", ")", ")", "content", ".", "push", "(", "getOperator", "(", ")", ")", ";", "else", "if", "(", "checkCombinator", "(", "pos", ")", ")", "content", ".", "push", "(", "getCombinator", "(", ")", ")", ";", "else", "if", "(", "checkSC", "(", "pos", ")", ")", "content", "=", "content", ".", "concat", "(", "getSC", "(", ")", ")", ";", "else", "if", "(", "checkString", "(", "pos", ")", ")", "content", ".", "push", "(", "getString", "(", ")", ")", ";", "}", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a loop. @return {Array} `['loop', x]`
[ "Get", "node", "with", "a", "loop", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3246-L3271
15,934
tonyganch/gonzales-pe
src/sass/parse.js
getNamespace
function getNamespace() { const type = NodeType.NamespaceType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = '|'; pos++; return newNode(type, content, line, column); }
javascript
function getNamespace() { const type = NodeType.NamespaceType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = '|'; pos++; return newNode(type, content, line, column); }
[ "function", "getNamespace", "(", ")", "{", "const", "type", "=", "NodeType", ".", "NamespaceType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "'|'", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a namespace sign @return {Array} `['namespace']`
[ "Get", "node", "with", "a", "namespace", "sign" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3433-L3443
15,935
tonyganch/gonzales-pe
src/sass/parse.js
checkNumber
function checkNumber(i) { if (i >= tokensLength) return 0; if (tokens[i].number_l) return tokens[i].number_l; // `10`: if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber && (!tokens[i + 1] || (tokens[i + 1] && tokens[i + 1].type !== TokenType.FullStop))) { tokens[i].number_l = 1; return 1; } // `10.`: if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop && (!tokens[i + 2] || (tokens[i + 2].type !== TokenType.DecimalNumber))) { tokens[i].number_l = 2; return 2; } // `.10`: if (i < tokensLength && tokens[i].type === TokenType.FullStop && tokens[i + 1].type === TokenType.DecimalNumber) { tokens[i].number_l = 2; return 2; } // `10.10`: if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop && tokens[i + 2] && tokens[i + 2].type === TokenType.DecimalNumber) { tokens[i].number_l = 3; return 3; } return 0; }
javascript
function checkNumber(i) { if (i >= tokensLength) return 0; if (tokens[i].number_l) return tokens[i].number_l; // `10`: if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber && (!tokens[i + 1] || (tokens[i + 1] && tokens[i + 1].type !== TokenType.FullStop))) { tokens[i].number_l = 1; return 1; } // `10.`: if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop && (!tokens[i + 2] || (tokens[i + 2].type !== TokenType.DecimalNumber))) { tokens[i].number_l = 2; return 2; } // `.10`: if (i < tokensLength && tokens[i].type === TokenType.FullStop && tokens[i + 1].type === TokenType.DecimalNumber) { tokens[i].number_l = 2; return 2; } // `10.10`: if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber && tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop && tokens[i + 2] && tokens[i + 2].type === TokenType.DecimalNumber) { tokens[i].number_l = 3; return 3; } return 0; }
[ "function", "checkNumber", "(", "i", ")", "{", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "tokens", "[", "i", "]", ".", "number_l", ")", "return", "tokens", "[", "i", "]", ".", "number_l", ";", "// `10`:", "if", "(", "i", "<", "tokensLength", "&&", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "DecimalNumber", "&&", "(", "!", "tokens", "[", "i", "+", "1", "]", "||", "(", "tokens", "[", "i", "+", "1", "]", "&&", "tokens", "[", "i", "+", "1", "]", ".", "type", "!==", "TokenType", ".", "FullStop", ")", ")", ")", "{", "tokens", "[", "i", "]", ".", "number_l", "=", "1", ";", "return", "1", ";", "}", "// `10.`:", "if", "(", "i", "<", "tokensLength", "&&", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "DecimalNumber", "&&", "tokens", "[", "i", "+", "1", "]", "&&", "tokens", "[", "i", "+", "1", "]", ".", "type", "===", "TokenType", ".", "FullStop", "&&", "(", "!", "tokens", "[", "i", "+", "2", "]", "||", "(", "tokens", "[", "i", "+", "2", "]", ".", "type", "!==", "TokenType", ".", "DecimalNumber", ")", ")", ")", "{", "tokens", "[", "i", "]", ".", "number_l", "=", "2", ";", "return", "2", ";", "}", "// `.10`:", "if", "(", "i", "<", "tokensLength", "&&", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "FullStop", "&&", "tokens", "[", "i", "+", "1", "]", ".", "type", "===", "TokenType", ".", "DecimalNumber", ")", "{", "tokens", "[", "i", "]", ".", "number_l", "=", "2", ";", "return", "2", ";", "}", "// `10.10`:", "if", "(", "i", "<", "tokensLength", "&&", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "DecimalNumber", "&&", "tokens", "[", "i", "+", "1", "]", "&&", "tokens", "[", "i", "+", "1", "]", ".", "type", "===", "TokenType", ".", "FullStop", "&&", "tokens", "[", "i", "+", "2", "]", "&&", "tokens", "[", "i", "+", "2", "]", ".", "type", "===", "TokenType", ".", "DecimalNumber", ")", "{", "tokens", "[", "i", "]", ".", "number_l", "=", "3", ";", "return", "3", ";", "}", "return", "0", ";", "}" ]
Check if token is part of a number @param {number} i Token's index number @return {number} Length of number
[ "Check", "if", "token", "is", "part", "of", "a", "number" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3476-L3516
15,936
tonyganch/gonzales-pe
src/sass/parse.js
getNumber
function getNumber() { const type = NodeType.NumberType; const token = tokens[pos]; const line = token.ln; const column = token.col; const l = tokens[pos].number_l; let content = ''; for (let j = 0; j < l; j++) { content += tokens[pos + j].value; } pos += l; return newNode(type, content, line, column); }
javascript
function getNumber() { const type = NodeType.NumberType; const token = tokens[pos]; const line = token.ln; const column = token.col; const l = tokens[pos].number_l; let content = ''; for (let j = 0; j < l; j++) { content += tokens[pos + j].value; } pos += l; return newNode(type, content, line, column); }
[ "function", "getNumber", "(", ")", "{", "const", "type", "=", "NodeType", ".", "NumberType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "l", "=", "tokens", "[", "pos", "]", ".", "number_l", ";", "let", "content", "=", "''", ";", "for", "(", "let", "j", "=", "0", ";", "j", "<", "l", ";", "j", "++", ")", "{", "content", "+=", "tokens", "[", "pos", "+", "j", "]", ".", "value", ";", "}", "pos", "+=", "l", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with number @return {Array} `['number', x]` where `x` is a number converted to string.
[ "Get", "node", "with", "number" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3523-L3538
15,937
tonyganch/gonzales-pe
src/sass/parse.js
getOperator
function getOperator() { const type = NodeType.OperatorType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = token.value; pos++; return newNode(type, content, line, column); }
javascript
function getOperator() { const type = NodeType.OperatorType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = token.value; pos++; return newNode(type, content, line, column); }
[ "function", "getOperator", "(", ")", "{", "const", "type", "=", "NodeType", ".", "OperatorType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "token", ".", "value", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with an operator @return {Array} `['operator', x]` where `x` is an operator converted to string.
[ "Get", "node", "with", "an", "operator" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3570-L3580
15,938
tonyganch/gonzales-pe
src/sass/parse.js
getParentSelector
function getParentSelector() { const type = NodeType.ParentSelectorType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = '&'; pos++; return newNode(type, content, line, column); }
javascript
function getParentSelector() { const type = NodeType.ParentSelectorType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = '&'; pos++; return newNode(type, content, line, column); }
[ "function", "getParentSelector", "(", ")", "{", "const", "type", "=", "NodeType", ".", "ParentSelectorType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "'&'", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a parent selector @return {Node}
[ "Get", "node", "with", "a", "parent", "selector" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3686-L3696
15,939
tonyganch/gonzales-pe
src/sass/parse.js
getPercentage
function getPercentage() { const type = NodeType.PercentageType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = getNumberOrInterpolation(); const end = getLastPosition(content, line, column, 1); // Skip `%`. pos++; return newNode(type, content, line, column, end); }
javascript
function getPercentage() { const type = NodeType.PercentageType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = getNumberOrInterpolation(); const end = getLastPosition(content, line, column, 1); // Skip `%`. pos++; return newNode(type, content, line, column, end); }
[ "function", "getPercentage", "(", ")", "{", "const", "type", "=", "NodeType", ".", "PercentageType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "getNumberOrInterpolation", "(", ")", ";", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "1", ")", ";", "// Skip `%`.", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get a percentage node that contains either a number or an interpolation @return {Object} The percentage node
[ "Get", "a", "percentage", "node", "that", "contains", "either", "a", "number", "or", "an", "interpolation" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3799-L3811
15,940
tonyganch/gonzales-pe
src/sass/parse.js
checkNumberOrInterpolation
function checkNumberOrInterpolation(i) { const start = i; let l; while (i < tokensLength) { if (l = checkInterpolation(i) || checkNumber(i)) i += l; else break; } return i - start; }
javascript
function checkNumberOrInterpolation(i) { const start = i; let l; while (i < tokensLength) { if (l = checkInterpolation(i) || checkNumber(i)) i += l; else break; } return i - start; }
[ "function", "checkNumberOrInterpolation", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "if", "(", "l", "=", "checkInterpolation", "(", "i", ")", "||", "checkNumber", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "break", ";", "}", "return", "i", "-", "start", ";", "}" ]
Check if token is a number or an interpolation @param {number} i Token's index number @return {number}
[ "Check", "if", "token", "is", "a", "number", "or", "an", "interpolation" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3818-L3828
15,941
tonyganch/gonzales-pe
src/sass/parse.js
getPlaceholder
function getPlaceholder() { const type = NodeType.PlaceholderType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; // Skip `%`. pos++; content = content.concat(getIdentOrInterpolation()); return newNode(type, content, line, column); }
javascript
function getPlaceholder() { const type = NodeType.PlaceholderType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; // Skip `%`. pos++; content = content.concat(getIdentOrInterpolation()); return newNode(type, content, line, column); }
[ "function", "getPlaceholder", "(", ")", "{", "const", "type", "=", "NodeType", ".", "PlaceholderType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "// Skip `%`.", "pos", "++", ";", "content", "=", "content", ".", "concat", "(", "getIdentOrInterpolation", "(", ")", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a placeholder selector @return {Array} `['placeholder', ['ident', x]]` where x is a placeholder's identifier (without `%`, e.g. `abc`).
[ "Get", "node", "with", "a", "placeholder", "selector" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L3876-L3889
15,942
tonyganch/gonzales-pe
src/sass/parse.js
checkCustomProperty
function checkCustomProperty(i) { const start = i; let l; if (i >= tokensLength) return 0; if (tokens[i].type !== TokenType.HyphenMinus || tokens[i + 1] && tokens[i + 1].type !== TokenType.HyphenMinus) return 0; // Skip `--` i += 2; if (l = checkIdentOrInterpolation(i)) i += l; else return 0; return i - start; }
javascript
function checkCustomProperty(i) { const start = i; let l; if (i >= tokensLength) return 0; if (tokens[i].type !== TokenType.HyphenMinus || tokens[i + 1] && tokens[i + 1].type !== TokenType.HyphenMinus) return 0; // Skip `--` i += 2; if (l = checkIdentOrInterpolation(i)) i += l; else return 0; return i - start; }
[ "function", "checkCustomProperty", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "HyphenMinus", "||", "tokens", "[", "i", "+", "1", "]", "&&", "tokens", "[", "i", "+", "1", "]", ".", "type", "!==", "TokenType", ".", "HyphenMinus", ")", "return", "0", ";", "// Skip `--`", "i", "+=", "2", ";", "if", "(", "l", "=", "checkIdentOrInterpolation", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of a custom property @param {Number} i Token's index number @return {Number} Length of the property
[ "Check", "if", "token", "is", "part", "of", "a", "custom", "property" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L4049-L4065
15,943
tonyganch/gonzales-pe
src/sass/parse.js
getCustomProperty
function getCustomProperty() { const type = NodeType.CustomPropertyType; const token = tokens[pos]; const line = token.ln; const column = token.col; // Skip `--` pos += 2; const content = getIdentOrInterpolation(); return newNode(type, content, line, column); }
javascript
function getCustomProperty() { const type = NodeType.CustomPropertyType; const token = tokens[pos]; const line = token.ln; const column = token.col; // Skip `--` pos += 2; const content = getIdentOrInterpolation(); return newNode(type, content, line, column); }
[ "function", "getCustomProperty", "(", ")", "{", "const", "type", "=", "NodeType", ".", "CustomPropertyType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "// Skip `--`", "pos", "+=", "2", ";", "const", "content", "=", "getIdentOrInterpolation", "(", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a custom property @return {Node}
[ "Get", "node", "with", "a", "custom", "property" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L4071-L4083
15,944
tonyganch/gonzales-pe
src/sass/parse.js
getPropertyDelim
function getPropertyDelim() { const type = NodeType.PropertyDelimType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = ':'; // Skip `:`. pos++; return newNode(type, content, line, column); }
javascript
function getPropertyDelim() { const type = NodeType.PropertyDelimType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = ':'; // Skip `:`. pos++; return newNode(type, content, line, column); }
[ "function", "getPropertyDelim", "(", ")", "{", "const", "type", "=", "NodeType", ".", "PropertyDelimType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "':'", ";", "// Skip `:`.", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a colon @return {Array} `['propertyDelim']`
[ "Get", "node", "with", "a", "colon" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L4098-L4109
15,945
tonyganch/gonzales-pe
src/sass/parse.js
getS
function getS() { const type = NodeType.SType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = joinValues(pos, tokens[pos].ws_last); pos = tokens[pos].ws_last + 1; return newNode(type, content, line, column); }
javascript
function getS() { const type = NodeType.SType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = joinValues(pos, tokens[pos].ws_last); pos = tokens[pos].ws_last + 1; return newNode(type, content, line, column); }
[ "function", "getS", "(", ")", "{", "const", "type", "=", "NodeType", ".", "SType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "joinValues", "(", "pos", ",", "tokens", "[", "pos", "]", ".", "ws_last", ")", ";", "pos", "=", "tokens", "[", "pos", "]", ".", "ws_last", "+", "1", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with spaces @return {Array} `['s', x]` where `x` is a string containing spaces
[ "Get", "node", "with", "spaces" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L4816-L4826
15,946
tonyganch/gonzales-pe
src/sass/parse.js
checkMultilineSC
function checkMultilineSC(i) { if (!tokens[i]) return 0; let l; let lsc = 0; while (i < tokensLength) { if (!(l = checkS(i)) && !(l = checkCommentML(i)) && !(l = checkCommentSL(i))) break; i += l; lsc += l; } return lsc || 0; }
javascript
function checkMultilineSC(i) { if (!tokens[i]) return 0; let l; let lsc = 0; while (i < tokensLength) { if (!(l = checkS(i)) && !(l = checkCommentML(i)) && !(l = checkCommentSL(i))) break; i += l; lsc += l; } return lsc || 0; }
[ "function", "checkMultilineSC", "(", "i", ")", "{", "if", "(", "!", "tokens", "[", "i", "]", ")", "return", "0", ";", "let", "l", ";", "let", "lsc", "=", "0", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "if", "(", "!", "(", "l", "=", "checkS", "(", "i", ")", ")", "&&", "!", "(", "l", "=", "checkCommentML", "(", "i", ")", ")", "&&", "!", "(", "l", "=", "checkCommentSL", "(", "i", ")", ")", ")", "break", ";", "i", "+=", "l", ";", "lsc", "+=", "l", ";", "}", "return", "lsc", "||", "0", ";", "}" ]
Check if token is a space, newline, or a comment. @param {number} i Token's index number @return {number} Number of similar (space, newline, or comment) tokens in a row starting with the given token.
[ "Check", "if", "token", "is", "a", "space", "newline", "or", "a", "comment", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L4834-L4850
15,947
tonyganch/gonzales-pe
src/sass/parse.js
getString
function getString() { const type = NodeType.StringType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = token.value; pos++; return newNode(type, content, line, column); }
javascript
function getString() { const type = NodeType.StringType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = token.value; pos++; return newNode(type, content, line, column); }
[ "function", "getString", "(", ")", "{", "const", "type", "=", "NodeType", ".", "StringType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "token", ".", "value", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get string's node @return {Array} `['string', x]` where `x` is a string (including quotes).
[ "Get", "string", "s", "node" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5003-L5013
15,948
tonyganch/gonzales-pe
src/sass/parse.js
getUnicodeRange
function getUnicodeRange() { const type = NodeType.UnicodeRangeType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; while (pos < tokensLength) { if (checkSC(pos)) content = content.concat(getSC()); else if (checkDelim(pos)) content.push(getDelim()); else if (checkUrange(pos)) content.push(getUrange()); else break; } return newNode(type, content, line, column); }
javascript
function getUnicodeRange() { const type = NodeType.UnicodeRangeType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; while (pos < tokensLength) { if (checkSC(pos)) content = content.concat(getSC()); else if (checkDelim(pos)) content.push(getDelim()); else if (checkUrange(pos)) content.push(getUrange()); else break; } return newNode(type, content, line, column); }
[ "function", "getUnicodeRange", "(", ")", "{", "const", "type", "=", "NodeType", ".", "UnicodeRangeType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "while", "(", "pos", "<", "tokensLength", ")", "{", "if", "(", "checkSC", "(", "pos", ")", ")", "content", "=", "content", ".", "concat", "(", "getSC", "(", ")", ")", ";", "else", "if", "(", "checkDelim", "(", "pos", ")", ")", "content", ".", "push", "(", "getDelim", "(", ")", ")", ";", "else", "if", "(", "checkUrange", "(", "pos", ")", ")", "content", ".", "push", "(", "getUrange", "(", ")", ")", ";", "else", "break", ";", "}", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get a unicode range node @return {Node}
[ "Get", "a", "unicode", "range", "node" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5197-L5212
15,949
tonyganch/gonzales-pe
src/sass/parse.js
getUnit
function getUnit() { const type = NodeType.IdentType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = token.value; pos++; return newNode(type, content, line, column); }
javascript
function getUnit() { const type = NodeType.IdentType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = token.value; pos++; return newNode(type, content, line, column); }
[ "function", "getUnit", "(", ")", "{", "const", "type", "=", "NodeType", ".", "IdentType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "token", ".", "value", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get unit node of type ident @return {Node} An ident node containing the unit value
[ "Get", "unit", "node", "of", "type", "ident" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5237-L5247
15,950
tonyganch/gonzales-pe
src/sass/parse.js
_checkUnicodeWildcard
function _checkUnicodeWildcard(i) { const start = i; if (i >= tokensLength) return 0; while (i < tokensLength) { if (tokens[i].type === TokenType.QuestionMark) i += 1; else break; } return i - start; }
javascript
function _checkUnicodeWildcard(i) { const start = i; if (i >= tokensLength) return 0; while (i < tokensLength) { if (tokens[i].type === TokenType.QuestionMark) i += 1; else break; } return i - start; }
[ "function", "_checkUnicodeWildcard", "(", "i", ")", "{", "const", "start", "=", "i", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "if", "(", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "QuestionMark", ")", "i", "+=", "1", ";", "else", "break", ";", "}", "return", "i", "-", "start", ";", "}" ]
Check for unicode wildcard characters `?` @param {number} i Token's index @return {number} Wildcard length
[ "Check", "for", "unicode", "wildcard", "characters", "?" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5308-L5319
15,951
tonyganch/gonzales-pe
src/sass/parse.js
getUri
function getUri() { const startPos = pos; const type = NodeType.UriType; const token = tokens[startPos]; const line = token.ln; const column = token.col; let content = []; let end; const uriType = tokens[startPos].uriType; // Skip `url` and `(`. pos += 2; if (uriType === 1) content = content.concat(getUri1()); else if (uriType === 2) content = content.concat(getUri2()); else end = getLastPosition(content, line, column, 4); if (!end) end = getLastPosition(content, line, column, 1); // Skip `)`. pos++; return newNode(type, content, line, column, end); }
javascript
function getUri() { const startPos = pos; const type = NodeType.UriType; const token = tokens[startPos]; const line = token.ln; const column = token.col; let content = []; let end; const uriType = tokens[startPos].uriType; // Skip `url` and `(`. pos += 2; if (uriType === 1) content = content.concat(getUri1()); else if (uriType === 2) content = content.concat(getUri2()); else end = getLastPosition(content, line, column, 4); if (!end) end = getLastPosition(content, line, column, 1); // Skip `)`. pos++; return newNode(type, content, line, column, end); }
[ "function", "getUri", "(", ")", "{", "const", "startPos", "=", "pos", ";", "const", "type", "=", "NodeType", ".", "UriType", ";", "const", "token", "=", "tokens", "[", "startPos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "let", "end", ";", "const", "uriType", "=", "tokens", "[", "startPos", "]", ".", "uriType", ";", "// Skip `url` and `(`.", "pos", "+=", "2", ";", "if", "(", "uriType", "===", "1", ")", "content", "=", "content", ".", "concat", "(", "getUri1", "(", ")", ")", ";", "else", "if", "(", "uriType", "===", "2", ")", "content", "=", "content", ".", "concat", "(", "getUri2", "(", ")", ")", ";", "else", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "4", ")", ";", "if", "(", "!", "end", ")", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "1", ")", ";", "// Skip `)`.", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get specific type of URI node @return {Node} Specific type of URI node
[ "Get", "specific", "type", "of", "URI", "node" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5366-L5390
15,952
tonyganch/gonzales-pe
src/sass/parse.js
checkUriRawCharacters
function checkUriRawCharacters(i) { const start = i; let l; if (l = checkIdent(i)) i += l; else if (l = checkNumber(i)) i += l; else { switch (tokens[i].type) { case TokenType.ExclamationMark: case TokenType.NumberSign: case TokenType.DollarSign: case TokenType.PercentSign: case TokenType.Ampersand: case TokenType.Asterisk: case TokenType.PlusSign: case TokenType.Comma: case TokenType.HyphenMinus: case TokenType.FullStop: case TokenType.Solidus: case TokenType.Colon: case TokenType.Semicolon: case TokenType.LessThanSign: case TokenType.EqualsSign: case TokenType.GreaterThanSign: case TokenType.QuotationMark: case TokenType.CommercialAt: case TokenType.LeftSquareBracket: case TokenType.RightSquareBracket: case TokenType.CircumflexAccent: case TokenType.LowLine: case TokenType.LeftCurlyBracket: case TokenType.VerticalLine: case TokenType.RightCurlyBracket: case TokenType.Tilde: i += 1; break; default: return 0; } } return i - start; }
javascript
function checkUriRawCharacters(i) { const start = i; let l; if (l = checkIdent(i)) i += l; else if (l = checkNumber(i)) i += l; else { switch (tokens[i].type) { case TokenType.ExclamationMark: case TokenType.NumberSign: case TokenType.DollarSign: case TokenType.PercentSign: case TokenType.Ampersand: case TokenType.Asterisk: case TokenType.PlusSign: case TokenType.Comma: case TokenType.HyphenMinus: case TokenType.FullStop: case TokenType.Solidus: case TokenType.Colon: case TokenType.Semicolon: case TokenType.LessThanSign: case TokenType.EqualsSign: case TokenType.GreaterThanSign: case TokenType.QuotationMark: case TokenType.CommercialAt: case TokenType.LeftSquareBracket: case TokenType.RightSquareBracket: case TokenType.CircumflexAccent: case TokenType.LowLine: case TokenType.LeftCurlyBracket: case TokenType.VerticalLine: case TokenType.RightCurlyBracket: case TokenType.Tilde: i += 1; break; default: return 0; } } return i - start; }
[ "function", "checkUriRawCharacters", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "if", "(", "l", "=", "checkNumber", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "{", "switch", "(", "tokens", "[", "i", "]", ".", "type", ")", "{", "case", "TokenType", ".", "ExclamationMark", ":", "case", "TokenType", ".", "NumberSign", ":", "case", "TokenType", ".", "DollarSign", ":", "case", "TokenType", ".", "PercentSign", ":", "case", "TokenType", ".", "Ampersand", ":", "case", "TokenType", ".", "Asterisk", ":", "case", "TokenType", ".", "PlusSign", ":", "case", "TokenType", ".", "Comma", ":", "case", "TokenType", ".", "HyphenMinus", ":", "case", "TokenType", ".", "FullStop", ":", "case", "TokenType", ".", "Solidus", ":", "case", "TokenType", ".", "Colon", ":", "case", "TokenType", ".", "Semicolon", ":", "case", "TokenType", ".", "LessThanSign", ":", "case", "TokenType", ".", "EqualsSign", ":", "case", "TokenType", ".", "GreaterThanSign", ":", "case", "TokenType", ".", "QuotationMark", ":", "case", "TokenType", ".", "CommercialAt", ":", "case", "TokenType", ".", "LeftSquareBracket", ":", "case", "TokenType", ".", "RightSquareBracket", ":", "case", "TokenType", ".", "CircumflexAccent", ":", "case", "TokenType", ".", "LowLine", ":", "case", "TokenType", ".", "LeftCurlyBracket", ":", "case", "TokenType", ".", "VerticalLine", ":", "case", "TokenType", ".", "RightCurlyBracket", ":", "case", "TokenType", ".", "Tilde", ":", "i", "+=", "1", ";", "break", ";", "default", ":", "return", "0", ";", "}", "}", "return", "i", "-", "start", ";", "}" ]
Check if token type is valid URI character @param {number} i Token's index number @return {number} Length of raw node
[ "Check", "if", "token", "type", "is", "valid", "URI", "character" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5397-L5440
15,953
tonyganch/gonzales-pe
src/sass/parse.js
checkUriRaw
function checkUriRaw(i) { const start = i; let l; while (i < tokensLength) { if (checkInterpolation(i) || checkVariable(i)) break; else if (l = checkUriRawCharacters(i)) i += l; else break; } tokens[start].uri_raw_end = i; return i - start; }
javascript
function checkUriRaw(i) { const start = i; let l; while (i < tokensLength) { if (checkInterpolation(i) || checkVariable(i)) break; else if (l = checkUriRawCharacters(i)) i += l; else break; } tokens[start].uri_raw_end = i; return i - start; }
[ "function", "checkUriRaw", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "if", "(", "checkInterpolation", "(", "i", ")", "||", "checkVariable", "(", "i", ")", ")", "break", ";", "else", "if", "(", "l", "=", "checkUriRawCharacters", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "break", ";", "}", "tokens", "[", "start", "]", ".", "uri_raw_end", "=", "i", ";", "return", "i", "-", "start", ";", "}" ]
Check if content of URI can be contained within a raw node @param {number} i Token's index number @return {number} Length of raw node
[ "Check", "if", "content", "of", "URI", "can", "be", "contained", "within", "a", "raw", "node" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5447-L5460
15,954
tonyganch/gonzales-pe
src/sass/parse.js
getUriRaw
function getUriRaw() { const startPos = pos; const type = NodeType.RawType; const token = tokens[startPos]; const line = token.ln; const column = token.col; let content = []; let l; while (pos < tokens[startPos].uri_raw_end) { if (checkInterpolation(pos) || checkVariable(pos)) break; else if (l = checkUriRawCharacters(pos)) pos += l; else break; } content = joinValues(startPos, pos - 1); return newNode(type, content, line, column); }
javascript
function getUriRaw() { const startPos = pos; const type = NodeType.RawType; const token = tokens[startPos]; const line = token.ln; const column = token.col; let content = []; let l; while (pos < tokens[startPos].uri_raw_end) { if (checkInterpolation(pos) || checkVariable(pos)) break; else if (l = checkUriRawCharacters(pos)) pos += l; else break; } content = joinValues(startPos, pos - 1); return newNode(type, content, line, column); }
[ "function", "getUriRaw", "(", ")", "{", "const", "startPos", "=", "pos", ";", "const", "type", "=", "NodeType", ".", "RawType", ";", "const", "token", "=", "tokens", "[", "startPos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "let", "l", ";", "while", "(", "pos", "<", "tokens", "[", "startPos", "]", ".", "uri_raw_end", ")", "{", "if", "(", "checkInterpolation", "(", "pos", ")", "||", "checkVariable", "(", "pos", ")", ")", "break", ";", "else", "if", "(", "l", "=", "checkUriRawCharacters", "(", "pos", ")", ")", "pos", "+=", "l", ";", "else", "break", ";", "}", "content", "=", "joinValues", "(", "startPos", ",", "pos", "-", "1", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get a raw node @return {Node}
[ "Get", "a", "raw", "node" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5466-L5484
15,955
tonyganch/gonzales-pe
src/sass/parse.js
checkVariable
function checkVariable(i) { const start = i; let l; if (i >= tokensLength) return 0; // Skip `$`. if (tokens[i].type === TokenType.DollarSign) i++; else return 0; if (l = checkIdent(i)) i += l; else return 0; return i - start; }
javascript
function checkVariable(i) { const start = i; let l; if (i >= tokensLength) return 0; // Skip `$`. if (tokens[i].type === TokenType.DollarSign) i++; else return 0; if (l = checkIdent(i)) i += l; else return 0; return i - start; }
[ "function", "checkVariable", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "// Skip `$`.", "if", "(", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "DollarSign", ")", "i", "++", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of a variable @param {number} i Token's index number @return {number} Length of the variable
[ "Check", "if", "token", "is", "part", "of", "a", "variable" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5762-L5776
15,956
tonyganch/gonzales-pe
src/sass/parse.js
getVariablesList
function getVariablesList() { const type = NodeType.VariablesListType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [getVariable()]; const end = getLastPosition(content, line, column, 3); // Skip `...`. pos += 3; return newNode(type, content, line, column, end); }
javascript
function getVariablesList() { const type = NodeType.VariablesListType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [getVariable()]; const end = getLastPosition(content, line, column, 3); // Skip `...`. pos += 3; return newNode(type, content, line, column, end); }
[ "function", "getVariablesList", "(", ")", "{", "const", "type", "=", "NodeType", ".", "VariablesListType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "[", "getVariable", "(", ")", "]", ";", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "3", ")", ";", "// Skip `...`.", "pos", "+=", "3", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with a variables list @return {Array} `['variableslist', ['variable', ['ident', x]]]` where `x` is a variable name.
[ "Get", "node", "with", "a", "variables", "list" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5824-L5836
15,957
tonyganch/gonzales-pe
src/sass/parse.js
checkSelector1
function checkSelector1(i) { if (i >= tokensLength) return 0; const start = i; let l; if (l = checkCompoundSelector(i)) i += l; else return 0; while (i < tokensLength) { let space = checkSC(i); const comma = checkCombinator(i + space); if (!space && !comma) break; if (comma) { i += space + comma; space = checkSC(i); } if (l = checkCompoundSelector(i + space)) i += space + l; else break; } tokens[start].selectorEnd = i; return i - start; }
javascript
function checkSelector1(i) { if (i >= tokensLength) return 0; const start = i; let l; if (l = checkCompoundSelector(i)) i += l; else return 0; while (i < tokensLength) { let space = checkSC(i); const comma = checkCombinator(i + space); if (!space && !comma) break; if (comma) { i += space + comma; space = checkSC(i); } if (l = checkCompoundSelector(i + space)) i += space + l; else break; } tokens[start].selectorEnd = i; return i - start; }
[ "function", "checkSelector1", "(", "i", ")", "{", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "l", "=", "checkCompoundSelector", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "let", "space", "=", "checkSC", "(", "i", ")", ";", "const", "comma", "=", "checkCombinator", "(", "i", "+", "space", ")", ";", "if", "(", "!", "space", "&&", "!", "comma", ")", "break", ";", "if", "(", "comma", ")", "{", "i", "+=", "space", "+", "comma", ";", "space", "=", "checkSC", "(", "i", ")", ";", "}", "if", "(", "l", "=", "checkCompoundSelector", "(", "i", "+", "space", ")", ")", "i", "+=", "space", "+", "l", ";", "else", "break", ";", "}", "tokens", "[", "start", "]", ".", "selectorEnd", "=", "i", ";", "return", "i", "-", "start", ";", "}" ]
Checks for selector which starts with a compound selector.
[ "Checks", "for", "selector", "which", "starts", "with", "a", "compound", "selector", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5942-L5967
15,958
tonyganch/gonzales-pe
src/sass/parse.js
checkSelector2
function checkSelector2(i) { if (i >= tokensLength) return 0; const start = i; let l; if (l = checkCombinator(i)) i += l; else return 0; while (i < tokensLength) { const spaceBefore = checkSC(i); if (l = checkCompoundSelector(i + spaceBefore)) i += spaceBefore + l; else break; const spaceAfter = checkSC(i); const comma = checkCombinator(i + spaceAfter); if (!spaceAfter && !comma) break; if (comma) { i += spaceAfter + comma; } } tokens[start].selectorEnd = i; return i - start; }
javascript
function checkSelector2(i) { if (i >= tokensLength) return 0; const start = i; let l; if (l = checkCombinator(i)) i += l; else return 0; while (i < tokensLength) { const spaceBefore = checkSC(i); if (l = checkCompoundSelector(i + spaceBefore)) i += spaceBefore + l; else break; const spaceAfter = checkSC(i); const comma = checkCombinator(i + spaceAfter); if (!spaceAfter && !comma) break; if (comma) { i += spaceAfter + comma; } } tokens[start].selectorEnd = i; return i - start; }
[ "function", "checkSelector2", "(", "i", ")", "{", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "l", "=", "checkCombinator", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "const", "spaceBefore", "=", "checkSC", "(", "i", ")", ";", "if", "(", "l", "=", "checkCompoundSelector", "(", "i", "+", "spaceBefore", ")", ")", "i", "+=", "spaceBefore", "+", "l", ";", "else", "break", ";", "const", "spaceAfter", "=", "checkSC", "(", "i", ")", ";", "const", "comma", "=", "checkCombinator", "(", "i", "+", "spaceAfter", ")", ";", "if", "(", "!", "spaceAfter", "&&", "!", "comma", ")", "break", ";", "if", "(", "comma", ")", "{", "i", "+=", "spaceAfter", "+", "comma", ";", "}", "}", "tokens", "[", "start", "]", ".", "selectorEnd", "=", "i", ";", "return", "i", "-", "start", ";", "}" ]
Checks for a selector that starts with a combinator.
[ "Checks", "for", "a", "selector", "that", "starts", "with", "a", "combinator", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L5992-L6016
15,959
tonyganch/gonzales-pe
src/sass/parse.js
checkTypeSelector
function checkTypeSelector(i) { if (i >= tokensLength) return 0; const start = i; let l; if (l = checkNamePrefix(i)) i += l; if (l = checkIdentOrInterpolation(i)) i += l; else return 0; return i - start; }
javascript
function checkTypeSelector(i) { if (i >= tokensLength) return 0; const start = i; let l; if (l = checkNamePrefix(i)) i += l; if (l = checkIdentOrInterpolation(i)) i += l; else return 0; return i - start; }
[ "function", "checkTypeSelector", "(", "i", ")", "{", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "l", "=", "checkNamePrefix", "(", "i", ")", ")", "i", "+=", "l", ";", "if", "(", "l", "=", "checkIdentOrInterpolation", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of a type selector @param {number} i Token's index @return {number} Type selector's length
[ "Check", "if", "token", "is", "part", "of", "a", "type", "selector" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L6210-L6222
15,960
tonyganch/gonzales-pe
src/sass/parse.js
getTypeSelector
function getTypeSelector() { const type = NodeType.TypeSelectorType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; if (checkNamePrefix(pos)) content.push(getNamePrefix()); content = content.concat(getIdentOrInterpolation()); return newNode(type, content, line, column); }
javascript
function getTypeSelector() { const type = NodeType.TypeSelectorType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = []; if (checkNamePrefix(pos)) content.push(getNamePrefix()); content = content.concat(getIdentOrInterpolation()); return newNode(type, content, line, column); }
[ "function", "getTypeSelector", "(", ")", "{", "const", "type", "=", "NodeType", ".", "TypeSelectorType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "[", "]", ";", "if", "(", "checkNamePrefix", "(", "pos", ")", ")", "content", ".", "push", "(", "getNamePrefix", "(", ")", ")", ";", "content", "=", "content", ".", "concat", "(", "getIdentOrInterpolation", "(", ")", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get type selector node @return {Node}
[ "Get", "type", "selector", "node" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/sass/parse.js#L6228-L6240
15,961
tonyganch/gonzales-pe
src/less/parse.js
checkArgument
function checkArgument(i) { let l; if (l = checkEscapedString(i)) tokens[i].argument_child = 1; else if (l = checkDeclaration(i)) tokens[i].argument_child = 2; else if (l = checkVariablesList(i)) tokens[i].argument_child = 3; else if (l = checkVariable(i)) tokens[i].argument_child = 4; else if (l = checkSC(i)) tokens[i].argument_child = 5; else if (l = checkUnary(i)) tokens[i].argument_child = 6; else if (l = checkOperator(i)) tokens[i].argument_child = 7; else if (l = checkDelim(i)) tokens[i].argument_child = 8; else if (l = checkDeclDelim(i)) tokens[i].argument_child = 9; else if (l = checkString(i)) tokens[i].argument_child = 10; else if (l = checkPercentage(i)) tokens[i].argument_child = 11; else if (l = checkDimension(i)) tokens[i].argument_child = 12; else if (l = checkNumber(i)) tokens[i].argument_child = 13; else if (l = checkUri(i)) tokens[i].argument_child = 14; else if (l = checkFunction(i)) tokens[i].argument_child = 15; else if (l = checkIdent(i)) tokens[i].argument_child = 16; else if (l = checkVhash(i)) tokens[i].argument_child = 17; else if (l = checkBlock(i)) tokens[i].argument_child = 18; else if (l = checkParentheses(i)) tokens[i].argument_child = 19; return l; }
javascript
function checkArgument(i) { let l; if (l = checkEscapedString(i)) tokens[i].argument_child = 1; else if (l = checkDeclaration(i)) tokens[i].argument_child = 2; else if (l = checkVariablesList(i)) tokens[i].argument_child = 3; else if (l = checkVariable(i)) tokens[i].argument_child = 4; else if (l = checkSC(i)) tokens[i].argument_child = 5; else if (l = checkUnary(i)) tokens[i].argument_child = 6; else if (l = checkOperator(i)) tokens[i].argument_child = 7; else if (l = checkDelim(i)) tokens[i].argument_child = 8; else if (l = checkDeclDelim(i)) tokens[i].argument_child = 9; else if (l = checkString(i)) tokens[i].argument_child = 10; else if (l = checkPercentage(i)) tokens[i].argument_child = 11; else if (l = checkDimension(i)) tokens[i].argument_child = 12; else if (l = checkNumber(i)) tokens[i].argument_child = 13; else if (l = checkUri(i)) tokens[i].argument_child = 14; else if (l = checkFunction(i)) tokens[i].argument_child = 15; else if (l = checkIdent(i)) tokens[i].argument_child = 16; else if (l = checkVhash(i)) tokens[i].argument_child = 17; else if (l = checkBlock(i)) tokens[i].argument_child = 18; else if (l = checkParentheses(i)) tokens[i].argument_child = 19; return l; }
[ "function", "checkArgument", "(", "i", ")", "{", "let", "l", ";", "if", "(", "l", "=", "checkEscapedString", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "1", ";", "else", "if", "(", "l", "=", "checkDeclaration", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "2", ";", "else", "if", "(", "l", "=", "checkVariablesList", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "3", ";", "else", "if", "(", "l", "=", "checkVariable", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "4", ";", "else", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "5", ";", "else", "if", "(", "l", "=", "checkUnary", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "6", ";", "else", "if", "(", "l", "=", "checkOperator", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "7", ";", "else", "if", "(", "l", "=", "checkDelim", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "8", ";", "else", "if", "(", "l", "=", "checkDeclDelim", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "9", ";", "else", "if", "(", "l", "=", "checkString", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "10", ";", "else", "if", "(", "l", "=", "checkPercentage", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "11", ";", "else", "if", "(", "l", "=", "checkDimension", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "12", ";", "else", "if", "(", "l", "=", "checkNumber", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "13", ";", "else", "if", "(", "l", "=", "checkUri", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "14", ";", "else", "if", "(", "l", "=", "checkFunction", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "15", ";", "else", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "16", ";", "else", "if", "(", "l", "=", "checkVhash", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "17", ";", "else", "if", "(", "l", "=", "checkBlock", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "18", ";", "else", "if", "(", "l", "=", "checkParentheses", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "argument_child", "=", "19", ";", "return", "l", ";", "}" ]
Check if token is valid to be part of arguments list. @param {Number} i Token's index number @returns {Number}
[ "Check", "if", "token", "is", "valid", "to", "be", "part", "of", "arguments", "list", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L424-L448
15,962
tonyganch/gonzales-pe
src/less/parse.js
checkAtrule
function checkAtrule(i) { let l; if (i >= tokensLength) return 0; // If token already has a record of being part of an @-rule, // return the @-rule's length: if (tokens[i].atrule_l !== undefined) return tokens[i].atrule_l; // If token is part of an @-rule, save the rule's type to token. if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4; // @-rule with ruleset: else if (l = checkAtruler(i)) tokens[i].atrule_type = 1; // Block @-rule: else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2; // Single-line @-rule: else if (l = checkAtrules(i)) tokens[i].atrule_type = 3; else return 0; // If token is part of an @-rule, save the rule's length to token: tokens[i].atrule_l = l; return l; }
javascript
function checkAtrule(i) { let l; if (i >= tokensLength) return 0; // If token already has a record of being part of an @-rule, // return the @-rule's length: if (tokens[i].atrule_l !== undefined) return tokens[i].atrule_l; // If token is part of an @-rule, save the rule's type to token. if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4; // @-rule with ruleset: else if (l = checkAtruler(i)) tokens[i].atrule_type = 1; // Block @-rule: else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2; // Single-line @-rule: else if (l = checkAtrules(i)) tokens[i].atrule_type = 3; else return 0; // If token is part of an @-rule, save the rule's length to token: tokens[i].atrule_l = l; return l; }
[ "function", "checkAtrule", "(", "i", ")", "{", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "// If token already has a record of being part of an @-rule,", "// return the @-rule's length:", "if", "(", "tokens", "[", "i", "]", ".", "atrule_l", "!==", "undefined", ")", "return", "tokens", "[", "i", "]", ".", "atrule_l", ";", "// If token is part of an @-rule, save the rule's type to token.", "if", "(", "l", "=", "checkKeyframesRule", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "atrule_type", "=", "4", ";", "// @-rule with ruleset:", "else", "if", "(", "l", "=", "checkAtruler", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "atrule_type", "=", "1", ";", "// Block @-rule:", "else", "if", "(", "l", "=", "checkAtruleb", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "atrule_type", "=", "2", ";", "// Single-line @-rule:", "else", "if", "(", "l", "=", "checkAtrules", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "atrule_type", "=", "3", ";", "else", "return", "0", ";", "// If token is part of an @-rule, save the rule's length to token:", "tokens", "[", "i", "]", ".", "atrule_l", "=", "l", ";", "return", "l", ";", "}" ]
Check if token is a part of an @-rule @param {Number} i Token's index number @returns {Number} Length of @-rule
[ "Check", "if", "token", "is", "a", "part", "of", "an" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L517-L540
15,963
tonyganch/gonzales-pe
src/less/parse.js
checkAtruler
function checkAtruler(i) { const start = i; let l; if (i >= tokensLength) return 0; if (l = checkAtkeyword(i)) i += l; else return 0; if (l = checkTsets(i)) i += l; if (i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket) i++; else return 0; if (l = checkAtrulers(i)) i += l; if (i < tokensLength && tokens[i].type === TokenType.RightCurlyBracket) i++; else return 0; return i - start; }
javascript
function checkAtruler(i) { const start = i; let l; if (i >= tokensLength) return 0; if (l = checkAtkeyword(i)) i += l; else return 0; if (l = checkTsets(i)) i += l; if (i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket) i++; else return 0; if (l = checkAtrulers(i)) i += l; if (i < tokensLength && tokens[i].type === TokenType.RightCurlyBracket) i++; else return 0; return i - start; }
[ "function", "checkAtruler", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "l", "=", "checkAtkeyword", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkTsets", "(", "i", ")", ")", "i", "+=", "l", ";", "if", "(", "i", "<", "tokensLength", "&&", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "LeftCurlyBracket", ")", "i", "++", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkAtrulers", "(", "i", ")", ")", "i", "+=", "l", ";", "if", "(", "i", "<", "tokensLength", "&&", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "RightCurlyBracket", ")", "i", "++", ";", "else", "return", "0", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of an @-rule with ruleset @param {Number} i Token's index number @returns {Number} Length of the @-rule
[ "Check", "if", "token", "is", "part", "of", "an" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L600-L620
15,964
tonyganch/gonzales-pe
src/less/parse.js
getBlock
function getBlock() { const type = NodeType.BlockType; const token = tokens[pos]; const line = token.ln; const column = token.col; const end = tokens[pos].right; let content = []; // Skip `{`. pos++; while (pos < end) { if (checkBlockdecl(pos)) content = content.concat(getBlockdecl()); else throwError(pos); } const end_ = getLastPosition(content, line, column, 1); pos = end + 1; return newNode(type, content, line, column, end_); }
javascript
function getBlock() { const type = NodeType.BlockType; const token = tokens[pos]; const line = token.ln; const column = token.col; const end = tokens[pos].right; let content = []; // Skip `{`. pos++; while (pos < end) { if (checkBlockdecl(pos)) content = content.concat(getBlockdecl()); else throwError(pos); } const end_ = getLastPosition(content, line, column, 1); pos = end + 1; return newNode(type, content, line, column, end_); }
[ "function", "getBlock", "(", ")", "{", "const", "type", "=", "NodeType", ".", "BlockType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "end", "=", "tokens", "[", "pos", "]", ".", "right", ";", "let", "content", "=", "[", "]", ";", "// Skip `{`.", "pos", "++", ";", "while", "(", "pos", "<", "end", ")", "{", "if", "(", "checkBlockdecl", "(", "pos", ")", ")", "content", "=", "content", ".", "concat", "(", "getBlockdecl", "(", ")", ")", ";", "else", "throwError", "(", "pos", ")", ";", "}", "const", "end_", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "1", ")", ";", "pos", "=", "end", "+", "1", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end_", ")", ";", "}" ]
Get node with a block @returns {Array} `['block', x]`
[ "Get", "node", "with", "a", "block" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L748-L768
15,965
tonyganch/gonzales-pe
src/less/parse.js
getCommentML
function getCommentML() { const type = NodeType.CommentMLType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = tokens[pos].value.substring(2); const l = content.length; if (content.charAt(l - 2) === '*' && content.charAt(l - 1) === '/') content = content.substring(0, l - 2); const end = getLastPosition(content, line, column, 2); if (end[0] === line) end[1] += 2; pos++; return newNode(type, content, line, column, end); }
javascript
function getCommentML() { const type = NodeType.CommentMLType; const token = tokens[pos]; const line = token.ln; const column = token.col; let content = tokens[pos].value.substring(2); const l = content.length; if (content.charAt(l - 2) === '*' && content.charAt(l - 1) === '/') content = content.substring(0, l - 2); const end = getLastPosition(content, line, column, 2); if (end[0] === line) end[1] += 2; pos++; return newNode(type, content, line, column, end); }
[ "function", "getCommentML", "(", ")", "{", "const", "type", "=", "NodeType", ".", "CommentMLType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "let", "content", "=", "tokens", "[", "pos", "]", ".", "value", ".", "substring", "(", "2", ")", ";", "const", "l", "=", "content", ".", "length", ";", "if", "(", "content", ".", "charAt", "(", "l", "-", "2", ")", "===", "'*'", "&&", "content", ".", "charAt", "(", "l", "-", "1", ")", "===", "'/'", ")", "content", "=", "content", ".", "substring", "(", "0", ",", "l", "-", "2", ")", ";", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "2", ")", ";", "if", "(", "end", "[", "0", "]", "===", "line", ")", "end", "[", "1", "]", "+=", "2", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with a multiline comment @returns {Array} `['commentML', x]` where `x` is the comment's text (without `/*` and `* /`).
[ "Get", "node", "with", "a", "multiline", "comment" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1242-L1258
15,966
tonyganch/gonzales-pe
src/less/parse.js
checkCondition
function checkCondition(i) { const start = i; let l; if (i >= tokensLength) return 0; if ((l = checkIdent(i)) && tokens[i].value === 'when') i += l; else return 0; while (i < tokensLength) { if (l = checkBlock(i)) { tokens[i].condition_child = 0; break; } else if (l = checkFunction(i)) tokens[i].condition_child = 1; else if (l = checkBrackets(i)) tokens[i].condition_child = 2; else if (l = checkParentheses(i)) tokens[i].condition_child = 3; else if (l = checkVariable(i)) tokens[i].condition_child = 4; else if (l = checkIdent(i)) tokens[i].condition_child = 5; else if (l = checkNumber(i)) tokens[i].condition_child = 6; else if (l = checkDelim(i)) tokens[i].condition_child = 7; else if (l = checkOperator(i)) tokens[i].condition_child = 8; else if (l = checkCombinator(i)) tokens[i].condition_child = 9; else if (l = checkSC(i)) tokens[i].condition_child = 10; else if (l = checkString(i)) tokens[i].condition_child = 11; else return 0; i += l; } return i - start; }
javascript
function checkCondition(i) { const start = i; let l; if (i >= tokensLength) return 0; if ((l = checkIdent(i)) && tokens[i].value === 'when') i += l; else return 0; while (i < tokensLength) { if (l = checkBlock(i)) { tokens[i].condition_child = 0; break; } else if (l = checkFunction(i)) tokens[i].condition_child = 1; else if (l = checkBrackets(i)) tokens[i].condition_child = 2; else if (l = checkParentheses(i)) tokens[i].condition_child = 3; else if (l = checkVariable(i)) tokens[i].condition_child = 4; else if (l = checkIdent(i)) tokens[i].condition_child = 5; else if (l = checkNumber(i)) tokens[i].condition_child = 6; else if (l = checkDelim(i)) tokens[i].condition_child = 7; else if (l = checkOperator(i)) tokens[i].condition_child = 8; else if (l = checkCombinator(i)) tokens[i].condition_child = 9; else if (l = checkSC(i)) tokens[i].condition_child = 10; else if (l = checkString(i)) tokens[i].condition_child = 11; else return 0; i += l; } return i - start; }
[ "function", "checkCondition", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "&&", "tokens", "[", "i", "]", ".", "value", "===", "'when'", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "while", "(", "i", "<", "tokensLength", ")", "{", "if", "(", "l", "=", "checkBlock", "(", "i", ")", ")", "{", "tokens", "[", "i", "]", ".", "condition_child", "=", "0", ";", "break", ";", "}", "else", "if", "(", "l", "=", "checkFunction", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "1", ";", "else", "if", "(", "l", "=", "checkBrackets", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "2", ";", "else", "if", "(", "l", "=", "checkParentheses", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "3", ";", "else", "if", "(", "l", "=", "checkVariable", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "4", ";", "else", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "5", ";", "else", "if", "(", "l", "=", "checkNumber", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "6", ";", "else", "if", "(", "l", "=", "checkDelim", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "7", ";", "else", "if", "(", "l", "=", "checkOperator", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "8", ";", "else", "if", "(", "l", "=", "checkCombinator", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "9", ";", "else", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "10", ";", "else", "if", "(", "l", "=", "checkString", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "condition_child", "=", "11", ";", "else", "return", "0", ";", "i", "+=", "l", ";", "}", "return", "i", "-", "start", ";", "}" ]
Check if token is part of a condition. @param {Number} i Token's index number @return {Number} Length of the condition
[ "Check", "if", "token", "is", "part", "of", "a", "condition", "." ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1289-L1319
15,967
tonyganch/gonzales-pe
src/less/parse.js
getEscapedString
function getEscapedString() { const type = NodeType.EscapedStringType; const token = tokens[pos]; const line = token.ln; const column = token.col; pos++; const content = tokens[pos].value; const end = getLastPosition(content, line, column + 1); pos++; return newNode(type, content, line, column, end); }
javascript
function getEscapedString() { const type = NodeType.EscapedStringType; const token = tokens[pos]; const line = token.ln; const column = token.col; pos++; const content = tokens[pos].value; const end = getLastPosition(content, line, column + 1); pos++; return newNode(type, content, line, column, end); }
[ "function", "getEscapedString", "(", ")", "{", "const", "type", "=", "NodeType", ".", "EscapedStringType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "pos", "++", ";", "const", "content", "=", "tokens", "[", "pos", "]", ".", "value", ";", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", "+", "1", ")", ";", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with an escaped string @returns {Array} `['escapedString', ['string', x]]` where `x` is a string without `~` but with quotes
[ "Get", "node", "with", "an", "escaped", "string" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1506-L1520
15,968
tonyganch/gonzales-pe
src/less/parse.js
checkIdent
function checkIdent(i) { const start = i; if (i >= tokensLength) return 0; if (tokens[i].type === TokenType.HyphenMinus) i++; if (tokens[i].type === TokenType.LowLine || tokens[i].type === TokenType.Identifier) i++; else return 0; for (; i < tokensLength; i++) { if (tokens[i].type !== TokenType.HyphenMinus && tokens[i].type !== TokenType.LowLine && tokens[i].type !== TokenType.Identifier && tokens[i].type !== TokenType.DecimalNumber) break; } tokens[start].ident_last = i - 1; return i - start; }
javascript
function checkIdent(i) { const start = i; if (i >= tokensLength) return 0; if (tokens[i].type === TokenType.HyphenMinus) i++; if (tokens[i].type === TokenType.LowLine || tokens[i].type === TokenType.Identifier) i++; else return 0; for (; i < tokensLength; i++) { if (tokens[i].type !== TokenType.HyphenMinus && tokens[i].type !== TokenType.LowLine && tokens[i].type !== TokenType.Identifier && tokens[i].type !== TokenType.DecimalNumber) break; } tokens[start].ident_last = i - 1; return i - start; }
[ "function", "checkIdent", "(", "i", ")", "{", "const", "start", "=", "i", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "HyphenMinus", ")", "i", "++", ";", "if", "(", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "LowLine", "||", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "Identifier", ")", "i", "++", ";", "else", "return", "0", ";", "for", "(", ";", "i", "<", "tokensLength", ";", "i", "++", ")", "{", "if", "(", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "HyphenMinus", "&&", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "LowLine", "&&", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "Identifier", "&&", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "DecimalNumber", ")", "break", ";", "}", "tokens", "[", "start", "]", ".", "ident_last", "=", "i", "-", "1", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of an identifier @param {Number} i Token's index number @returns {Number} Length of the identifier
[ "Check", "if", "token", "is", "part", "of", "an", "identifier" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1707-L1728
15,969
tonyganch/gonzales-pe
src/less/parse.js
checkInclude
function checkInclude(i) { let l; if (i >= tokensLength) return 0; if (l = checkInclude1(i)) tokens[i].include_type = 1; else if (l = checkInclude2(i)) tokens[i].include_type = 2; return l; }
javascript
function checkInclude(i) { let l; if (i >= tokensLength) return 0; if (l = checkInclude1(i)) tokens[i].include_type = 1; else if (l = checkInclude2(i)) tokens[i].include_type = 2; return l; }
[ "function", "checkInclude", "(", "i", ")", "{", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "l", "=", "checkInclude1", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "1", ";", "else", "if", "(", "l", "=", "checkInclude2", "(", "i", ")", ")", "tokens", "[", "i", "]", ".", "include_type", "=", "2", ";", "return", "l", ";", "}" ]
Check if token is part of an include (`@include` or `@extend` directive). @param {Number} i Token's index number @returns {Number}
[ "Check", "if", "token", "is", "part", "of", "an", "include", "(" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1809-L1818
15,970
tonyganch/gonzales-pe
src/less/parse.js
checkInterpolatedVariable
function checkInterpolatedVariable(i) { const start = i; let l; if (i >= tokensLength) return 0; if (tokens[i].type !== TokenType.CommercialAt || !tokens[i + 1] || tokens[i + 1].type !== TokenType.LeftCurlyBracket) { return 0; } i += 2; if (l = checkIdent(i)) i += l; else return 0; return tokens[i].type === TokenType.RightCurlyBracket ? i - start + 1 : 0; }
javascript
function checkInterpolatedVariable(i) { const start = i; let l; if (i >= tokensLength) return 0; if (tokens[i].type !== TokenType.CommercialAt || !tokens[i + 1] || tokens[i + 1].type !== TokenType.LeftCurlyBracket) { return 0; } i += 2; if (l = checkIdent(i)) i += l; else return 0; return tokens[i].type === TokenType.RightCurlyBracket ? i - start + 1 : 0; }
[ "function", "checkInterpolatedVariable", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", ")", "return", "0", ";", "if", "(", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "CommercialAt", "||", "!", "tokens", "[", "i", "+", "1", "]", "||", "tokens", "[", "i", "+", "1", "]", ".", "type", "!==", "TokenType", ".", "LeftCurlyBracket", ")", "{", "return", "0", ";", "}", "i", "+=", "2", ";", "if", "(", "l", "=", "checkIdent", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "return", "tokens", "[", "i", "]", ".", "type", "===", "TokenType", ".", "RightCurlyBracket", "?", "i", "-", "start", "+", "1", ":", "0", ";", "}" ]
Check if token is part of LESS interpolated variable @param {Number} i Token's index number @returns {Number}
[ "Check", "if", "token", "is", "part", "of", "LESS", "interpolated", "variable" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1935-L1952
15,971
tonyganch/gonzales-pe
src/less/parse.js
getInterpolatedVariable
function getInterpolatedVariable() { const type = NodeType.InterpolatedVariableType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = []; // Skip `@{`: pos += 2; content.push(getIdent()); const end = getLastPosition(content, line, column, 1); // Skip `}`: pos++; return newNode(type, content, line, column, end); }
javascript
function getInterpolatedVariable() { const type = NodeType.InterpolatedVariableType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = []; // Skip `@{`: pos += 2; content.push(getIdent()); const end = getLastPosition(content, line, column, 1); // Skip `}`: pos++; return newNode(type, content, line, column, end); }
[ "function", "getInterpolatedVariable", "(", ")", "{", "const", "type", "=", "NodeType", ".", "InterpolatedVariableType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "[", "]", ";", "// Skip `@{`:", "pos", "+=", "2", ";", "content", ".", "push", "(", "getIdent", "(", ")", ")", ";", "const", "end", "=", "getLastPosition", "(", "content", ",", "line", ",", "column", ",", "1", ")", ";", "// Skip `}`:", "pos", "++", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with LESS interpolated variable @returns {Array} `['interpolatedVariable', x]`
[ "Get", "node", "with", "LESS", "interpolated", "variable" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L1958-L1976
15,972
tonyganch/gonzales-pe
src/less/parse.js
getUri
function getUri() { const startPos = pos; const uriExcluding = {}; let uri; let token; let l; let raw; pos += 2; uriExcluding[TokenType.Space] = 1; uriExcluding[TokenType.Tab] = 1; uriExcluding[TokenType.Newline] = 1; uriExcluding[TokenType.LeftParenthesis] = 1; uriExcluding[TokenType.RightParenthesis] = 1; if (checkUri1(pos)) { uri = [] .concat(getSC()) .concat([getString()]) .concat(getSC()); } else { uri = getSC(); l = checkExcluding(uriExcluding, pos); token = tokens[pos]; raw = newNode(NodeType.RawType, joinValues(pos, pos + l), token.ln, token.col); uri.push(raw); pos += l + 1; uri = uri.concat(getSC()); } token = tokens[startPos]; const line = token.ln; const column = token.col; const end = getLastPosition(uri, line, column, 1); pos++; return newNode(NodeType.UriType, uri, line, column, end); }
javascript
function getUri() { const startPos = pos; const uriExcluding = {}; let uri; let token; let l; let raw; pos += 2; uriExcluding[TokenType.Space] = 1; uriExcluding[TokenType.Tab] = 1; uriExcluding[TokenType.Newline] = 1; uriExcluding[TokenType.LeftParenthesis] = 1; uriExcluding[TokenType.RightParenthesis] = 1; if (checkUri1(pos)) { uri = [] .concat(getSC()) .concat([getString()]) .concat(getSC()); } else { uri = getSC(); l = checkExcluding(uriExcluding, pos); token = tokens[pos]; raw = newNode(NodeType.RawType, joinValues(pos, pos + l), token.ln, token.col); uri.push(raw); pos += l + 1; uri = uri.concat(getSC()); } token = tokens[startPos]; const line = token.ln; const column = token.col; const end = getLastPosition(uri, line, column, 1); pos++; return newNode(NodeType.UriType, uri, line, column, end); }
[ "function", "getUri", "(", ")", "{", "const", "startPos", "=", "pos", ";", "const", "uriExcluding", "=", "{", "}", ";", "let", "uri", ";", "let", "token", ";", "let", "l", ";", "let", "raw", ";", "pos", "+=", "2", ";", "uriExcluding", "[", "TokenType", ".", "Space", "]", "=", "1", ";", "uriExcluding", "[", "TokenType", ".", "Tab", "]", "=", "1", ";", "uriExcluding", "[", "TokenType", ".", "Newline", "]", "=", "1", ";", "uriExcluding", "[", "TokenType", ".", "LeftParenthesis", "]", "=", "1", ";", "uriExcluding", "[", "TokenType", ".", "RightParenthesis", "]", "=", "1", ";", "if", "(", "checkUri1", "(", "pos", ")", ")", "{", "uri", "=", "[", "]", ".", "concat", "(", "getSC", "(", ")", ")", ".", "concat", "(", "[", "getString", "(", ")", "]", ")", ".", "concat", "(", "getSC", "(", ")", ")", ";", "}", "else", "{", "uri", "=", "getSC", "(", ")", ";", "l", "=", "checkExcluding", "(", "uriExcluding", ",", "pos", ")", ";", "token", "=", "tokens", "[", "pos", "]", ";", "raw", "=", "newNode", "(", "NodeType", ".", "RawType", ",", "joinValues", "(", "pos", ",", "pos", "+", "l", ")", ",", "token", ".", "ln", ",", "token", ".", "col", ")", ";", "uri", ".", "push", "(", "raw", ")", ";", "pos", "+=", "l", "+", "1", ";", "uri", "=", "uri", ".", "concat", "(", "getSC", "(", ")", ")", ";", "}", "token", "=", "tokens", "[", "startPos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "end", "=", "getLastPosition", "(", "uri", ",", "line", ",", "column", ",", "1", ")", ";", "pos", "++", ";", "return", "newNode", "(", "NodeType", ".", "UriType", ",", "uri", ",", "line", ",", "column", ",", "end", ")", ";", "}" ]
Get node with URI @returns {Array} `['uri', x]` where `x` is URI's nodes (without `url` and braces, e.g. `['string', ''/css/styles.css'']`).
[ "Get", "node", "with", "URI" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L3847-L3889
15,973
tonyganch/gonzales-pe
src/less/parse.js
checkVariable
function checkVariable(i) { let l; if (i >= tokensLength || tokens[i].type !== TokenType.CommercialAt) return 0; if (tokens[i - 1] && tokens[i - 1].type === TokenType.CommercialAt && tokens[i - 2] && tokens[i - 2].type === TokenType.CommercialAt) return 0; return (l = checkVariable(i + 1) || checkIdent(i + 1)) ? l + 1 : 0; }
javascript
function checkVariable(i) { let l; if (i >= tokensLength || tokens[i].type !== TokenType.CommercialAt) return 0; if (tokens[i - 1] && tokens[i - 1].type === TokenType.CommercialAt && tokens[i - 2] && tokens[i - 2].type === TokenType.CommercialAt) return 0; return (l = checkVariable(i + 1) || checkIdent(i + 1)) ? l + 1 : 0; }
[ "function", "checkVariable", "(", "i", ")", "{", "let", "l", ";", "if", "(", "i", ">=", "tokensLength", "||", "tokens", "[", "i", "]", ".", "type", "!==", "TokenType", ".", "CommercialAt", ")", "return", "0", ";", "if", "(", "tokens", "[", "i", "-", "1", "]", "&&", "tokens", "[", "i", "-", "1", "]", ".", "type", "===", "TokenType", ".", "CommercialAt", "&&", "tokens", "[", "i", "-", "2", "]", "&&", "tokens", "[", "i", "-", "2", "]", ".", "type", "===", "TokenType", ".", "CommercialAt", ")", "return", "0", ";", "return", "(", "l", "=", "checkVariable", "(", "i", "+", "1", ")", "||", "checkIdent", "(", "i", "+", "1", ")", ")", "?", "l", "+", "1", ":", "0", ";", "}" ]
Check if token is part of LESS variable @param {Number} i Token's index number @returns {Number} Length of the variable
[ "Check", "if", "token", "is", "part", "of", "LESS", "variable" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L4008-L4019
15,974
tonyganch/gonzales-pe
src/less/parse.js
getVariable
function getVariable() { const type = NodeType.VariableType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = []; // Skip `$`. pos++; if (checkVariable(pos)) content.push(getVariable()); else content.push(getIdent()); return newNode(type, content, line, column); }
javascript
function getVariable() { const type = NodeType.VariableType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = []; // Skip `$`. pos++; if (checkVariable(pos)) content.push(getVariable()); else content.push(getIdent()); return newNode(type, content, line, column); }
[ "function", "getVariable", "(", ")", "{", "const", "type", "=", "NodeType", ".", "VariableType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "[", "]", ";", "// Skip `$`.", "pos", "++", ";", "if", "(", "checkVariable", "(", "pos", ")", ")", "content", ".", "push", "(", "getVariable", "(", ")", ")", ";", "else", "content", ".", "push", "(", "getIdent", "(", ")", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with a variable @returns {Array} `['variable', ['ident', x]]` where `x` is a variable name.
[ "Get", "node", "with", "a", "variable" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/less/parse.js#L4026-L4040
15,975
tonyganch/gonzales-pe
src/scss/parse.js
checkInclude3
function checkInclude3(i) { const start = i; let l; if (l = checkAtkeyword(i)) i += l; else return 0; if (tokens[start + 1].value !== 'include') return 0; if (l = checkSC(i)) i += l; else return 0; if (l = checkIdentOrInterpolation(i)) i += l; else return 0; if (l = checkSC(i)) i += l; if (l = checkArguments(i)) i += l; else return 0; return i - start; }
javascript
function checkInclude3(i) { const start = i; let l; if (l = checkAtkeyword(i)) i += l; else return 0; if (tokens[start + 1].value !== 'include') return 0; if (l = checkSC(i)) i += l; else return 0; if (l = checkIdentOrInterpolation(i)) i += l; else return 0; if (l = checkSC(i)) i += l; if (l = checkArguments(i)) i += l; else return 0; return i - start; }
[ "function", "checkInclude3", "(", "i", ")", "{", "const", "start", "=", "i", ";", "let", "l", ";", "if", "(", "l", "=", "checkAtkeyword", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "if", "(", "tokens", "[", "start", "+", "1", "]", ".", "value", "!==", "'include'", ")", "return", "0", ";", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkIdentOrInterpolation", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "if", "(", "l", "=", "checkSC", "(", "i", ")", ")", "i", "+=", "l", ";", "if", "(", "l", "=", "checkArguments", "(", "i", ")", ")", "i", "+=", "l", ";", "else", "return", "0", ";", "return", "i", "-", "start", ";", "}" ]
Check if token is part of an included mixin like `@include nani(foo)` @param {Number} i Token's index number @returns {Number} Length of the include
[ "Check", "if", "token", "is", "part", "of", "an", "included", "mixin", "like" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/scss/parse.js#L2239-L2260
15,976
tonyganch/gonzales-pe
src/scss/parse.js
getInclude3
function getInclude3() { const type = NodeType.IncludeType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [].concat( getAtkeyword(), getSC(), getIdentOrInterpolation(), getSC(), getArguments() ); return newNode(type, content, line, column); }
javascript
function getInclude3() { const type = NodeType.IncludeType; const token = tokens[pos]; const line = token.ln; const column = token.col; const content = [].concat( getAtkeyword(), getSC(), getIdentOrInterpolation(), getSC(), getArguments() ); return newNode(type, content, line, column); }
[ "function", "getInclude3", "(", ")", "{", "const", "type", "=", "NodeType", ".", "IncludeType", ";", "const", "token", "=", "tokens", "[", "pos", "]", ";", "const", "line", "=", "token", ".", "ln", ";", "const", "column", "=", "token", ".", "col", ";", "const", "content", "=", "[", "]", ".", "concat", "(", "getAtkeyword", "(", ")", ",", "getSC", "(", ")", ",", "getIdentOrInterpolation", "(", ")", ",", "getSC", "(", ")", ",", "getArguments", "(", ")", ")", ";", "return", "newNode", "(", "type", ",", "content", ",", "line", ",", "column", ")", ";", "}" ]
Get node with included mixin like `@include nani(foo)` @returns {Array} `['include', ['atkeyword', x], sc, ['selector', y], sc, ['arguments', z], sc]` where `x` is `include` or `extend`, `y` is mixin's identifier (selector), `z` are arguments passed to the mixin and `sc` are optional whitespaces
[ "Get", "node", "with", "included", "mixin", "like" ]
cb4be1c6c22184b525c6b7252823de834235a963
https://github.com/tonyganch/gonzales-pe/blob/cb4be1c6c22184b525c6b7252823de834235a963/src/scss/parse.js#L2269-L2283
15,977
azerion/phaser-spine
build/phaser-spine.js
function () { var bones = this.bones; var updateCache = this.cache; var ikConstraints = this.ikConstraints; var transformConstraints = this.transformConstraints; var ikConstraintsCount = ikConstraints.length; var transformConstraintsCount = transformConstraints.length; updateCache.length = 0; for (var i = 0, n = bones.length; i < n; i++) { var bone = bones[i]; updateCache[updateCache.length] = bone; for (var ii = 0; ii < ikConstraintsCount; ii++) { var ikConstraint = ikConstraints[ii]; if (bone == ikConstraint.bones[ikConstraint.bones.length - 1]) { updateCache[updateCache.length] = ikConstraint; break; } } } for (var i = 0; i < transformConstraintsCount; i++) { var transformConstraint = transformConstraints[i]; for (var ii = updateCache.length - 1; ii >= 0; ii--) { var object = updateCache[ii]; if (object == transformConstraint.bone || object == transformConstraint.target) { updateCache.splice(ii + 1, 0, transformConstraint); break; } } } }
javascript
function () { var bones = this.bones; var updateCache = this.cache; var ikConstraints = this.ikConstraints; var transformConstraints = this.transformConstraints; var ikConstraintsCount = ikConstraints.length; var transformConstraintsCount = transformConstraints.length; updateCache.length = 0; for (var i = 0, n = bones.length; i < n; i++) { var bone = bones[i]; updateCache[updateCache.length] = bone; for (var ii = 0; ii < ikConstraintsCount; ii++) { var ikConstraint = ikConstraints[ii]; if (bone == ikConstraint.bones[ikConstraint.bones.length - 1]) { updateCache[updateCache.length] = ikConstraint; break; } } } for (var i = 0; i < transformConstraintsCount; i++) { var transformConstraint = transformConstraints[i]; for (var ii = updateCache.length - 1; ii >= 0; ii--) { var object = updateCache[ii]; if (object == transformConstraint.bone || object == transformConstraint.target) { updateCache.splice(ii + 1, 0, transformConstraint); break; } } } }
[ "function", "(", ")", "{", "var", "bones", "=", "this", ".", "bones", ";", "var", "updateCache", "=", "this", ".", "cache", ";", "var", "ikConstraints", "=", "this", ".", "ikConstraints", ";", "var", "transformConstraints", "=", "this", ".", "transformConstraints", ";", "var", "ikConstraintsCount", "=", "ikConstraints", ".", "length", ";", "var", "transformConstraintsCount", "=", "transformConstraints", ".", "length", ";", "updateCache", ".", "length", "=", "0", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "bones", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "var", "bone", "=", "bones", "[", "i", "]", ";", "updateCache", "[", "updateCache", ".", "length", "]", "=", "bone", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "ikConstraintsCount", ";", "ii", "++", ")", "{", "var", "ikConstraint", "=", "ikConstraints", "[", "ii", "]", ";", "if", "(", "bone", "==", "ikConstraint", ".", "bones", "[", "ikConstraint", ".", "bones", ".", "length", "-", "1", "]", ")", "{", "updateCache", "[", "updateCache", ".", "length", "]", "=", "ikConstraint", ";", "break", ";", "}", "}", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "transformConstraintsCount", ";", "i", "++", ")", "{", "var", "transformConstraint", "=", "transformConstraints", "[", "i", "]", ";", "for", "(", "var", "ii", "=", "updateCache", ".", "length", "-", "1", ";", "ii", ">=", "0", ";", "ii", "--", ")", "{", "var", "object", "=", "updateCache", "[", "ii", "]", ";", "if", "(", "object", "==", "transformConstraint", ".", "bone", "||", "object", "==", "transformConstraint", ".", "target", ")", "{", "updateCache", ".", "splice", "(", "ii", "+", "1", ",", "0", ",", "transformConstraint", ")", ";", "break", ";", "}", "}", "}", "}" ]
Caches information about bones and constraints. Must be called if bones or constraints are added or removed.
[ "Caches", "information", "about", "bones", "and", "constraints", ".", "Must", "be", "called", "if", "bones", "or", "constraints", "are", "added", "or", "removed", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L1201-L1232
15,978
azerion/phaser-spine
build/phaser-spine.js
function () { var updateCache = this.cache; for (var i = 0, n = updateCache.length; i < n; i++) updateCache[i].update(); }
javascript
function () { var updateCache = this.cache; for (var i = 0, n = updateCache.length; i < n; i++) updateCache[i].update(); }
[ "function", "(", ")", "{", "var", "updateCache", "=", "this", ".", "cache", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "updateCache", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "updateCache", "[", "i", "]", ".", "update", "(", ")", ";", "}" ]
Updates the world transform for each bone and applies constraints.
[ "Updates", "the", "world", "transform", "for", "each", "bone", "and", "applies", "constraints", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L1234-L1238
15,979
azerion/phaser-spine
build/phaser-spine.js
function () { var bones = this.bones; for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); var ikConstraints = this.ikConstraints; for (var i = 0, n = ikConstraints.length; i < n; i++) { var constraint = ikConstraints[i]; constraint.bendDirection = constraint.data.bendDirection; constraint.mix = constraint.data.mix; } var transformConstraints = this.transformConstraints; for (var i = 0, n = transformConstraints.length; i < n; i++) { var constraint = transformConstraints[i]; constraint.translateMix = constraint.data.translateMix; constraint.x = constraint.data.x; constraint.y = constraint.data.y; } }
javascript
function () { var bones = this.bones; for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); var ikConstraints = this.ikConstraints; for (var i = 0, n = ikConstraints.length; i < n; i++) { var constraint = ikConstraints[i]; constraint.bendDirection = constraint.data.bendDirection; constraint.mix = constraint.data.mix; } var transformConstraints = this.transformConstraints; for (var i = 0, n = transformConstraints.length; i < n; i++) { var constraint = transformConstraints[i]; constraint.translateMix = constraint.data.translateMix; constraint.x = constraint.data.x; constraint.y = constraint.data.y; } }
[ "function", "(", ")", "{", "var", "bones", "=", "this", ".", "bones", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "bones", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "bones", "[", "i", "]", ".", "setToSetupPose", "(", ")", ";", "var", "ikConstraints", "=", "this", ".", "ikConstraints", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "ikConstraints", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "var", "constraint", "=", "ikConstraints", "[", "i", "]", ";", "constraint", ".", "bendDirection", "=", "constraint", ".", "data", ".", "bendDirection", ";", "constraint", ".", "mix", "=", "constraint", ".", "data", ".", "mix", ";", "}", "var", "transformConstraints", "=", "this", ".", "transformConstraints", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "transformConstraints", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "var", "constraint", "=", "transformConstraints", "[", "i", "]", ";", "constraint", ".", "translateMix", "=", "constraint", ".", "data", ".", "translateMix", ";", "constraint", ".", "x", "=", "constraint", ".", "data", ".", "x", ";", "constraint", ".", "y", "=", "constraint", ".", "data", ".", "y", ";", "}", "}" ]
Sets the bones and constraints to their setup pose values.
[ "Sets", "the", "bones", "and", "constraints", "to", "their", "setup", "pose", "values", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L1245-L1264
15,980
azerion/phaser-spine
build/phaser-spine.js
function (trackIndex, animation, loop) { var entry = new spine.TrackEntry(); entry.animation = animation; entry.loop = loop; entry.endTime = animation.duration; this.setCurrent(trackIndex, entry); return entry; }
javascript
function (trackIndex, animation, loop) { var entry = new spine.TrackEntry(); entry.animation = animation; entry.loop = loop; entry.endTime = animation.duration; this.setCurrent(trackIndex, entry); return entry; }
[ "function", "(", "trackIndex", ",", "animation", ",", "loop", ")", "{", "var", "entry", "=", "new", "spine", ".", "TrackEntry", "(", ")", ";", "entry", ".", "animation", "=", "animation", ";", "entry", ".", "loop", "=", "loop", ";", "entry", ".", "endTime", "=", "animation", ".", "duration", ";", "this", ".", "setCurrent", "(", "trackIndex", ",", "entry", ")", ";", "return", "entry", ";", "}" ]
Set the current animation. Any queued animations are cleared.
[ "Set", "the", "current", "animation", ".", "Any", "queued", "animations", "are", "cleared", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L1842-L1849
15,981
azerion/phaser-spine
build/phaser-spine.js
function (x, y) { return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; }
javascript
function (x, y) { return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; }
[ "function", "(", "x", ",", "y", ")", "{", "return", "x", ">=", "this", ".", "minX", "&&", "x", "<=", "this", ".", "maxX", "&&", "y", ">=", "this", ".", "minY", "&&", "y", "<=", "this", ".", "maxY", ";", "}" ]
Returns true if the axis aligned bounding box contains the point.
[ "Returns", "true", "if", "the", "axis", "aligned", "bounding", "box", "contains", "the", "point", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L2787-L2789
15,982
azerion/phaser-spine
build/phaser-spine.js
function (x1, y1, x2, y2) { var minX = this.minX, minY = this.minY, maxX = this.maxX, maxY = this.maxY; if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) return false; var m = (y2 - y1) / (x2 - x1); var y = m * (minX - x1) + y1; if (y > minY && y < maxY) return true; y = m * (maxX - x1) + y1; if (y > minY && y < maxY) return true; var x = (minY - y1) / m + x1; if (x > minX && x < maxX) return true; x = (maxY - y1) / m + x1; if (x > minX && x < maxX) return true; return false; }
javascript
function (x1, y1, x2, y2) { var minX = this.minX, minY = this.minY, maxX = this.maxX, maxY = this.maxY; if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) return false; var m = (y2 - y1) / (x2 - x1); var y = m * (minX - x1) + y1; if (y > minY && y < maxY) return true; y = m * (maxX - x1) + y1; if (y > minY && y < maxY) return true; var x = (minY - y1) / m + x1; if (x > minX && x < maxX) return true; x = (maxY - y1) / m + x1; if (x > minX && x < maxX) return true; return false; }
[ "function", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", "{", "var", "minX", "=", "this", ".", "minX", ",", "minY", "=", "this", ".", "minY", ",", "maxX", "=", "this", ".", "maxX", ",", "maxY", "=", "this", ".", "maxY", ";", "if", "(", "(", "x1", "<=", "minX", "&&", "x2", "<=", "minX", ")", "||", "(", "y1", "<=", "minY", "&&", "y2", "<=", "minY", ")", "||", "(", "x1", ">=", "maxX", "&&", "x2", ">=", "maxX", ")", "||", "(", "y1", ">=", "maxY", "&&", "y2", ">=", "maxY", ")", ")", "return", "false", ";", "var", "m", "=", "(", "y2", "-", "y1", ")", "/", "(", "x2", "-", "x1", ")", ";", "var", "y", "=", "m", "*", "(", "minX", "-", "x1", ")", "+", "y1", ";", "if", "(", "y", ">", "minY", "&&", "y", "<", "maxY", ")", "return", "true", ";", "y", "=", "m", "*", "(", "maxX", "-", "x1", ")", "+", "y1", ";", "if", "(", "y", ">", "minY", "&&", "y", "<", "maxY", ")", "return", "true", ";", "var", "x", "=", "(", "minY", "-", "y1", ")", "/", "m", "+", "x1", ";", "if", "(", "x", ">", "minX", "&&", "x", "<", "maxX", ")", "return", "true", ";", "x", "=", "(", "maxY", "-", "y1", ")", "/", "m", "+", "x1", ";", "if", "(", "x", ">", "minX", "&&", "x", "<", "maxX", ")", "return", "true", ";", "return", "false", ";", "}" ]
Returns true if the axis aligned bounding box intersects the line segment.
[ "Returns", "true", "if", "the", "axis", "aligned", "bounding", "box", "intersects", "the", "line", "segment", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L2791-L2805
15,983
azerion/phaser-spine
build/phaser-spine.js
function (bounds) { return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; }
javascript
function (bounds) { return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; }
[ "function", "(", "bounds", ")", "{", "return", "this", ".", "minX", "<", "bounds", ".", "maxX", "&&", "this", ".", "maxX", ">", "bounds", ".", "minX", "&&", "this", ".", "minY", "<", "bounds", ".", "maxY", "&&", "this", ".", "maxY", ">", "bounds", ".", "minY", ";", "}" ]
Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds.
[ "Returns", "true", "if", "the", "axis", "aligned", "bounding", "box", "intersects", "the", "axis", "aligned", "bounding", "box", "of", "the", "specified", "bounds", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L2807-L2809
15,984
azerion/phaser-spine
build/phaser-spine.js
function (polygon, x, y) { var nn = polygon.length; var prevIndex = nn - 2; var inside = false; for (var ii = 0; ii < nn; ii += 2) { var vertexY = polygon[ii + 1]; var prevY = polygon[prevIndex + 1]; if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { var vertexX = polygon[ii]; if (vertexX + (y - vertexY) / (prevY - vertexY) * (polygon[prevIndex] - vertexX) < x) inside = !inside; } prevIndex = ii; } return inside; }
javascript
function (polygon, x, y) { var nn = polygon.length; var prevIndex = nn - 2; var inside = false; for (var ii = 0; ii < nn; ii += 2) { var vertexY = polygon[ii + 1]; var prevY = polygon[prevIndex + 1]; if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { var vertexX = polygon[ii]; if (vertexX + (y - vertexY) / (prevY - vertexY) * (polygon[prevIndex] - vertexX) < x) inside = !inside; } prevIndex = ii; } return inside; }
[ "function", "(", "polygon", ",", "x", ",", "y", ")", "{", "var", "nn", "=", "polygon", ".", "length", ";", "var", "prevIndex", "=", "nn", "-", "2", ";", "var", "inside", "=", "false", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "nn", ";", "ii", "+=", "2", ")", "{", "var", "vertexY", "=", "polygon", "[", "ii", "+", "1", "]", ";", "var", "prevY", "=", "polygon", "[", "prevIndex", "+", "1", "]", ";", "if", "(", "(", "vertexY", "<", "y", "&&", "prevY", ">=", "y", ")", "||", "(", "prevY", "<", "y", "&&", "vertexY", ">=", "y", ")", ")", "{", "var", "vertexX", "=", "polygon", "[", "ii", "]", ";", "if", "(", "vertexX", "+", "(", "y", "-", "vertexY", ")", "/", "(", "prevY", "-", "vertexY", ")", "*", "(", "polygon", "[", "prevIndex", "]", "-", "vertexX", ")", "<", "x", ")", "inside", "=", "!", "inside", ";", "}", "prevIndex", "=", "ii", ";", "}", "return", "inside", ";", "}" ]
Returns true if the polygon contains the point.
[ "Returns", "true", "if", "the", "polygon", "contains", "the", "point", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L2827-L2841
15,985
azerion/phaser-spine
build/phaser-spine.js
function (polygon, x1, y1, x2, y2) { var nn = polygon.length; var width12 = x1 - x2, height12 = y1 - y2; var det1 = x1 * y2 - y1 * x2; var x3 = polygon[nn - 2], y3 = polygon[nn - 1]; for (var ii = 0; ii < nn; ii += 2) { var x4 = polygon[ii], y4 = polygon[ii + 1]; var det2 = x3 * y4 - y3 * x4; var width34 = x3 - x4, height34 = y3 - y4; var det3 = width12 * height34 - height12 * width34; var x = (det1 * width34 - width12 * det2) / det3; if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { var y = (det1 * height34 - height12 * det2) / det3; if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true; } x3 = x4; y3 = y4; } return false; }
javascript
function (polygon, x1, y1, x2, y2) { var nn = polygon.length; var width12 = x1 - x2, height12 = y1 - y2; var det1 = x1 * y2 - y1 * x2; var x3 = polygon[nn - 2], y3 = polygon[nn - 1]; for (var ii = 0; ii < nn; ii += 2) { var x4 = polygon[ii], y4 = polygon[ii + 1]; var det2 = x3 * y4 - y3 * x4; var width34 = x3 - x4, height34 = y3 - y4; var det3 = width12 * height34 - height12 * width34; var x = (det1 * width34 - width12 * det2) / det3; if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { var y = (det1 * height34 - height12 * det2) / det3; if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true; } x3 = x4; y3 = y4; } return false; }
[ "function", "(", "polygon", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", "{", "var", "nn", "=", "polygon", ".", "length", ";", "var", "width12", "=", "x1", "-", "x2", ",", "height12", "=", "y1", "-", "y2", ";", "var", "det1", "=", "x1", "*", "y2", "-", "y1", "*", "x2", ";", "var", "x3", "=", "polygon", "[", "nn", "-", "2", "]", ",", "y3", "=", "polygon", "[", "nn", "-", "1", "]", ";", "for", "(", "var", "ii", "=", "0", ";", "ii", "<", "nn", ";", "ii", "+=", "2", ")", "{", "var", "x4", "=", "polygon", "[", "ii", "]", ",", "y4", "=", "polygon", "[", "ii", "+", "1", "]", ";", "var", "det2", "=", "x3", "*", "y4", "-", "y3", "*", "x4", ";", "var", "width34", "=", "x3", "-", "x4", ",", "height34", "=", "y3", "-", "y4", ";", "var", "det3", "=", "width12", "*", "height34", "-", "height12", "*", "width34", ";", "var", "x", "=", "(", "det1", "*", "width34", "-", "width12", "*", "det2", ")", "/", "det3", ";", "if", "(", "(", "(", "x", ">=", "x3", "&&", "x", "<=", "x4", ")", "||", "(", "x", ">=", "x4", "&&", "x", "<=", "x3", ")", ")", "&&", "(", "(", "x", ">=", "x1", "&&", "x", "<=", "x2", ")", "||", "(", "x", ">=", "x2", "&&", "x", "<=", "x1", ")", ")", ")", "{", "var", "y", "=", "(", "det1", "*", "height34", "-", "height12", "*", "det2", ")", "/", "det3", ";", "if", "(", "(", "(", "y", ">=", "y3", "&&", "y", "<=", "y4", ")", "||", "(", "y", ">=", "y4", "&&", "y", "<=", "y3", ")", ")", "&&", "(", "(", "y", ">=", "y1", "&&", "y", "<=", "y2", ")", "||", "(", "y", ">=", "y2", "&&", "y", "<=", "y1", ")", ")", ")", "return", "true", ";", "}", "x3", "=", "x4", ";", "y3", "=", "y4", ";", "}", "return", "false", ";", "}" ]
Returns true if the polygon contains the line segment.
[ "Returns", "true", "if", "the", "polygon", "contains", "the", "line", "segment", "." ]
37c41fe880aae0d2721301dbd95a5ed73364143a
https://github.com/azerion/phaser-spine/blob/37c41fe880aae0d2721301dbd95a5ed73364143a/build/phaser-spine.js#L2843-L2862
15,986
arendjr/selectivity
src/inputs/multiple.js
MultipleInput
function MultipleInput(options) { Selectivity.call( this, assign( { // dropdowns for multiple-value inputs should open below the select box, // unless there is not enough space below, but there is space enough above, then it should // open upwards positionDropdown: function(el, selectEl) { var rect = selectEl.getBoundingClientRect(); var dropdownHeight = el.clientHeight; var openUpwards = rect.bottom + dropdownHeight > window.innerHeight && rect.top - dropdownHeight > 0; assign(el.style, { left: rect.left + 'px', top: (openUpwards ? rect.top - dropdownHeight : rect.bottom) + 'px', width: rect.width + 'px' }); }, showSearchInputInDropdown: false }, options ) ); this._reset(); var events = { change: this.rerenderSelection, click: this._clicked, 'selectivity-selected': this._resultSelected }; events['change ' + INPUT_SELECTOR] = stopPropagation; events['click ' + SELECTED_ITEM_SELECTOR] = this._itemClicked; events['click ' + SELECTED_ITEM_SELECTOR + '-remove'] = this._itemRemoveClicked; events['keydown ' + INPUT_SELECTOR] = this._keyHeld; events['keyup ' + INPUT_SELECTOR] = this._keyReleased; events['paste ' + INPUT_SELECTOR] = this._onPaste; this.events.on(events); }
javascript
function MultipleInput(options) { Selectivity.call( this, assign( { // dropdowns for multiple-value inputs should open below the select box, // unless there is not enough space below, but there is space enough above, then it should // open upwards positionDropdown: function(el, selectEl) { var rect = selectEl.getBoundingClientRect(); var dropdownHeight = el.clientHeight; var openUpwards = rect.bottom + dropdownHeight > window.innerHeight && rect.top - dropdownHeight > 0; assign(el.style, { left: rect.left + 'px', top: (openUpwards ? rect.top - dropdownHeight : rect.bottom) + 'px', width: rect.width + 'px' }); }, showSearchInputInDropdown: false }, options ) ); this._reset(); var events = { change: this.rerenderSelection, click: this._clicked, 'selectivity-selected': this._resultSelected }; events['change ' + INPUT_SELECTOR] = stopPropagation; events['click ' + SELECTED_ITEM_SELECTOR] = this._itemClicked; events['click ' + SELECTED_ITEM_SELECTOR + '-remove'] = this._itemRemoveClicked; events['keydown ' + INPUT_SELECTOR] = this._keyHeld; events['keyup ' + INPUT_SELECTOR] = this._keyReleased; events['paste ' + INPUT_SELECTOR] = this._onPaste; this.events.on(events); }
[ "function", "MultipleInput", "(", "options", ")", "{", "Selectivity", ".", "call", "(", "this", ",", "assign", "(", "{", "// dropdowns for multiple-value inputs should open below the select box,", "// unless there is not enough space below, but there is space enough above, then it should", "// open upwards", "positionDropdown", ":", "function", "(", "el", ",", "selectEl", ")", "{", "var", "rect", "=", "selectEl", ".", "getBoundingClientRect", "(", ")", ";", "var", "dropdownHeight", "=", "el", ".", "clientHeight", ";", "var", "openUpwards", "=", "rect", ".", "bottom", "+", "dropdownHeight", ">", "window", ".", "innerHeight", "&&", "rect", ".", "top", "-", "dropdownHeight", ">", "0", ";", "assign", "(", "el", ".", "style", ",", "{", "left", ":", "rect", ".", "left", "+", "'px'", ",", "top", ":", "(", "openUpwards", "?", "rect", ".", "top", "-", "dropdownHeight", ":", "rect", ".", "bottom", ")", "+", "'px'", ",", "width", ":", "rect", ".", "width", "+", "'px'", "}", ")", ";", "}", ",", "showSearchInputInDropdown", ":", "false", "}", ",", "options", ")", ")", ";", "this", ".", "_reset", "(", ")", ";", "var", "events", "=", "{", "change", ":", "this", ".", "rerenderSelection", ",", "click", ":", "this", ".", "_clicked", ",", "'selectivity-selected'", ":", "this", ".", "_resultSelected", "}", ";", "events", "[", "'change '", "+", "INPUT_SELECTOR", "]", "=", "stopPropagation", ";", "events", "[", "'click '", "+", "SELECTED_ITEM_SELECTOR", "]", "=", "this", ".", "_itemClicked", ";", "events", "[", "'click '", "+", "SELECTED_ITEM_SELECTOR", "+", "'-remove'", "]", "=", "this", ".", "_itemRemoveClicked", ";", "events", "[", "'keydown '", "+", "INPUT_SELECTOR", "]", "=", "this", ".", "_keyHeld", ";", "events", "[", "'keyup '", "+", "INPUT_SELECTOR", "]", "=", "this", ".", "_keyReleased", ";", "events", "[", "'paste '", "+", "INPUT_SELECTOR", "]", "=", "this", ".", "_onPaste", ";", "this", ".", "events", ".", "on", "(", "events", ")", ";", "}" ]
MultipleInput Constructor.
[ "MultipleInput", "Constructor", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/inputs/multiple.js#L26-L69
15,987
arendjr/selectivity
src/inputs/multiple.js
function(el, selectEl) { var rect = selectEl.getBoundingClientRect(); var dropdownHeight = el.clientHeight; var openUpwards = rect.bottom + dropdownHeight > window.innerHeight && rect.top - dropdownHeight > 0; assign(el.style, { left: rect.left + 'px', top: (openUpwards ? rect.top - dropdownHeight : rect.bottom) + 'px', width: rect.width + 'px' }); }
javascript
function(el, selectEl) { var rect = selectEl.getBoundingClientRect(); var dropdownHeight = el.clientHeight; var openUpwards = rect.bottom + dropdownHeight > window.innerHeight && rect.top - dropdownHeight > 0; assign(el.style, { left: rect.left + 'px', top: (openUpwards ? rect.top - dropdownHeight : rect.bottom) + 'px', width: rect.width + 'px' }); }
[ "function", "(", "el", ",", "selectEl", ")", "{", "var", "rect", "=", "selectEl", ".", "getBoundingClientRect", "(", ")", ";", "var", "dropdownHeight", "=", "el", ".", "clientHeight", ";", "var", "openUpwards", "=", "rect", ".", "bottom", "+", "dropdownHeight", ">", "window", ".", "innerHeight", "&&", "rect", ".", "top", "-", "dropdownHeight", ">", "0", ";", "assign", "(", "el", ".", "style", ",", "{", "left", ":", "rect", ".", "left", "+", "'px'", ",", "top", ":", "(", "openUpwards", "?", "rect", ".", "top", "-", "dropdownHeight", ":", "rect", ".", "bottom", ")", "+", "'px'", ",", "width", ":", "rect", ".", "width", "+", "'px'", "}", ")", ";", "}" ]
dropdowns for multiple-value inputs should open below the select box, unless there is not enough space below, but there is space enough above, then it should open upwards
[ "dropdowns", "for", "multiple", "-", "value", "inputs", "should", "open", "below", "the", "select", "box", "unless", "there", "is", "not", "enough", "space", "below", "but", "there", "is", "space", "enough", "above", "then", "it", "should", "open", "upwards" ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/inputs/multiple.js#L34-L46
15,988
arendjr/selectivity
src/inputs/multiple.js
function(item) { var itemIsId = Selectivity.isValidId(item); var id = itemIsId ? item : this.validateItem(item) && item.id; if (this.options.allowDuplicates || this._value.indexOf(id) === -1) { this._value.push(id); if (itemIsId && this.options.initSelection) { this.options.initSelection( [id], function(data) { if (this._value.indexOf(id) > -1) { item = this.validateItem(data[0]); this._data.push(item); this.triggerChange({ added: item }); } }.bind(this) ); } else { if (itemIsId) { item = this.getItemForId(id); } this._data.push(item); this.triggerChange({ added: item }); } } this.input.value = ''; this._updateInputWidth(); }
javascript
function(item) { var itemIsId = Selectivity.isValidId(item); var id = itemIsId ? item : this.validateItem(item) && item.id; if (this.options.allowDuplicates || this._value.indexOf(id) === -1) { this._value.push(id); if (itemIsId && this.options.initSelection) { this.options.initSelection( [id], function(data) { if (this._value.indexOf(id) > -1) { item = this.validateItem(data[0]); this._data.push(item); this.triggerChange({ added: item }); } }.bind(this) ); } else { if (itemIsId) { item = this.getItemForId(id); } this._data.push(item); this.triggerChange({ added: item }); } } this.input.value = ''; this._updateInputWidth(); }
[ "function", "(", "item", ")", "{", "var", "itemIsId", "=", "Selectivity", ".", "isValidId", "(", "item", ")", ";", "var", "id", "=", "itemIsId", "?", "item", ":", "this", ".", "validateItem", "(", "item", ")", "&&", "item", ".", "id", ";", "if", "(", "this", ".", "options", ".", "allowDuplicates", "||", "this", ".", "_value", ".", "indexOf", "(", "id", ")", "===", "-", "1", ")", "{", "this", ".", "_value", ".", "push", "(", "id", ")", ";", "if", "(", "itemIsId", "&&", "this", ".", "options", ".", "initSelection", ")", "{", "this", ".", "options", ".", "initSelection", "(", "[", "id", "]", ",", "function", "(", "data", ")", "{", "if", "(", "this", ".", "_value", ".", "indexOf", "(", "id", ")", ">", "-", "1", ")", "{", "item", "=", "this", ".", "validateItem", "(", "data", "[", "0", "]", ")", ";", "this", ".", "_data", ".", "push", "(", "item", ")", ";", "this", ".", "triggerChange", "(", "{", "added", ":", "item", "}", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ")", ";", "}", "else", "{", "if", "(", "itemIsId", ")", "{", "item", "=", "this", ".", "getItemForId", "(", "id", ")", ";", "}", "this", ".", "_data", ".", "push", "(", "item", ")", ";", "this", ".", "triggerChange", "(", "{", "added", ":", "item", "}", ")", ";", "}", "}", "this", ".", "input", ".", "value", "=", "''", ";", "this", ".", "_updateInputWidth", "(", ")", ";", "}" ]
Adds an item to the selection, if it's not selected yet. @param item The item to add. May be an item with 'id' and 'text' properties or just an ID.
[ "Adds", "an", "item", "to", "the", "selection", "if", "it", "s", "not", "selected", "yet", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/inputs/multiple.js#L80-L111
15,989
arendjr/selectivity
src/inputs/multiple.js
function(item) { var id = item.id || item; var removedItem; var index = Selectivity.findIndexById(this._data, id); if (index > -1) { removedItem = this._data[index]; this._data.splice(index, 1); } if (this._value[index] !== id) { index = this._value.indexOf(id); } if (index > -1) { this._value.splice(index, 1); } if (removedItem) { this.triggerChange({ removed: removedItem }); } if (id === this._highlightedItemId) { this._highlightedItemId = null; } this._updateInputWidth(); }
javascript
function(item) { var id = item.id || item; var removedItem; var index = Selectivity.findIndexById(this._data, id); if (index > -1) { removedItem = this._data[index]; this._data.splice(index, 1); } if (this._value[index] !== id) { index = this._value.indexOf(id); } if (index > -1) { this._value.splice(index, 1); } if (removedItem) { this.triggerChange({ removed: removedItem }); } if (id === this._highlightedItemId) { this._highlightedItemId = null; } this._updateInputWidth(); }
[ "function", "(", "item", ")", "{", "var", "id", "=", "item", ".", "id", "||", "item", ";", "var", "removedItem", ";", "var", "index", "=", "Selectivity", ".", "findIndexById", "(", "this", ".", "_data", ",", "id", ")", ";", "if", "(", "index", ">", "-", "1", ")", "{", "removedItem", "=", "this", ".", "_data", "[", "index", "]", ";", "this", ".", "_data", ".", "splice", "(", "index", ",", "1", ")", ";", "}", "if", "(", "this", ".", "_value", "[", "index", "]", "!==", "id", ")", "{", "index", "=", "this", ".", "_value", ".", "indexOf", "(", "id", ")", ";", "}", "if", "(", "index", ">", "-", "1", ")", "{", "this", ".", "_value", ".", "splice", "(", "index", ",", "1", ")", ";", "}", "if", "(", "removedItem", ")", "{", "this", ".", "triggerChange", "(", "{", "removed", ":", "removedItem", "}", ")", ";", "}", "if", "(", "id", "===", "this", ".", "_highlightedItemId", ")", "{", "this", ".", "_highlightedItemId", "=", "null", ";", "}", "this", ".", "_updateInputWidth", "(", ")", ";", "}" ]
Removes an item from the selection, if it is selected. @param item The item to remove. May be an item with 'id' and 'text' properties or just an ID.
[ "Removes", "an", "item", "from", "the", "selection", "if", "it", "is", "selected", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/inputs/multiple.js#L174-L200
15,990
arendjr/selectivity
src/inputs/multiple.js
function(data) { if (data === null) { return []; } else if (Array.isArray(data)) { return data.map(this.validateItem, this); } else { throw new Error('Data for MultiSelectivity instance should be an array'); } }
javascript
function(data) { if (data === null) { return []; } else if (Array.isArray(data)) { return data.map(this.validateItem, this); } else { throw new Error('Data for MultiSelectivity instance should be an array'); } }
[ "function", "(", "data", ")", "{", "if", "(", "data", "===", "null", ")", "{", "return", "[", "]", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "data", ")", ")", "{", "return", "data", ".", "map", "(", "this", ".", "validateItem", ",", "this", ")", ";", "}", "else", "{", "throw", "new", "Error", "(", "'Data for MultiSelectivity instance should be an array'", ")", ";", "}", "}" ]
Validates data to set. Throws an exception if the data is invalid. @param data The data to validate. Should be an array of objects with 'id' and 'text' properties. @return The validated data. This may differ from the input data.
[ "Validates", "data", "to", "set", ".", "Throws", "an", "exception", "if", "the", "data", "is", "invalid", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/inputs/multiple.js#L283-L291
15,991
arendjr/selectivity
src/inputs/multiple.js
function(value) { if (value === null) { return []; } else if (Array.isArray(value)) { if (value.every(Selectivity.isValidId)) { return value; } else { throw new Error('Value contains invalid IDs'); } } else { throw new Error('Value for MultiSelectivity instance should be an array'); } }
javascript
function(value) { if (value === null) { return []; } else if (Array.isArray(value)) { if (value.every(Selectivity.isValidId)) { return value; } else { throw new Error('Value contains invalid IDs'); } } else { throw new Error('Value for MultiSelectivity instance should be an array'); } }
[ "function", "(", "value", ")", "{", "if", "(", "value", "===", "null", ")", "{", "return", "[", "]", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "value", ")", ")", "{", "if", "(", "value", ".", "every", "(", "Selectivity", ".", "isValidId", ")", ")", "{", "return", "value", ";", "}", "else", "{", "throw", "new", "Error", "(", "'Value contains invalid IDs'", ")", ";", "}", "}", "else", "{", "throw", "new", "Error", "(", "'Value for MultiSelectivity instance should be an array'", ")", ";", "}", "}" ]
Validates a value to set. Throws an exception if the value is invalid. @param value The value to validate. Should be an array of IDs. @return The validated value. This may differ from the input value.
[ "Validates", "a", "value", "to", "set", ".", "Throws", "an", "exception", "if", "the", "value", "is", "invalid", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/inputs/multiple.js#L300-L312
15,992
arendjr/selectivity
src/event-listener.js
EventListener
function EventListener(el, context) { this.context = context || null; this.el = el; this.events = {}; this._onEvent = this._onEvent.bind(this); }
javascript
function EventListener(el, context) { this.context = context || null; this.el = el; this.events = {}; this._onEvent = this._onEvent.bind(this); }
[ "function", "EventListener", "(", "el", ",", "context", ")", "{", "this", ".", "context", "=", "context", "||", "null", ";", "this", ".", "el", "=", "el", ";", "this", ".", "events", "=", "{", "}", ";", "this", ".", "_onEvent", "=", "this", ".", "_onEvent", ".", "bind", "(", "this", ")", ";", "}" ]
Listens to events dispatched to an element or its children. @param el The element to listen to. @param context Optional context in which to execute the callbacks.
[ "Listens", "to", "events", "dispatched", "to", "an", "element", "or", "its", "children", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/event-listener.js#L16-L24
15,993
arendjr/selectivity
src/event-listener.js
function(eventName, selector, callback) { if (!isString(selector)) { callback = selector; selector = ''; } if (callback) { var events = this.events[eventName]; if (events) { events = events[selector]; if (events) { for (var i = 0; i < events.length; i++) { if (events[i] === callback) { events.splice(i, 1); i--; } } } } } else { this.events[eventName][selector] = []; } }
javascript
function(eventName, selector, callback) { if (!isString(selector)) { callback = selector; selector = ''; } if (callback) { var events = this.events[eventName]; if (events) { events = events[selector]; if (events) { for (var i = 0; i < events.length; i++) { if (events[i] === callback) { events.splice(i, 1); i--; } } } } } else { this.events[eventName][selector] = []; } }
[ "function", "(", "eventName", ",", "selector", ",", "callback", ")", "{", "if", "(", "!", "isString", "(", "selector", ")", ")", "{", "callback", "=", "selector", ";", "selector", "=", "''", ";", "}", "if", "(", "callback", ")", "{", "var", "events", "=", "this", ".", "events", "[", "eventName", "]", ";", "if", "(", "events", ")", "{", "events", "=", "events", "[", "selector", "]", ";", "if", "(", "events", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "events", ".", "length", ";", "i", "++", ")", "{", "if", "(", "events", "[", "i", "]", "===", "callback", ")", "{", "events", ".", "splice", "(", "i", ",", "1", ")", ";", "i", "--", ";", "}", "}", "}", "}", "}", "else", "{", "this", ".", "events", "[", "eventName", "]", "[", "selector", "]", "=", "[", "]", ";", "}", "}" ]
Stops listening to an event. The arguments are the same as for on(), but when no callback is given, all callbacks for the given event and class are discarded.
[ "Stops", "listening", "to", "an", "event", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/event-listener.js#L49-L71
15,994
arendjr/selectivity
src/event-listener.js
function(eventName, selector, callback) { if (!isString(eventName)) { var eventsMap = eventName; for (var key in eventsMap) { if (eventsMap.hasOwnProperty(key)) { var split = key.split(' '); if (split.length > 1) { this.on(split[0], split[1], eventsMap[key]); } else { this.on(split[0], eventsMap[key]); } } } return; } if (!isString(selector)) { callback = selector; selector = ''; } if (!this.events.hasOwnProperty(eventName)) { var useCapture = CAPTURED_EVENTS.indexOf(eventName) > -1; this.el.addEventListener(eventName, this._onEvent, useCapture); this.events[eventName] = {}; } if (!this.events[eventName].hasOwnProperty(selector)) { this.events[eventName][selector] = []; } if (this.events[eventName][selector].indexOf(callback) < 0) { this.events[eventName][selector].push(callback); } }
javascript
function(eventName, selector, callback) { if (!isString(eventName)) { var eventsMap = eventName; for (var key in eventsMap) { if (eventsMap.hasOwnProperty(key)) { var split = key.split(' '); if (split.length > 1) { this.on(split[0], split[1], eventsMap[key]); } else { this.on(split[0], eventsMap[key]); } } } return; } if (!isString(selector)) { callback = selector; selector = ''; } if (!this.events.hasOwnProperty(eventName)) { var useCapture = CAPTURED_EVENTS.indexOf(eventName) > -1; this.el.addEventListener(eventName, this._onEvent, useCapture); this.events[eventName] = {}; } if (!this.events[eventName].hasOwnProperty(selector)) { this.events[eventName][selector] = []; } if (this.events[eventName][selector].indexOf(callback) < 0) { this.events[eventName][selector].push(callback); } }
[ "function", "(", "eventName", ",", "selector", ",", "callback", ")", "{", "if", "(", "!", "isString", "(", "eventName", ")", ")", "{", "var", "eventsMap", "=", "eventName", ";", "for", "(", "var", "key", "in", "eventsMap", ")", "{", "if", "(", "eventsMap", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "var", "split", "=", "key", ".", "split", "(", "' '", ")", ";", "if", "(", "split", ".", "length", ">", "1", ")", "{", "this", ".", "on", "(", "split", "[", "0", "]", ",", "split", "[", "1", "]", ",", "eventsMap", "[", "key", "]", ")", ";", "}", "else", "{", "this", ".", "on", "(", "split", "[", "0", "]", ",", "eventsMap", "[", "key", "]", ")", ";", "}", "}", "}", "return", ";", "}", "if", "(", "!", "isString", "(", "selector", ")", ")", "{", "callback", "=", "selector", ";", "selector", "=", "''", ";", "}", "if", "(", "!", "this", ".", "events", ".", "hasOwnProperty", "(", "eventName", ")", ")", "{", "var", "useCapture", "=", "CAPTURED_EVENTS", ".", "indexOf", "(", "eventName", ")", ">", "-", "1", ";", "this", ".", "el", ".", "addEventListener", "(", "eventName", ",", "this", ".", "_onEvent", ",", "useCapture", ")", ";", "this", ".", "events", "[", "eventName", "]", "=", "{", "}", ";", "}", "if", "(", "!", "this", ".", "events", "[", "eventName", "]", ".", "hasOwnProperty", "(", "selector", ")", ")", "{", "this", ".", "events", "[", "eventName", "]", "[", "selector", "]", "=", "[", "]", ";", "}", "if", "(", "this", ".", "events", "[", "eventName", "]", "[", "selector", "]", ".", "indexOf", "(", "callback", ")", "<", "0", ")", "{", "this", ".", "events", "[", "eventName", "]", "[", "selector", "]", ".", "push", "(", "callback", ")", ";", "}", "}" ]
Starts listening to an event. @param eventName Name of the event to listen to, in lower-case. @param selector Optional CSS selector. If given, only events inside a child element matching the selector are caught. @param callback Callback to invoke when the event is caught. Alternatively, the arguments may be provided using a map to start listening to multiple events at once. Here, the keys of the map are eventNames and the values are callbacks. Selectors may be specified by separating them from the event name with a space. For example: .on({ 'blur': this._blurred, 'click .some-input': this._inputClicked, })
[ "Starts", "listening", "to", "an", "event", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/event-listener.js#L90-L125
15,995
arendjr/selectivity
src/templates.js
function(options) { var extraClass = options.dropdownCssClass ? ' ' + options.dropdownCssClass : '', searchInput = ''; if (options.showSearchInput) { extraClass += ' has-search-input'; var placeholder = options.searchInputPlaceholder; searchInput = '<div class="selectivity-search-input-container">' + '<input type="text" class="selectivity-search-input"' + (placeholder ? ' placeholder="' + escape(placeholder) + '"' : '') + '>' + '</div>'; } return ( '<div class="selectivity-dropdown' + extraClass + '">' + searchInput + '<div class="selectivity-results-container"></div>' + '</div>' ); }
javascript
function(options) { var extraClass = options.dropdownCssClass ? ' ' + options.dropdownCssClass : '', searchInput = ''; if (options.showSearchInput) { extraClass += ' has-search-input'; var placeholder = options.searchInputPlaceholder; searchInput = '<div class="selectivity-search-input-container">' + '<input type="text" class="selectivity-search-input"' + (placeholder ? ' placeholder="' + escape(placeholder) + '"' : '') + '>' + '</div>'; } return ( '<div class="selectivity-dropdown' + extraClass + '">' + searchInput + '<div class="selectivity-results-container"></div>' + '</div>' ); }
[ "function", "(", "options", ")", "{", "var", "extraClass", "=", "options", ".", "dropdownCssClass", "?", "' '", "+", "options", ".", "dropdownCssClass", ":", "''", ",", "searchInput", "=", "''", ";", "if", "(", "options", ".", "showSearchInput", ")", "{", "extraClass", "+=", "' has-search-input'", ";", "var", "placeholder", "=", "options", ".", "searchInputPlaceholder", ";", "searchInput", "=", "'<div class=\"selectivity-search-input-container\">'", "+", "'<input type=\"text\" class=\"selectivity-search-input\"'", "+", "(", "placeholder", "?", "' placeholder=\"'", "+", "escape", "(", "placeholder", ")", "+", "'\"'", ":", "''", ")", "+", "'>'", "+", "'</div>'", ";", "}", "return", "(", "'<div class=\"selectivity-dropdown'", "+", "extraClass", "+", "'\">'", "+", "searchInput", "+", "'<div class=\"selectivity-results-container\"></div>'", "+", "'</div>'", ")", ";", "}" ]
Renders the dropdown. The template is expected to have at least one element with the class 'selectivity-results-container', which is where all results will be added to. @param options Options object containing the following properties: dropdownCssClass - Optional CSS class to add to the top-level element. searchInputPlaceholder - Optional placeholder text to display in the search input in the dropdown. showSearchInput - Boolean whether a search input should be shown. If true, an input element with the 'selectivity-search-input' is expected.
[ "Renders", "the", "dropdown", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/templates.js#L32-L54
15,996
arendjr/selectivity
src/templates.js
function(options) { var extraClass = options.highlighted ? ' highlighted' : ''; return ( '<span class="selectivity-multiple-selected-item' + extraClass + '" ' + 'data-item-id="' + escape(options.id) + '">' + (options.removable ? '<a class="selectivity-multiple-selected-item-remove">' + '<i class="fa fa-remove"></i>' + '</a>' : '') + escape(options.text) + '</span>' ); }
javascript
function(options) { var extraClass = options.highlighted ? ' highlighted' : ''; return ( '<span class="selectivity-multiple-selected-item' + extraClass + '" ' + 'data-item-id="' + escape(options.id) + '">' + (options.removable ? '<a class="selectivity-multiple-selected-item-remove">' + '<i class="fa fa-remove"></i>' + '</a>' : '') + escape(options.text) + '</span>' ); }
[ "function", "(", "options", ")", "{", "var", "extraClass", "=", "options", ".", "highlighted", "?", "' highlighted'", ":", "''", ";", "return", "(", "'<span class=\"selectivity-multiple-selected-item'", "+", "extraClass", "+", "'\" '", "+", "'data-item-id=\"'", "+", "escape", "(", "options", ".", "id", ")", "+", "'\">'", "+", "(", "options", ".", "removable", "?", "'<a class=\"selectivity-multiple-selected-item-remove\">'", "+", "'<i class=\"fa fa-remove\"></i>'", "+", "'</a>'", ":", "''", ")", "+", "escape", "(", "options", ".", "text", ")", "+", "'</span>'", ")", ";", "}" ]
Renders a selected item in multi-selection input boxes. The template is expected to have a top-level element with the class 'selectivity-multiple-selected-item'. This element is also required to have a 'data-item-id' attribute with the ID set to that passed through the options object. An element with the class 'selectivity-multiple-selected-item-remove' should be present which, when clicked, will cause the element to be removed. @param options Options object containing the following properties: highlighted - Boolean whether this item is currently highlighted. id - Identifier for the item. removable - Boolean whether a remove icon should be displayed. text - Text label which the user sees.
[ "Renders", "a", "selected", "item", "in", "multi", "-", "selection", "input", "boxes", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/templates.js#L132-L149
15,997
arendjr/selectivity
src/templates.js
function(options) { return ( '<div class="selectivity-result-item' + (options.disabled ? ' disabled' : '') + '"' + ' data-item-id="' + escape(options.id) + '">' + escape(options.text) + (options.submenu ? '<i class="selectivity-submenu-icon fa fa-chevron-right"></i>' : '') + '</div>' ); }
javascript
function(options) { return ( '<div class="selectivity-result-item' + (options.disabled ? ' disabled' : '') + '"' + ' data-item-id="' + escape(options.id) + '">' + escape(options.text) + (options.submenu ? '<i class="selectivity-submenu-icon fa fa-chevron-right"></i>' : '') + '</div>' ); }
[ "function", "(", "options", ")", "{", "return", "(", "'<div class=\"selectivity-result-item'", "+", "(", "options", ".", "disabled", "?", "' disabled'", ":", "''", ")", "+", "'\"'", "+", "' data-item-id=\"'", "+", "escape", "(", "options", ".", "id", ")", "+", "'\">'", "+", "escape", "(", "options", ".", "text", ")", "+", "(", "options", ".", "submenu", "?", "'<i class=\"selectivity-submenu-icon fa fa-chevron-right\"></i>'", ":", "''", ")", "+", "'</div>'", ")", ";", "}" ]
Render a result item in the dropdown. The template is expected to have a top-level element with the class 'selectivity-result-item'. This element is also required to have a 'data-item-id' attribute with the ID set to that passed through the options object. @param options Options object containing the following properties: id - Identifier for the item. text - Text label which the user sees. disabled - Truthy if the item should be disabled. submenu - Truthy if the result item has a menu with subresults.
[ "Render", "a", "result", "item", "in", "the", "dropdown", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/templates.js#L190-L204
15,998
arendjr/selectivity
src/plugins/submenu.js
SubmenuPlugin
function SubmenuPlugin(selectivity, options) { /** * Optional parent dropdown menu from which this dropdown was opened. */ this.parentMenu = options.parentMenu; Dropdown.call(this, selectivity, options); this._closeSubmenuTimeout = 0; this._openSubmenuTimeout = 0; }
javascript
function SubmenuPlugin(selectivity, options) { /** * Optional parent dropdown menu from which this dropdown was opened. */ this.parentMenu = options.parentMenu; Dropdown.call(this, selectivity, options); this._closeSubmenuTimeout = 0; this._openSubmenuTimeout = 0; }
[ "function", "SubmenuPlugin", "(", "selectivity", ",", "options", ")", "{", "/**\n * Optional parent dropdown menu from which this dropdown was opened.\n */", "this", ".", "parentMenu", "=", "options", ".", "parentMenu", ";", "Dropdown", ".", "call", "(", "this", ",", "selectivity", ",", "options", ")", ";", "this", ".", "_closeSubmenuTimeout", "=", "0", ";", "this", ".", "_openSubmenuTimeout", "=", "0", ";", "}" ]
Extended dropdown that supports submenus.
[ "Extended", "dropdown", "that", "supports", "submenus", "." ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/plugins/submenu.js#L11-L22
15,999
arendjr/selectivity
src/plugins/submenu.js
setSelectable
function setSelectable(item) { if (item.children) { item.children.forEach(setSelectable); } if (item.submenu) { item.selectable = !!item.selectable; } }
javascript
function setSelectable(item) { if (item.children) { item.children.forEach(setSelectable); } if (item.submenu) { item.selectable = !!item.selectable; } }
[ "function", "setSelectable", "(", "item", ")", "{", "if", "(", "item", ".", "children", ")", "{", "item", ".", "children", ".", "forEach", "(", "setSelectable", ")", ";", "}", "if", "(", "item", ".", "submenu", ")", "{", "item", ".", "selectable", "=", "!", "!", "item", ".", "selectable", ";", "}", "}" ]
makes sure any result item with a submenu that's not explicitly set as selectable becomes unselectable
[ "makes", "sure", "any", "result", "item", "with", "a", "submenu", "that", "s", "not", "explicitly", "set", "as", "selectable", "becomes", "unselectable" ]
00e0657aea491ea41547979b62e8f9fc48f36549
https://github.com/arendjr/selectivity/blob/00e0657aea491ea41547979b62e8f9fc48f36549/src/plugins/submenu.js#L122-L129