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
36,400
Zeindelf/utilify-js
dist/utilify.esm.js
objectArraySortByValue
function objectArraySortByValue(arr, map, key) { var _this2 = this; var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; if (!validateHelpers.isArray(map) || map.length < 1) { var compare = function compare(a, b, n) { return _this2.getDescendantProp(a, n).toString().localeCompare(_this2.getDescendantProp(b, n).toString(), undefined, { numeric: true }); }; return arr.slice().sort(function (a, b) { return reverse ? -compare(a, b, key) : compare(a, b, key); }); } return arr.slice().sort(function (a, b) { var ordered = map.indexOf(_this2.getDescendantProp(a, key).toString()) - map.indexOf(_this2.getDescendantProp(b, key).toString()); return reverse ? ordered * -1 : ordered; }); }
javascript
function objectArraySortByValue(arr, map, key) { var _this2 = this; var reverse = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; if (!validateHelpers.isArray(map) || map.length < 1) { var compare = function compare(a, b, n) { return _this2.getDescendantProp(a, n).toString().localeCompare(_this2.getDescendantProp(b, n).toString(), undefined, { numeric: true }); }; return arr.slice().sort(function (a, b) { return reverse ? -compare(a, b, key) : compare(a, b, key); }); } return arr.slice().sort(function (a, b) { var ordered = map.indexOf(_this2.getDescendantProp(a, key).toString()) - map.indexOf(_this2.getDescendantProp(b, key).toString()); return reverse ? ordered * -1 : ordered; }); }
[ "function", "objectArraySortByValue", "(", "arr", ",", "map", ",", "key", ")", "{", "var", "_this2", "=", "this", ";", "var", "reverse", "=", "arguments", ".", "length", ">", "3", "&&", "arguments", "[", "3", "]", "!==", "undefined", "?", "arguments", "[", "3", "]", ":", "false", ";", "if", "(", "!", "validateHelpers", ".", "isArray", "(", "map", ")", "||", "map", ".", "length", "<", "1", ")", "{", "var", "compare", "=", "function", "compare", "(", "a", ",", "b", ",", "n", ")", "{", "return", "_this2", ".", "getDescendantProp", "(", "a", ",", "n", ")", ".", "toString", "(", ")", ".", "localeCompare", "(", "_this2", ".", "getDescendantProp", "(", "b", ",", "n", ")", ".", "toString", "(", ")", ",", "undefined", ",", "{", "numeric", ":", "true", "}", ")", ";", "}", ";", "return", "arr", ".", "slice", "(", ")", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "return", "reverse", "?", "-", "compare", "(", "a", ",", "b", ",", "key", ")", ":", "compare", "(", "a", ",", "b", ",", "key", ")", ";", "}", ")", ";", "}", "return", "arr", ".", "slice", "(", ")", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "var", "ordered", "=", "map", ".", "indexOf", "(", "_this2", ".", "getDescendantProp", "(", "a", ",", "key", ")", ".", "toString", "(", ")", ")", "-", "map", ".", "indexOf", "(", "_this2", ".", "getDescendantProp", "(", "b", ",", "key", ")", ".", "toString", "(", ")", ")", ";", "return", "reverse", "?", "ordered", "*", "-", "1", ":", "ordered", ";", "}", ")", ";", "}" ]
Sorting an array of objects by values @param {Array} [arr] An Array of objects @param {Mix} [map] Map to custom order. If value isn't an array with values, will do natural sort @param {String} [key] Object key to use for sorting (accepts dot notation) @param {Boolean} [reverse=false] Reverse sorting @returns {Array} New object array with sorting values @example var mapToSort = ['A', 'B', 'C', 'D', 'E']; // Map to sorting var obj = [{param: 'D'}, {param: 'A'}, {param: 'E'}, {param: 'C'}, {param: 'B'}]; globalHelpers.objectArraySortByValue(objToSortByValue, mapToSort, 'param'); //=> [{param: 'A'}, {param: 'B'}, {param: 'C'}, {param: 'D'}, {param: 'E'}] // Deep key var obj = [{deep: {param: 'D'}}, {deep: {param: 'A'}}, {deep: {param: 'E'}}, {deep: {param: 'C'}}, {deep: {param: 'B'}}]; globalHelpers.objectArraySortByValue(objToSortByValue, mapToSort, 'deep.param'); //=> [{deep: {param: 'A'}}, {deep: {param: 'B'}}, {deep: {param: 'C'}}, {deep: {param: 'D'}}, {deep: {param: 'E'}}]
[ "Sorting", "an", "array", "of", "objects", "by", "values" ]
a16f6e578c953b10cec5ca89c06aeba73ff6674f
https://github.com/Zeindelf/utilify-js/blob/a16f6e578c953b10cec5ca89c06aeba73ff6674f/dist/utilify.esm.js#L2583-L2603
36,401
Zeindelf/utilify-js
dist/utilify.esm.js
objectToArray
function objectToArray(obj) { if (!validateHelpers.isPlainObject(obj)) { throw new Error('\'obj\' must be a plain object'); } return Object.keys(obj).map(function (key) { return obj[key]; }); }
javascript
function objectToArray(obj) { if (!validateHelpers.isPlainObject(obj)) { throw new Error('\'obj\' must be a plain object'); } return Object.keys(obj).map(function (key) { return obj[key]; }); }
[ "function", "objectToArray", "(", "obj", ")", "{", "if", "(", "!", "validateHelpers", ".", "isPlainObject", "(", "obj", ")", ")", "{", "throw", "new", "Error", "(", "'\\'obj\\' must be a plain object'", ")", ";", "}", "return", "Object", ".", "keys", "(", "obj", ")", ".", "map", "(", "function", "(", "key", ")", "{", "return", "obj", "[", "key", "]", ";", "}", ")", ";", "}" ]
Convert object given into an array values @param {Object} obj Object to convert @return {Array} @example const obj = {a: 'a', b: 'b'}; objectToArray(obj); // ['a', 'b']
[ "Convert", "object", "given", "into", "an", "array", "values" ]
a16f6e578c953b10cec5ca89c06aeba73ff6674f
https://github.com/Zeindelf/utilify-js/blob/a16f6e578c953b10cec5ca89c06aeba73ff6674f/dist/utilify.esm.js#L2682-L2690
36,402
Zeindelf/utilify-js
dist/utilify.esm.js
renameKeys
function renameKeys(obj, keysMap) { if (!validateHelpers.isPlainObject(obj)) { throw new Error('\'obj\' must be an plain object'); } return Object.keys(obj).reduce(function (acc, key) { return _extends({}, acc, defineProperty({}, keysMap[key] || key, obj[key])); }, {}); }
javascript
function renameKeys(obj, keysMap) { if (!validateHelpers.isPlainObject(obj)) { throw new Error('\'obj\' must be an plain object'); } return Object.keys(obj).reduce(function (acc, key) { return _extends({}, acc, defineProperty({}, keysMap[key] || key, obj[key])); }, {}); }
[ "function", "renameKeys", "(", "obj", ",", "keysMap", ")", "{", "if", "(", "!", "validateHelpers", ".", "isPlainObject", "(", "obj", ")", ")", "{", "throw", "new", "Error", "(", "'\\'obj\\' must be an plain object'", ")", ";", "}", "return", "Object", ".", "keys", "(", "obj", ")", ".", "reduce", "(", "function", "(", "acc", ",", "key", ")", "{", "return", "_extends", "(", "{", "}", ",", "acc", ",", "defineProperty", "(", "{", "}", ",", "keysMap", "[", "key", "]", "||", "key", ",", "obj", "[", "key", "]", ")", ")", ";", "}", ",", "{", "}", ")", ";", "}" ]
Replaces the names of multiple object keys with the values provided. @param {Object} obj The plain object @param {Object} keysMap Object with key and value to replace @returns {Object} @example const obj = { name: 'John', surename: 'Smith', age: 20 }; renameKeys(obj, { name: 'firstName', surename: 'lastName' }); //=> { firstName: 'John', lastName: 'Smith', age: 20 }
[ "Replaces", "the", "names", "of", "multiple", "object", "keys", "with", "the", "values", "provided", "." ]
a16f6e578c953b10cec5ca89c06aeba73ff6674f
https://github.com/Zeindelf/utilify-js/blob/a16f6e578c953b10cec5ca89c06aeba73ff6674f/dist/utilify.esm.js#L2704-L2712
36,403
Zeindelf/utilify-js
dist/utilify.esm.js
getUserLocation
function getUserLocation(cache, storage) { var _this = this; if (cache) { this._initLocationStorage(storage); } var store = storage.session.get(CONSTANTS.STORAGE_NAME); /* eslint-disable */ return $.Deferred(function (def) { /* eslint-enable */ if (!validateHelpers.isObjectEmpty(store)) { def.resolve(store); } else { if (window.navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { var lat = position.coords.latitude; var lng = position.coords.longitude; if (!window.google) { return def.reject('Google Maps Javascript API not found. Follow tutorial: https://developers.google.com/maps/documentation/javascript'); } var latlng = new google.maps.LatLng(lat, lng); var geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'latLng': latlng }, function (results, status) { if (status === google.maps.GeocoderStatus.OK) { if (results[1]) { for (var i = 0, len = results.length; i < len; i += 1) { if (results[i].types[0] === 'locality') { var city = results[i].address_components[0].short_name; var state = results[i].address_components[2].short_name; var storeLocation = { coords: { lat: lat, lng: lng }, city: city, state: state, region: _this.filteredRegion(state) }; if (cache) { storage.session.set(CONSTANTS.STORAGE_NAME, storeLocation, CONSTANTS.EXPIRE_TIME); } def.resolve(storeLocation); } } } else { def.reject('No reverse geocode results.'); } } else { def.reject('Geocoder failed: ' + status); } }); }, function (err) { def.reject('Geolocation not available.'); }); } else { def.reject('Geolocation isn\'t available'); } } }).promise(); }
javascript
function getUserLocation(cache, storage) { var _this = this; if (cache) { this._initLocationStorage(storage); } var store = storage.session.get(CONSTANTS.STORAGE_NAME); /* eslint-disable */ return $.Deferred(function (def) { /* eslint-enable */ if (!validateHelpers.isObjectEmpty(store)) { def.resolve(store); } else { if (window.navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { var lat = position.coords.latitude; var lng = position.coords.longitude; if (!window.google) { return def.reject('Google Maps Javascript API not found. Follow tutorial: https://developers.google.com/maps/documentation/javascript'); } var latlng = new google.maps.LatLng(lat, lng); var geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'latLng': latlng }, function (results, status) { if (status === google.maps.GeocoderStatus.OK) { if (results[1]) { for (var i = 0, len = results.length; i < len; i += 1) { if (results[i].types[0] === 'locality') { var city = results[i].address_components[0].short_name; var state = results[i].address_components[2].short_name; var storeLocation = { coords: { lat: lat, lng: lng }, city: city, state: state, region: _this.filteredRegion(state) }; if (cache) { storage.session.set(CONSTANTS.STORAGE_NAME, storeLocation, CONSTANTS.EXPIRE_TIME); } def.resolve(storeLocation); } } } else { def.reject('No reverse geocode results.'); } } else { def.reject('Geocoder failed: ' + status); } }); }, function (err) { def.reject('Geolocation not available.'); }); } else { def.reject('Geolocation isn\'t available'); } } }).promise(); }
[ "function", "getUserLocation", "(", "cache", ",", "storage", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "cache", ")", "{", "this", ".", "_initLocationStorage", "(", "storage", ")", ";", "}", "var", "store", "=", "storage", ".", "session", ".", "get", "(", "CONSTANTS", ".", "STORAGE_NAME", ")", ";", "/* eslint-disable */", "return", "$", ".", "Deferred", "(", "function", "(", "def", ")", "{", "/* eslint-enable */", "if", "(", "!", "validateHelpers", ".", "isObjectEmpty", "(", "store", ")", ")", "{", "def", ".", "resolve", "(", "store", ")", ";", "}", "else", "{", "if", "(", "window", ".", "navigator", ".", "geolocation", ")", "{", "navigator", ".", "geolocation", ".", "getCurrentPosition", "(", "function", "(", "position", ")", "{", "var", "lat", "=", "position", ".", "coords", ".", "latitude", ";", "var", "lng", "=", "position", ".", "coords", ".", "longitude", ";", "if", "(", "!", "window", ".", "google", ")", "{", "return", "def", ".", "reject", "(", "'Google Maps Javascript API not found. Follow tutorial: https://developers.google.com/maps/documentation/javascript'", ")", ";", "}", "var", "latlng", "=", "new", "google", ".", "maps", ".", "LatLng", "(", "lat", ",", "lng", ")", ";", "var", "geocoder", "=", "new", "google", ".", "maps", ".", "Geocoder", "(", ")", ";", "geocoder", ".", "geocode", "(", "{", "'latLng'", ":", "latlng", "}", ",", "function", "(", "results", ",", "status", ")", "{", "if", "(", "status", "===", "google", ".", "maps", ".", "GeocoderStatus", ".", "OK", ")", "{", "if", "(", "results", "[", "1", "]", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "results", ".", "length", ";", "i", "<", "len", ";", "i", "+=", "1", ")", "{", "if", "(", "results", "[", "i", "]", ".", "types", "[", "0", "]", "===", "'locality'", ")", "{", "var", "city", "=", "results", "[", "i", "]", ".", "address_components", "[", "0", "]", ".", "short_name", ";", "var", "state", "=", "results", "[", "i", "]", ".", "address_components", "[", "2", "]", ".", "short_name", ";", "var", "storeLocation", "=", "{", "coords", ":", "{", "lat", ":", "lat", ",", "lng", ":", "lng", "}", ",", "city", ":", "city", ",", "state", ":", "state", ",", "region", ":", "_this", ".", "filteredRegion", "(", "state", ")", "}", ";", "if", "(", "cache", ")", "{", "storage", ".", "session", ".", "set", "(", "CONSTANTS", ".", "STORAGE_NAME", ",", "storeLocation", ",", "CONSTANTS", ".", "EXPIRE_TIME", ")", ";", "}", "def", ".", "resolve", "(", "storeLocation", ")", ";", "}", "}", "}", "else", "{", "def", ".", "reject", "(", "'No reverse geocode results.'", ")", ";", "}", "}", "else", "{", "def", ".", "reject", "(", "'Geocoder failed: '", "+", "status", ")", ";", "}", "}", ")", ";", "}", ",", "function", "(", "err", ")", "{", "def", ".", "reject", "(", "'Geolocation not available.'", ")", ";", "}", ")", ";", "}", "else", "{", "def", ".", "reject", "(", "'Geolocation isn\\'t available'", ")", ";", "}", "}", "}", ")", ".", "promise", "(", ")", ";", "}" ]
Get user location by HTML5 Geolocate API and translate coordinates to Brazilian State, City and Region @param {Boolean} cache Save user coordinates into localstorage @param {Object} storage Store2 lib instance @return {Promise} When success, response are an object with State, City, Region and user Coordinates @example locationHelpers.getCityState() .then(function(res) { window.console.log(res); }) .fail(function(err) { window.console.log(err); });
[ "Get", "user", "location", "by", "HTML5", "Geolocate", "API", "and", "translate", "coordinates", "to", "Brazilian", "State", "City", "and", "Region" ]
a16f6e578c953b10cec5ca89c06aeba73ff6674f
https://github.com/Zeindelf/utilify-js/blob/a16f6e578c953b10cec5ca89c06aeba73ff6674f/dist/utilify.esm.js#L3166-L3229
36,404
Zeindelf/utilify-js
dist/utilify.esm.js
filteredRegion
function filteredRegion(state) { var _this2 = this; var filteredRegion = ''; var _loop = function _loop(region) { if ({}.hasOwnProperty.call(_this2._regionMap, region)) { _this2._regionMap[region].some(function (el, i, arr) { if (stringHelpers.removeAccent(el.toLowerCase()) === stringHelpers.removeAccent(state.toLowerCase())) { filteredRegion = region; } }); } }; for (var region in this._regionMap) { _loop(region); } return filteredRegion; }
javascript
function filteredRegion(state) { var _this2 = this; var filteredRegion = ''; var _loop = function _loop(region) { if ({}.hasOwnProperty.call(_this2._regionMap, region)) { _this2._regionMap[region].some(function (el, i, arr) { if (stringHelpers.removeAccent(el.toLowerCase()) === stringHelpers.removeAccent(state.toLowerCase())) { filteredRegion = region; } }); } }; for (var region in this._regionMap) { _loop(region); } return filteredRegion; }
[ "function", "filteredRegion", "(", "state", ")", "{", "var", "_this2", "=", "this", ";", "var", "filteredRegion", "=", "''", ";", "var", "_loop", "=", "function", "_loop", "(", "region", ")", "{", "if", "(", "{", "}", ".", "hasOwnProperty", ".", "call", "(", "_this2", ".", "_regionMap", ",", "region", ")", ")", "{", "_this2", ".", "_regionMap", "[", "region", "]", ".", "some", "(", "function", "(", "el", ",", "i", ",", "arr", ")", "{", "if", "(", "stringHelpers", ".", "removeAccent", "(", "el", ".", "toLowerCase", "(", ")", ")", "===", "stringHelpers", ".", "removeAccent", "(", "state", ".", "toLowerCase", "(", ")", ")", ")", "{", "filteredRegion", "=", "region", ";", "}", "}", ")", ";", "}", "}", ";", "for", "(", "var", "region", "in", "this", ".", "_regionMap", ")", "{", "_loop", "(", "region", ")", ";", "}", "return", "filteredRegion", ";", "}" ]
Get Brazilian region for an state initials given @param {String} state Initials state (e.g. 'SP') @return {String} Region (Norte, Sul, etc.) @example locationHelpers.filteredRegion('SP'); // Sudeste
[ "Get", "Brazilian", "region", "for", "an", "state", "initials", "given" ]
a16f6e578c953b10cec5ca89c06aeba73ff6674f
https://github.com/Zeindelf/utilify-js/blob/a16f6e578c953b10cec5ca89c06aeba73ff6674f/dist/utilify.esm.js#L3240-L3260
36,405
Zeindelf/utilify-js
dist/utilify.esm.js
Utilify
function Utilify() { classCallCheck(this, Utilify); /** * Version * @type {String} */ this.version = '0.10.1'; /** * Package name * @type {String} */ this.name = '@UtilifyJS'; /** * Global Helpers instance * @type {GlobalHelpers} */ this.globalHelpers = new GlobalHelpers(); /** * Location Helpers instance * @type {LocationHelpers} */ this.locationHelpers = new LocationHelpers(store); /** * Local/Session Storage * @type {Object} */ this.storage = store; /** * JS Cookies * @type {Object} */ this.cookies = initCookies(function () {}); }
javascript
function Utilify() { classCallCheck(this, Utilify); /** * Version * @type {String} */ this.version = '0.10.1'; /** * Package name * @type {String} */ this.name = '@UtilifyJS'; /** * Global Helpers instance * @type {GlobalHelpers} */ this.globalHelpers = new GlobalHelpers(); /** * Location Helpers instance * @type {LocationHelpers} */ this.locationHelpers = new LocationHelpers(store); /** * Local/Session Storage * @type {Object} */ this.storage = store; /** * JS Cookies * @type {Object} */ this.cookies = initCookies(function () {}); }
[ "function", "Utilify", "(", ")", "{", "classCallCheck", "(", "this", ",", "Utilify", ")", ";", "/**\n * Version\n * @type {String}\n */", "this", ".", "version", "=", "'0.10.1'", ";", "/**\n * Package name\n * @type {String}\n */", "this", ".", "name", "=", "'@UtilifyJS'", ";", "/**\n * Global Helpers instance\n * @type {GlobalHelpers}\n */", "this", ".", "globalHelpers", "=", "new", "GlobalHelpers", "(", ")", ";", "/**\n * Location Helpers instance\n * @type {LocationHelpers}\n */", "this", ".", "locationHelpers", "=", "new", "LocationHelpers", "(", "store", ")", ";", "/**\n * Local/Session Storage\n * @type {Object}\n */", "this", ".", "storage", "=", "store", ";", "/**\n * JS Cookies\n * @type {Object}\n */", "this", ".", "cookies", "=", "initCookies", "(", "function", "(", ")", "{", "}", ")", ";", "}" ]
Create a Utilify class Main class
[ "Create", "a", "Utilify", "class", "Main", "class" ]
a16f6e578c953b10cec5ca89c06aeba73ff6674f
https://github.com/Zeindelf/utilify-js/blob/a16f6e578c953b10cec5ca89c06aeba73ff6674f/dist/utilify.esm.js#L3338-L3376
36,406
avoidwork/abaaso
src/datalist.js
function ( target, store, template, options ) { var ref = [store], obj, instance; if ( !( target instanceof Element ) || typeof store !== "object" || !regex.string_object.test( typeof template ) ) { throw new Error( label.error.invalidArguments ); } obj = element.create( "ul", {"class": "list", id: store.parentNode.id + "-datalist"}, target ); // Creating instance instance = new DataList( obj, ref[0], template ); if ( options instanceof Object) { utility.merge( instance, options ); } instance.store.datalists.push( instance ); // Rendering if not tied to an API or data is ready if ( instance.store.uri === null || instance.store.loaded ) { instance.refresh(); } return instance; }
javascript
function ( target, store, template, options ) { var ref = [store], obj, instance; if ( !( target instanceof Element ) || typeof store !== "object" || !regex.string_object.test( typeof template ) ) { throw new Error( label.error.invalidArguments ); } obj = element.create( "ul", {"class": "list", id: store.parentNode.id + "-datalist"}, target ); // Creating instance instance = new DataList( obj, ref[0], template ); if ( options instanceof Object) { utility.merge( instance, options ); } instance.store.datalists.push( instance ); // Rendering if not tied to an API or data is ready if ( instance.store.uri === null || instance.store.loaded ) { instance.refresh(); } return instance; }
[ "function", "(", "target", ",", "store", ",", "template", ",", "options", ")", "{", "var", "ref", "=", "[", "store", "]", ",", "obj", ",", "instance", ";", "if", "(", "!", "(", "target", "instanceof", "Element", ")", "||", "typeof", "store", "!==", "\"object\"", "||", "!", "regex", ".", "string_object", ".", "test", "(", "typeof", "template", ")", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "invalidArguments", ")", ";", "}", "obj", "=", "element", ".", "create", "(", "\"ul\"", ",", "{", "\"class\"", ":", "\"list\"", ",", "id", ":", "store", ".", "parentNode", ".", "id", "+", "\"-datalist\"", "}", ",", "target", ")", ";", "// Creating instance", "instance", "=", "new", "DataList", "(", "obj", ",", "ref", "[", "0", "]", ",", "template", ")", ";", "if", "(", "options", "instanceof", "Object", ")", "{", "utility", ".", "merge", "(", "instance", ",", "options", ")", ";", "}", "instance", ".", "store", ".", "datalists", ".", "push", "(", "instance", ")", ";", "// Rendering if not tied to an API or data is ready", "if", "(", "instance", ".", "store", ".", "uri", "===", "null", "||", "instance", ".", "store", ".", "loaded", ")", "{", "instance", ".", "refresh", "(", ")", ";", "}", "return", "instance", ";", "}" ]
Creates an instance of datalist @method factory @param {Object} target Element to receive the DataList @param {Object} store Data store to feed the DataList @param {Mixed} template Record field, template ( $.tpl ), or String, e.g. "<p>this is a {{field}} sample.</p>", fields are marked with {{ }} @param {Object} options Optional parameters to set on the DataList @return {Object} DataList instance
[ "Creates", "an", "instance", "of", "datalist" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/src/datalist.js#L13-L38
36,407
avoidwork/abaaso
src/datalist.js
function () { if ( isNaN( this.pageSize ) ) { throw new Error( label.error.invalidArguments ); } return number.round( ( !this.filter ? this.total : this.filtered.length ) / this.pageSize, "up" ); }
javascript
function () { if ( isNaN( this.pageSize ) ) { throw new Error( label.error.invalidArguments ); } return number.round( ( !this.filter ? this.total : this.filtered.length ) / this.pageSize, "up" ); }
[ "function", "(", ")", "{", "if", "(", "isNaN", "(", "this", ".", "pageSize", ")", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "invalidArguments", ")", ";", "}", "return", "number", ".", "round", "(", "(", "!", "this", ".", "filter", "?", "this", ".", "total", ":", "this", ".", "filtered", ".", "length", ")", "/", "this", ".", "pageSize", ",", "\"up\"", ")", ";", "}" ]
Calculates the total pages @method pages @private @return {Number} Total pages
[ "Calculates", "the", "total", "pages" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/src/datalist.js#L47-L53
36,408
spreadshirt/rAppid.js-sprd
sprd/type/UploadDesign.js
function (fileName) { fileName = (fileName || "").toLowerCase(); var validExtensions = ["svg", "cdr", "eps", "ai"], fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1); return validExtensions.indexOf(fileExtension) != -1; }
javascript
function (fileName) { fileName = (fileName || "").toLowerCase(); var validExtensions = ["svg", "cdr", "eps", "ai"], fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1); return validExtensions.indexOf(fileExtension) != -1; }
[ "function", "(", "fileName", ")", "{", "fileName", "=", "(", "fileName", "||", "\"\"", ")", ".", "toLowerCase", "(", ")", ";", "var", "validExtensions", "=", "[", "\"svg\"", ",", "\"cdr\"", ",", "\"eps\"", ",", "\"ai\"", "]", ",", "fileExtension", "=", "fileName", ".", "substr", "(", "fileName", ".", "lastIndexOf", "(", "'.'", ")", "+", "1", ")", ";", "return", "validExtensions", ".", "indexOf", "(", "fileExtension", ")", "!=", "-", "1", ";", "}" ]
Checks if the file name matches a correct extension for a vector file. @param {String} fileName @returns {boolean}
[ "Checks", "if", "the", "file", "name", "matches", "a", "correct", "extension", "for", "a", "vector", "file", "." ]
b56f9f47fe01332f5bf885eaf4db59014f099019
https://github.com/spreadshirt/rAppid.js-sprd/blob/b56f9f47fe01332f5bf885eaf4db59014f099019/sprd/type/UploadDesign.js#L103-L109
36,409
tinwatchman/grawlix
spec/util-spec.js
function(pluginOptions, options) { options.isFactoryFunctionRun = true; return new GrawlixPlugin({ name: 'blank-plugin-2', init: function(opts) { opts.isLoaded = true; } }); }
javascript
function(pluginOptions, options) { options.isFactoryFunctionRun = true; return new GrawlixPlugin({ name: 'blank-plugin-2', init: function(opts) { opts.isLoaded = true; } }); }
[ "function", "(", "pluginOptions", ",", "options", ")", "{", "options", ".", "isFactoryFunctionRun", "=", "true", ";", "return", "new", "GrawlixPlugin", "(", "{", "name", ":", "'blank-plugin-2'", ",", "init", ":", "function", "(", "opts", ")", "{", "opts", ".", "isLoaded", "=", "true", ";", "}", "}", ")", ";", "}" ]
factory function plugin
[ "factory", "function", "plugin" ]
235cd9629992b97c62953b813d5034a9546211f1
https://github.com/tinwatchman/grawlix/blob/235cd9629992b97c62953b813d5034a9546211f1/spec/util-spec.js#L644-L652
36,410
LockateMe/cordova-plugin-minisodium
www/MiniSodium.js
function(ed25519Sk, callback){ if (typeof callback != 'function') throw new TypeError('callback must be a function'); try { isValidInput(ed25519Sk, 'ed25519Sk', MiniSodium.crypto_sign_SECRETKEYBYTES); } catch (e){ callback(e); return; } ed25519Sk = to_hex(ed25519Sk); var params = [ed25519Sk]; cordova.exec(resultHandlerFactory(callback), callback, 'MiniSodium', 'crypto_sign_ed25519_sk_to_curve25519', params); }
javascript
function(ed25519Sk, callback){ if (typeof callback != 'function') throw new TypeError('callback must be a function'); try { isValidInput(ed25519Sk, 'ed25519Sk', MiniSodium.crypto_sign_SECRETKEYBYTES); } catch (e){ callback(e); return; } ed25519Sk = to_hex(ed25519Sk); var params = [ed25519Sk]; cordova.exec(resultHandlerFactory(callback), callback, 'MiniSodium', 'crypto_sign_ed25519_sk_to_curve25519', params); }
[ "function", "(", "ed25519Sk", ",", "callback", ")", "{", "if", "(", "typeof", "callback", "!=", "'function'", ")", "throw", "new", "TypeError", "(", "'callback must be a function'", ")", ";", "try", "{", "isValidInput", "(", "ed25519Sk", ",", "'ed25519Sk'", ",", "MiniSodium", ".", "crypto_sign_SECRETKEYBYTES", ")", ";", "}", "catch", "(", "e", ")", "{", "callback", "(", "e", ")", ";", "return", ";", "}", "ed25519Sk", "=", "to_hex", "(", "ed25519Sk", ")", ";", "var", "params", "=", "[", "ed25519Sk", "]", ";", "cordova", ".", "exec", "(", "resultHandlerFactory", "(", "callback", ")", ",", "callback", ",", "'MiniSodium'", ",", "'crypto_sign_ed25519_sk_to_curve25519'", ",", "params", ")", ";", "}" ]
Ed25519 -> Curve25519 keypair conversion
[ "Ed25519", "-", ">", "Curve25519", "keypair", "conversion" ]
4527565db27c488deca5f949d562192526ef1748
https://github.com/LockateMe/cordova-plugin-minisodium/blob/4527565db27c488deca5f949d562192526ef1748/www/MiniSodium.js#L220-L233
36,411
LockateMe/cordova-plugin-minisodium
www/MiniSodium.js
function(str) { if (str instanceof Uint8Array) return str; if (!is_hex(str)) { throw new TypeError("The provided string doesn't look like hex data"); } var result = new Uint8Array(str.length / 2); for (var i = 0; i < str.length; i += 2) { result[i >>> 1] = parseInt(str.substr(i, 2), 16); } return result; }
javascript
function(str) { if (str instanceof Uint8Array) return str; if (!is_hex(str)) { throw new TypeError("The provided string doesn't look like hex data"); } var result = new Uint8Array(str.length / 2); for (var i = 0; i < str.length; i += 2) { result[i >>> 1] = parseInt(str.substr(i, 2), 16); } return result; }
[ "function", "(", "str", ")", "{", "if", "(", "str", "instanceof", "Uint8Array", ")", "return", "str", ";", "if", "(", "!", "is_hex", "(", "str", ")", ")", "{", "throw", "new", "TypeError", "(", "\"The provided string doesn't look like hex data\"", ")", ";", "}", "var", "result", "=", "new", "Uint8Array", "(", "str", ".", "length", "/", "2", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "str", ".", "length", ";", "i", "+=", "2", ")", "{", "result", "[", "i", ">>>", "1", "]", "=", "parseInt", "(", "str", ".", "substr", "(", "i", ",", "2", ")", ",", "16", ")", ";", "}", "return", "result", ";", "}" ]
Hexdecimal encoding helpers
[ "Hexdecimal", "encoding", "helpers" ]
4527565db27c488deca5f949d562192526ef1748
https://github.com/LockateMe/cordova-plugin-minisodium/blob/4527565db27c488deca5f949d562192526ef1748/www/MiniSodium.js#L472-L482
36,412
Dashron/roads
src/middleware/simpleRouter.js
buildRouterPath
function buildRouterPath(path, prefix) { if (!prefix) { prefix = ''; } if (prefix.length && path === '/') { return prefix; } return prefix + path; }
javascript
function buildRouterPath(path, prefix) { if (!prefix) { prefix = ''; } if (prefix.length && path === '/') { return prefix; } return prefix + path; }
[ "function", "buildRouterPath", "(", "path", ",", "prefix", ")", "{", "if", "(", "!", "prefix", ")", "{", "prefix", "=", "''", ";", "}", "if", "(", "prefix", ".", "length", "&&", "path", "===", "'/'", ")", "{", "return", "prefix", ";", "}", "return", "prefix", "+", "path", ";", "}" ]
Applies a prefix to paths of route files @todo I'm pretty sure there's an existing library that will do this more accurately @param {string} path - The HTTP path of a route @param {string} [prefix] - An optional prefix for the HTTP path
[ "Applies", "a", "prefix", "to", "paths", "of", "route", "files" ]
c089d79d8181063c7fae00432a79b7a79a7809d3
https://github.com/Dashron/roads/blob/c089d79d8181063c7fae00432a79b7a79a7809d3/src/middleware/simpleRouter.js#L19-L29
36,413
Dashron/roads
src/middleware/simpleRouter.js
compareRouteAndApplyArgs
function compareRouteAndApplyArgs (route, request_url, request_method) { if (route.method !== request_method) { return false; } let template = route.path.split('/'); if (template[0] === '') { template = template.slice(1); // Slice kills the emptystring before the leading slash } let actual = request_url.pathname.split('/'); if (actual[0] === '') { actual = actual.slice(1); // Slice kills the emptystring before the leading slash } if (template.length != actual.length) { return false; } for (let i = 0; i < template.length; i++) { let actual_part = actual[i]; let template_part = template[i]; // Process variables first if (template_part[0] === '#') { // # templates only accept numbers if (isNaN(Number(actual_part))) { return false; } applyArg(request_url, template_part.substring(1), Number(actual_part)); continue; } if (template_part[0] === '$') { // $ templates accept any non-slash alphanumeric character applyArg(request_url, template_part.substring(1), String(actual_part)); // Continue so that continue; } // Process exact matches second if (actual_part === template_part) { continue; } return false; } return true; }
javascript
function compareRouteAndApplyArgs (route, request_url, request_method) { if (route.method !== request_method) { return false; } let template = route.path.split('/'); if (template[0] === '') { template = template.slice(1); // Slice kills the emptystring before the leading slash } let actual = request_url.pathname.split('/'); if (actual[0] === '') { actual = actual.slice(1); // Slice kills the emptystring before the leading slash } if (template.length != actual.length) { return false; } for (let i = 0; i < template.length; i++) { let actual_part = actual[i]; let template_part = template[i]; // Process variables first if (template_part[0] === '#') { // # templates only accept numbers if (isNaN(Number(actual_part))) { return false; } applyArg(request_url, template_part.substring(1), Number(actual_part)); continue; } if (template_part[0] === '$') { // $ templates accept any non-slash alphanumeric character applyArg(request_url, template_part.substring(1), String(actual_part)); // Continue so that continue; } // Process exact matches second if (actual_part === template_part) { continue; } return false; } return true; }
[ "function", "compareRouteAndApplyArgs", "(", "route", ",", "request_url", ",", "request_method", ")", "{", "if", "(", "route", ".", "method", "!==", "request_method", ")", "{", "return", "false", ";", "}", "let", "template", "=", "route", ".", "path", ".", "split", "(", "'/'", ")", ";", "if", "(", "template", "[", "0", "]", "===", "''", ")", "{", "template", "=", "template", ".", "slice", "(", "1", ")", ";", "// Slice kills the emptystring before the leading slash", "}", "let", "actual", "=", "request_url", ".", "pathname", ".", "split", "(", "'/'", ")", ";", "if", "(", "actual", "[", "0", "]", "===", "''", ")", "{", "actual", "=", "actual", ".", "slice", "(", "1", ")", ";", "// Slice kills the emptystring before the leading slash", "}", "if", "(", "template", ".", "length", "!=", "actual", ".", "length", ")", "{", "return", "false", ";", "}", "for", "(", "let", "i", "=", "0", ";", "i", "<", "template", ".", "length", ";", "i", "++", ")", "{", "let", "actual_part", "=", "actual", "[", "i", "]", ";", "let", "template_part", "=", "template", "[", "i", "]", ";", "// Process variables first", "if", "(", "template_part", "[", "0", "]", "===", "'#'", ")", "{", "// # templates only accept numbers", "if", "(", "isNaN", "(", "Number", "(", "actual_part", ")", ")", ")", "{", "return", "false", ";", "}", "applyArg", "(", "request_url", ",", "template_part", ".", "substring", "(", "1", ")", ",", "Number", "(", "actual_part", ")", ")", ";", "continue", ";", "}", "if", "(", "template_part", "[", "0", "]", "===", "'$'", ")", "{", "// $ templates accept any non-slash alphanumeric character", "applyArg", "(", "request_url", ",", "template_part", ".", "substring", "(", "1", ")", ",", "String", "(", "actual_part", ")", ")", ";", "// Continue so that ", "continue", ";", "}", "// Process exact matches second", "if", "(", "actual_part", "===", "template_part", ")", "{", "continue", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks to see if the route matches the request, and if true assigns any applicable url variables and returns the route @param {object} route - Route object from this simple router class @param {object} route.method - HTTP method associated with this route @param {object} route.path - HTTP path associated with this route @param {object} request_url - Parsed HTTP request url @param {string} request_method - HTTP request method
[ "Checks", "to", "see", "if", "the", "route", "matches", "the", "request", "and", "if", "true", "assigns", "any", "applicable", "url", "variables", "and", "returns", "the", "route" ]
c089d79d8181063c7fae00432a79b7a79a7809d3
https://github.com/Dashron/roads/blob/c089d79d8181063c7fae00432a79b7a79a7809d3/src/middleware/simpleRouter.js#L154-L204
36,414
Dashron/roads
src/middleware/simpleRouter.js
applyArg
function applyArg(request_url, template_part, actual_part) { if (typeof(request_url.args) === "undefined") { request_url.args = {}; } if (typeof request_url.args !== "object") { throw new Error("The request url's args have already been defined as a " + typeof request_url.args + " and we expected an object. For safety we are throwing this error instead of overwriting your existing data. Please use a different field name in your code"); } request_url.args[template_part] = actual_part; }
javascript
function applyArg(request_url, template_part, actual_part) { if (typeof(request_url.args) === "undefined") { request_url.args = {}; } if (typeof request_url.args !== "object") { throw new Error("The request url's args have already been defined as a " + typeof request_url.args + " and we expected an object. For safety we are throwing this error instead of overwriting your existing data. Please use a different field name in your code"); } request_url.args[template_part] = actual_part; }
[ "function", "applyArg", "(", "request_url", ",", "template_part", ",", "actual_part", ")", "{", "if", "(", "typeof", "(", "request_url", ".", "args", ")", "===", "\"undefined\"", ")", "{", "request_url", ".", "args", "=", "{", "}", ";", "}", "if", "(", "typeof", "request_url", ".", "args", "!==", "\"object\"", ")", "{", "throw", "new", "Error", "(", "\"The request url's args have already been defined as a \"", "+", "typeof", "request_url", ".", "args", "+", "\" and we expected an object. For safety we are throwing this error instead of overwriting your existing data. Please use a different field name in your code\"", ")", ";", "}", "request_url", ".", "args", "[", "template_part", "]", "=", "actual_part", ";", "}" ]
Assigns a value to the parsed request urls args parameter @param {object} request_url - The parsed url object @param {string} template_part - The template variable @param {*} actual_part - The url value
[ "Assigns", "a", "value", "to", "the", "parsed", "request", "urls", "args", "parameter" ]
c089d79d8181063c7fae00432a79b7a79a7809d3
https://github.com/Dashron/roads/blob/c089d79d8181063c7fae00432a79b7a79a7809d3/src/middleware/simpleRouter.js#L213-L223
36,415
felixrieseberg/windows-notification-state
lib/index.js
getNotificationState
function getNotificationState () { if (process.platform !== 'win32') { throw new Error('windows-notification-state only works on windows') } const QUERY_USER_NOTIFICATION_STATE = [ '', 'QUNS_NOT_PRESENT', 'QUNS_BUSY', 'QUNS_RUNNING_D3D_FULL_SCREEN', 'QUNS_PRESENTATION_MODE', 'QUNS_ACCEPTS_NOTIFICATIONS', 'QUNS_QUIET_TIME', 'QUNS_APP' ] const result = addon.getNotificationState() if (QUERY_USER_NOTIFICATION_STATE[result]) { return QUERY_USER_NOTIFICATION_STATE[result] } else { return 'UNKNOWN_ERROR' } }
javascript
function getNotificationState () { if (process.platform !== 'win32') { throw new Error('windows-notification-state only works on windows') } const QUERY_USER_NOTIFICATION_STATE = [ '', 'QUNS_NOT_PRESENT', 'QUNS_BUSY', 'QUNS_RUNNING_D3D_FULL_SCREEN', 'QUNS_PRESENTATION_MODE', 'QUNS_ACCEPTS_NOTIFICATIONS', 'QUNS_QUIET_TIME', 'QUNS_APP' ] const result = addon.getNotificationState() if (QUERY_USER_NOTIFICATION_STATE[result]) { return QUERY_USER_NOTIFICATION_STATE[result] } else { return 'UNKNOWN_ERROR' } }
[ "function", "getNotificationState", "(", ")", "{", "if", "(", "process", ".", "platform", "!==", "'win32'", ")", "{", "throw", "new", "Error", "(", "'windows-notification-state only works on windows'", ")", "}", "const", "QUERY_USER_NOTIFICATION_STATE", "=", "[", "''", ",", "'QUNS_NOT_PRESENT'", ",", "'QUNS_BUSY'", ",", "'QUNS_RUNNING_D3D_FULL_SCREEN'", ",", "'QUNS_PRESENTATION_MODE'", ",", "'QUNS_ACCEPTS_NOTIFICATIONS'", ",", "'QUNS_QUIET_TIME'", ",", "'QUNS_APP'", "]", "const", "result", "=", "addon", ".", "getNotificationState", "(", ")", "if", "(", "QUERY_USER_NOTIFICATION_STATE", "[", "result", "]", ")", "{", "return", "QUERY_USER_NOTIFICATION_STATE", "[", "result", "]", "}", "else", "{", "return", "'UNKNOWN_ERROR'", "}", "}" ]
Returns the name of the QUERY_USER_NOTIFICATION_STATE enum rather than a number. @returns {string} QUERY_USER_NOTIFICATION_STATE
[ "Returns", "the", "name", "of", "the", "QUERY_USER_NOTIFICATION_STATE", "enum", "rather", "than", "a", "number", "." ]
a8e0710997f1744eb8129e691513f235f681807e
https://github.com/felixrieseberg/windows-notification-state/blob/a8e0710997f1744eb8129e691513f235f681807e/lib/index.js#L22-L45
36,416
HumanBrainProject/jsdoc-sphinx
template/util/rst-mixin.js
titlecase
function titlecase() { return function(data, render) { var text = render(data); if (text.length === 0) { return text; } return text[0].toUpperCase() + text.substring(1); }; }
javascript
function titlecase() { return function(data, render) { var text = render(data); if (text.length === 0) { return text; } return text[0].toUpperCase() + text.substring(1); }; }
[ "function", "titlecase", "(", ")", "{", "return", "function", "(", "data", ",", "render", ")", "{", "var", "text", "=", "render", "(", "data", ")", ";", "if", "(", "text", ".", "length", "===", "0", ")", "{", "return", "text", ";", "}", "return", "text", "[", "0", "]", ".", "toUpperCase", "(", ")", "+", "text", ".", "substring", "(", "1", ")", ";", "}", ";", "}" ]
Mustache lambda that upercase the first letter of each word in the given data. @return {function} the titlecase helper function
[ "Mustache", "lambda", "that", "upercase", "the", "first", "letter", "of", "each", "word", "in", "the", "given", "data", "." ]
9d7c1d318ce535640588e7308917729c3849bc83
https://github.com/HumanBrainProject/jsdoc-sphinx/blob/9d7c1d318ce535640588e7308917729c3849bc83/template/util/rst-mixin.js#L19-L28
36,417
HumanBrainProject/jsdoc-sphinx
template/util/rst-mixin.js
generateHeading
function generateHeading() { var mixin = {}; // If two char are provided, first one is used as upperline of the text. _.each(['==', '=', '-', '~', '\''], function(char, idx) { // Mustach lambda function takes no parameters and return a function // whose signature is data, render. // see https://mustache.github.io/mustache.5.html mixin['h' + (idx + 1)] = function() { return function(data, render) { var text = render(data); var length = _.last(text.split('\n')).length; if (char.length === 2) { text = repeatChar(char[1], length) + '\n' + text; } return text + '\n' + repeatChar(char[0], length); }; }; }); return mixin; }
javascript
function generateHeading() { var mixin = {}; // If two char are provided, first one is used as upperline of the text. _.each(['==', '=', '-', '~', '\''], function(char, idx) { // Mustach lambda function takes no parameters and return a function // whose signature is data, render. // see https://mustache.github.io/mustache.5.html mixin['h' + (idx + 1)] = function() { return function(data, render) { var text = render(data); var length = _.last(text.split('\n')).length; if (char.length === 2) { text = repeatChar(char[1], length) + '\n' + text; } return text + '\n' + repeatChar(char[0], length); }; }; }); return mixin; }
[ "function", "generateHeading", "(", ")", "{", "var", "mixin", "=", "{", "}", ";", "// If two char are provided, first one is used as upperline of the text.", "_", ".", "each", "(", "[", "'=='", ",", "'='", ",", "'-'", ",", "'~'", ",", "'\\''", "]", ",", "function", "(", "char", ",", "idx", ")", "{", "// Mustach lambda function takes no parameters and return a function", "// whose signature is data, render.", "// see https://mustache.github.io/mustache.5.html", "mixin", "[", "'h'", "+", "(", "idx", "+", "1", ")", "]", "=", "function", "(", ")", "{", "return", "function", "(", "data", ",", "render", ")", "{", "var", "text", "=", "render", "(", "data", ")", ";", "var", "length", "=", "_", ".", "last", "(", "text", ".", "split", "(", "'\\n'", ")", ")", ".", "length", ";", "if", "(", "char", ".", "length", "===", "2", ")", "{", "text", "=", "repeatChar", "(", "char", "[", "1", "]", ",", "length", ")", "+", "'\\n'", "+", "text", ";", "}", "return", "text", "+", "'\\n'", "+", "repeatChar", "(", "char", "[", "0", "]", ",", "length", ")", ";", "}", ";", "}", ";", "}", ")", ";", "return", "mixin", ";", "}" ]
Create a mixin object containing mustache lambda function for heading. The function are named h1 to h[n]. @return {function} Mustache lambda
[ "Create", "a", "mixin", "object", "containing", "mustache", "lambda", "function", "for", "heading", "." ]
9d7c1d318ce535640588e7308917729c3849bc83
https://github.com/HumanBrainProject/jsdoc-sphinx/blob/9d7c1d318ce535640588e7308917729c3849bc83/template/util/rst-mixin.js#L37-L56
36,418
HumanBrainProject/jsdoc-sphinx
template/util/rst-mixin.js
pre
function pre() { return function(data, render) { // remove first line if empty ; it happens because of // the {{pre}} tag on one line. logger.debug('empty line:', Boolean(data.match(/^\s+\n/, ''))); data = data.replace(/^\s+\n/, ''); // Find the first non-empty lines tabulation var m = data.match(/^([ \r\t]+)[^\s]/m); if (!m) { return render(data); } var prefix = m[1]; // remove the prefix from the beginning of all lines before rendering data = data.replace(new RegExp('^' + prefix, 'mg'), ''); var output = render(data); output = output.replace(/\n/mg, '\n' + prefix); // Depending what kind of content is on the first line, it might // or might not keep the spacing... // if the first does not contains the pattern, add it if (data.substring(0, prefix.length) !== prefix) { output = prefix + output; } return output; }; }
javascript
function pre() { return function(data, render) { // remove first line if empty ; it happens because of // the {{pre}} tag on one line. logger.debug('empty line:', Boolean(data.match(/^\s+\n/, ''))); data = data.replace(/^\s+\n/, ''); // Find the first non-empty lines tabulation var m = data.match(/^([ \r\t]+)[^\s]/m); if (!m) { return render(data); } var prefix = m[1]; // remove the prefix from the beginning of all lines before rendering data = data.replace(new RegExp('^' + prefix, 'mg'), ''); var output = render(data); output = output.replace(/\n/mg, '\n' + prefix); // Depending what kind of content is on the first line, it might // or might not keep the spacing... // if the first does not contains the pattern, add it if (data.substring(0, prefix.length) !== prefix) { output = prefix + output; } return output; }; }
[ "function", "pre", "(", ")", "{", "return", "function", "(", "data", ",", "render", ")", "{", "// remove first line if empty ; it happens because of", "// the {{pre}} tag on one line.", "logger", ".", "debug", "(", "'empty line:'", ",", "Boolean", "(", "data", ".", "match", "(", "/", "^\\s+\\n", "/", ",", "''", ")", ")", ")", ";", "data", "=", "data", ".", "replace", "(", "/", "^\\s+\\n", "/", ",", "''", ")", ";", "// Find the first non-empty lines tabulation", "var", "m", "=", "data", ".", "match", "(", "/", "^([ \\r\\t]+)[^\\s]", "/", "m", ")", ";", "if", "(", "!", "m", ")", "{", "return", "render", "(", "data", ")", ";", "}", "var", "prefix", "=", "m", "[", "1", "]", ";", "// remove the prefix from the beginning of all lines before rendering", "data", "=", "data", ".", "replace", "(", "new", "RegExp", "(", "'^'", "+", "prefix", ",", "'mg'", ")", ",", "''", ")", ";", "var", "output", "=", "render", "(", "data", ")", ";", "output", "=", "output", ".", "replace", "(", "/", "\\n", "/", "mg", ",", "'\\n'", "+", "prefix", ")", ";", "// Depending what kind of content is on the first line, it might", "// or might not keep the spacing...", "// if the first does not contains the pattern, add it", "if", "(", "data", ".", "substring", "(", "0", ",", "prefix", ".", "length", ")", "!==", "prefix", ")", "{", "output", "=", "prefix", "+", "output", ";", "}", "return", "output", ";", "}", ";", "}" ]
Mustache lambda to preserve whitespace of the given string. @return {function} Mustache lambda
[ "Mustache", "lambda", "to", "preserve", "whitespace", "of", "the", "given", "string", "." ]
9d7c1d318ce535640588e7308917729c3849bc83
https://github.com/HumanBrainProject/jsdoc-sphinx/blob/9d7c1d318ce535640588e7308917729c3849bc83/template/util/rst-mixin.js#L63-L87
36,419
syntax-tree/unist-builder-blueprint
index.js
propsNode
function propsNode (node) { var props = flatmap(Object.keys(node), function (key) { if (key == 'type' || key == 'value' || key == 'children') { return; } var value = node[key]; if (key == 'data') { value = JSON.parse(JSON.stringify(value)); } return { type: 'Property', key: { type: 'Identifier', name: key }, value: literalNode(value) }; }); return props.length && { type: 'ObjectExpression', properties: props }; }
javascript
function propsNode (node) { var props = flatmap(Object.keys(node), function (key) { if (key == 'type' || key == 'value' || key == 'children') { return; } var value = node[key]; if (key == 'data') { value = JSON.parse(JSON.stringify(value)); } return { type: 'Property', key: { type: 'Identifier', name: key }, value: literalNode(value) }; }); return props.length && { type: 'ObjectExpression', properties: props }; }
[ "function", "propsNode", "(", "node", ")", "{", "var", "props", "=", "flatmap", "(", "Object", ".", "keys", "(", "node", ")", ",", "function", "(", "key", ")", "{", "if", "(", "key", "==", "'type'", "||", "key", "==", "'value'", "||", "key", "==", "'children'", ")", "{", "return", ";", "}", "var", "value", "=", "node", "[", "key", "]", ";", "if", "(", "key", "==", "'data'", ")", "{", "value", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "value", ")", ")", ";", "}", "return", "{", "type", ":", "'Property'", ",", "key", ":", "{", "type", ":", "'Identifier'", ",", "name", ":", "key", "}", ",", "value", ":", "literalNode", "(", "value", ")", "}", ";", "}", ")", ";", "return", "props", ".", "length", "&&", "{", "type", ":", "'ObjectExpression'", ",", "properties", ":", "props", "}", ";", "}" ]
Create ESTree object literal node representing Unist node properties.
[ "Create", "ESTree", "object", "literal", "node", "representing", "Unist", "node", "properties", "." ]
f63bf8f1474ea84cf1c127a3cc47814e7611783e
https://github.com/syntax-tree/unist-builder-blueprint/blob/f63bf8f1474ea84cf1c127a3cc47814e7611783e/index.js#L38-L64
36,420
syntax-tree/unist-builder-blueprint
index.js
literalNode
function literalNode (value) { if (value === undefined) { return { type: 'Identifier', name: 'undefined' }; } else if (typeof value == 'function') { throw Error('Unist property contains a function'); } else if (value === null || typeof value != 'object') { return { type: 'Literal', value: value }; } else if (Array.isArray(value)) { return { type: 'ArrayExpression', elements: value.map(literalNode) }; } else { return { type: 'ObjectExpression', properties: Object.keys(value).map(function (key) { return { type: 'Property', key: { type: 'Identifier', name: key }, value: literalNode(value[key]) }; }) }; } }
javascript
function literalNode (value) { if (value === undefined) { return { type: 'Identifier', name: 'undefined' }; } else if (typeof value == 'function') { throw Error('Unist property contains a function'); } else if (value === null || typeof value != 'object') { return { type: 'Literal', value: value }; } else if (Array.isArray(value)) { return { type: 'ArrayExpression', elements: value.map(literalNode) }; } else { return { type: 'ObjectExpression', properties: Object.keys(value).map(function (key) { return { type: 'Property', key: { type: 'Identifier', name: key }, value: literalNode(value[key]) }; }) }; } }
[ "function", "literalNode", "(", "value", ")", "{", "if", "(", "value", "===", "undefined", ")", "{", "return", "{", "type", ":", "'Identifier'", ",", "name", ":", "'undefined'", "}", ";", "}", "else", "if", "(", "typeof", "value", "==", "'function'", ")", "{", "throw", "Error", "(", "'Unist property contains a function'", ")", ";", "}", "else", "if", "(", "value", "===", "null", "||", "typeof", "value", "!=", "'object'", ")", "{", "return", "{", "type", ":", "'Literal'", ",", "value", ":", "value", "}", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "value", ")", ")", "{", "return", "{", "type", ":", "'ArrayExpression'", ",", "elements", ":", "value", ".", "map", "(", "literalNode", ")", "}", ";", "}", "else", "{", "return", "{", "type", ":", "'ObjectExpression'", ",", "properties", ":", "Object", ".", "keys", "(", "value", ")", ".", "map", "(", "function", "(", "key", ")", "{", "return", "{", "type", ":", "'Property'", ",", "key", ":", "{", "type", ":", "'Identifier'", ",", "name", ":", "key", "}", ",", "value", ":", "literalNode", "(", "value", "[", "key", "]", ")", "}", ";", "}", ")", "}", ";", "}", "}" ]
Create ESTree node representing particular JavaScript literal.
[ "Create", "ESTree", "node", "representing", "particular", "JavaScript", "literal", "." ]
f63bf8f1474ea84cf1c127a3cc47814e7611783e
https://github.com/syntax-tree/unist-builder-blueprint/blob/f63bf8f1474ea84cf1c127a3cc47814e7611783e/index.js#L68-L105
36,421
avoidwork/abaaso
src/promise.js
function ( parent, child ) { parent.then( function ( arg ) { child.resolve( arg ); }, function ( e ) { child.reject( e ); }); }
javascript
function ( parent, child ) { parent.then( function ( arg ) { child.resolve( arg ); }, function ( e ) { child.reject( e ); }); }
[ "function", "(", "parent", ",", "child", ")", "{", "parent", ".", "then", "(", "function", "(", "arg", ")", "{", "child", ".", "resolve", "(", "arg", ")", ";", "}", ",", "function", "(", "e", ")", "{", "child", ".", "reject", "(", "e", ")", ";", "}", ")", ";", "}" ]
Pipes a reconciliation from `parent` to `child` @method pipe @param {Object} parent Promise @param {Object} child Promise @return {Undefined} undefined
[ "Pipes", "a", "reconciliation", "from", "parent", "to", "child" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/src/promise.js#L43-L49
36,422
avoidwork/abaaso
src/promise.js
function ( obj, arg, state ) { if ( obj.state > promise.state.PENDING ) { return; } obj.value = arg; obj.state = state; if ( !obj.deferred ) { promise.delay( function () { obj.process(); }); obj.deferred = true; } return obj; }
javascript
function ( obj, arg, state ) { if ( obj.state > promise.state.PENDING ) { return; } obj.value = arg; obj.state = state; if ( !obj.deferred ) { promise.delay( function () { obj.process(); }); obj.deferred = true; } return obj; }
[ "function", "(", "obj", ",", "arg", ",", "state", ")", "{", "if", "(", "obj", ".", "state", ">", "promise", ".", "state", ".", "PENDING", ")", "{", "return", ";", "}", "obj", ".", "value", "=", "arg", ";", "obj", ".", "state", "=", "state", ";", "if", "(", "!", "obj", ".", "deferred", ")", "{", "promise", ".", "delay", "(", "function", "(", ")", "{", "obj", ".", "process", "(", ")", ";", "}", ")", ";", "obj", ".", "deferred", "=", "true", ";", "}", "return", "obj", ";", "}" ]
Initiates processing a Promise @memberOf process @param {Object} obj Promise instance @param {Mixed} arg Promise value @param {Number} state State, e.g. "1" @return {Object} Promise instance
[ "Initiates", "processing", "a", "Promise" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/src/promise.js#L60-L77
36,423
HumanBrainProject/jsdoc-sphinx
template/util/index.js
view
function view(name, model, cb) { var basePath = path.join(path.dirname(__filename), '../views'); var render = function(err, files) { if (err) { cb(err); } cb(null, mustache.render(files[0], model, { toctreeChildren: files[1], func: files[2], member: files[3], constant: files[3], typedef: files[5] })); }; async.parallel(_.map([ name, '_toctree-children', '_function', '_member', '_member', '_typedef' ], function(p) { return function(cb) { fs.readFile(path.join(basePath, p + '.mustache'), 'utf-8', cb); }; }), render); }
javascript
function view(name, model, cb) { var basePath = path.join(path.dirname(__filename), '../views'); var render = function(err, files) { if (err) { cb(err); } cb(null, mustache.render(files[0], model, { toctreeChildren: files[1], func: files[2], member: files[3], constant: files[3], typedef: files[5] })); }; async.parallel(_.map([ name, '_toctree-children', '_function', '_member', '_member', '_typedef' ], function(p) { return function(cb) { fs.readFile(path.join(basePath, p + '.mustache'), 'utf-8', cb); }; }), render); }
[ "function", "view", "(", "name", ",", "model", ",", "cb", ")", "{", "var", "basePath", "=", "path", ".", "join", "(", "path", ".", "dirname", "(", "__filename", ")", ",", "'../views'", ")", ";", "var", "render", "=", "function", "(", "err", ",", "files", ")", "{", "if", "(", "err", ")", "{", "cb", "(", "err", ")", ";", "}", "cb", "(", "null", ",", "mustache", ".", "render", "(", "files", "[", "0", "]", ",", "model", ",", "{", "toctreeChildren", ":", "files", "[", "1", "]", ",", "func", ":", "files", "[", "2", "]", ",", "member", ":", "files", "[", "3", "]", ",", "constant", ":", "files", "[", "3", "]", ",", "typedef", ":", "files", "[", "5", "]", "}", ")", ")", ";", "}", ";", "async", ".", "parallel", "(", "_", ".", "map", "(", "[", "name", ",", "'_toctree-children'", ",", "'_function'", ",", "'_member'", ",", "'_member'", ",", "'_typedef'", "]", ",", "function", "(", "p", ")", "{", "return", "function", "(", "cb", ")", "{", "fs", ".", "readFile", "(", "path", ".", "join", "(", "basePath", ",", "p", "+", "'.mustache'", ")", ",", "'utf-8'", ",", "cb", ")", ";", "}", ";", "}", ")", ",", "render", ")", ";", "}" ]
Generate the output string given a template name and the model. @param {string} name the template name without the extension. @param {object} model the ViewModel to use with the template @param {viewCallback} cb callback
[ "Generate", "the", "output", "string", "given", "a", "template", "name", "and", "the", "model", "." ]
9d7c1d318ce535640588e7308917729c3849bc83
https://github.com/HumanBrainProject/jsdoc-sphinx/blob/9d7c1d318ce535640588e7308917729c3849bc83/template/util/index.js#L24-L50
36,424
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { if ( !array.contains( obj, arg ) ) { obj.push( arg ); } return obj; }
javascript
function ( obj, arg ) { if ( !array.contains( obj, arg ) ) { obj.push( arg ); } return obj; }
[ "function", "(", "obj", ",", "arg", ")", "{", "if", "(", "!", "array", ".", "contains", "(", "obj", ",", "arg", ")", ")", "{", "obj", ".", "push", "(", "arg", ")", ";", "}", "return", "obj", ";", "}" ]
Adds 'arg' to 'obj' if it is not found @method add @param {Array} obj Array to receive 'arg' @param {Mixed} arg Argument to set in 'obj' @return {Array} Array that was queried
[ "Adds", "arg", "to", "obj", "if", "it", "is", "not", "found" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L167-L173
36,425
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { var min = 0, max = obj.length - 1, idx, val; while ( min <= max ) { idx = Math.floor( ( min + max ) / 2 ); val = obj[idx]; if ( val < arg ) { min = idx + 1; } else if ( val > arg ) { max = idx - 1; } else { return idx; } } return -1; }
javascript
function ( obj, arg ) { var min = 0, max = obj.length - 1, idx, val; while ( min <= max ) { idx = Math.floor( ( min + max ) / 2 ); val = obj[idx]; if ( val < arg ) { min = idx + 1; } else if ( val > arg ) { max = idx - 1; } else { return idx; } } return -1; }
[ "function", "(", "obj", ",", "arg", ")", "{", "var", "min", "=", "0", ",", "max", "=", "obj", ".", "length", "-", "1", ",", "idx", ",", "val", ";", "while", "(", "min", "<=", "max", ")", "{", "idx", "=", "Math", ".", "floor", "(", "(", "min", "+", "max", ")", "/", "2", ")", ";", "val", "=", "obj", "[", "idx", "]", ";", "if", "(", "val", "<", "arg", ")", "{", "min", "=", "idx", "+", "1", ";", "}", "else", "if", "(", "val", ">", "arg", ")", "{", "max", "=", "idx", "-", "1", ";", "}", "else", "{", "return", "idx", ";", "}", "}", "return", "-", "1", ";", "}" ]
Preforms a binary search on a sorted Array @method binIndex @param {Array} obj Array to search @param {Mixed} arg Value to find index of @return {Number} Index of `arg` within `obj`
[ "Preforms", "a", "binary", "search", "on", "a", "sorted", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L183-L204
36,426
avoidwork/abaaso
lib/abaaso.js
function ( obj, size ) { var result = [], nth = number.round( ( obj.length / size ), "up" ), start = 0, i = -1; while ( ++i < nth ) { start = i * size; result.push( array.limit( obj, start, size ) ); } return result; }
javascript
function ( obj, size ) { var result = [], nth = number.round( ( obj.length / size ), "up" ), start = 0, i = -1; while ( ++i < nth ) { start = i * size; result.push( array.limit( obj, start, size ) ); } return result; }
[ "function", "(", "obj", ",", "size", ")", "{", "var", "result", "=", "[", "]", ",", "nth", "=", "number", ".", "round", "(", "(", "obj", ".", "length", "/", "size", ")", ",", "\"up\"", ")", ",", "start", "=", "0", ",", "i", "=", "-", "1", ";", "while", "(", "++", "i", "<", "nth", ")", "{", "start", "=", "i", "*", "size", ";", "result", ".", "push", "(", "array", ".", "limit", "(", "obj", ",", "start", ",", "size", ")", ")", ";", "}", "return", "result", ";", "}" ]
Transforms an Array to a 2D Array of chunks @method chunk @param {Array} obj Array to parse @param {Number} size Chunk size ( integer ) @return {Array} Chunked Array
[ "Transforms", "an", "Array", "to", "a", "2D", "Array", "of", "chunks" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L274-L286
36,427
avoidwork/abaaso
lib/abaaso.js
function ( obj, fn ) { var result = []; array.each( obj, function ( i ) { result.push( fn( i ) ); }); return result; }
javascript
function ( obj, fn ) { var result = []; array.each( obj, function ( i ) { result.push( fn( i ) ); }); return result; }
[ "function", "(", "obj", ",", "fn", ")", "{", "var", "result", "=", "[", "]", ";", "array", ".", "each", "(", "obj", ",", "function", "(", "i", ")", "{", "result", ".", "push", "(", "fn", "(", "i", ")", ")", ";", "}", ")", ";", "return", "result", ";", "}" ]
Creates a new Array of the result of `fn` executed against every index of `obj` @method collect @param {Array} obj Array to iterate @param {Function} fn Function to execute against indices @return {Array} New Array
[ "Creates", "a", "new", "Array", "of", "the", "result", "of", "fn", "executed", "against", "every", "index", "of", "obj" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L330-L338
36,428
avoidwork/abaaso
lib/abaaso.js
function ( obj, diff ) { var result = []; result = obj.filter( function ( i ) { return !regex.null_undefined.test( i ); }); return !diff ? result : ( result.length < obj.length ? result : null ); }
javascript
function ( obj, diff ) { var result = []; result = obj.filter( function ( i ) { return !regex.null_undefined.test( i ); }); return !diff ? result : ( result.length < obj.length ? result : null ); }
[ "function", "(", "obj", ",", "diff", ")", "{", "var", "result", "=", "[", "]", ";", "result", "=", "obj", ".", "filter", "(", "function", "(", "i", ")", "{", "return", "!", "regex", ".", "null_undefined", ".", "test", "(", "i", ")", ";", "}", ")", ";", "return", "!", "diff", "?", "result", ":", "(", "result", ".", "length", "<", "obj", ".", "length", "?", "result", ":", "null", ")", ";", "}" ]
Compacts a Array by removing `null` or `undefined` indices @method compact @param {Array} obj Array to compact @param {Boolean} diff Indicates to return resulting Array only if there's a difference @return {Array} Compacted copy of `obj`, or null ( if `diff` is passed & no diff is found )
[ "Compacts", "a", "Array", "by", "removing", "null", "or", "undefined", "indices" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L348-L356
36,429
avoidwork/abaaso
lib/abaaso.js
function ( array1, array2 ) { var result = []; array.each( array1, function ( i ) { if ( !array.contains( array2, i ) ) { array.add( result, i ); } }); array.each( array2, function ( i ) { if ( !array.contains( array1, i ) ) { array.add( result, i ); } }); return result; }
javascript
function ( array1, array2 ) { var result = []; array.each( array1, function ( i ) { if ( !array.contains( array2, i ) ) { array.add( result, i ); } }); array.each( array2, function ( i ) { if ( !array.contains( array1, i ) ) { array.add( result, i ); } }); return result; }
[ "function", "(", "array1", ",", "array2", ")", "{", "var", "result", "=", "[", "]", ";", "array", ".", "each", "(", "array1", ",", "function", "(", "i", ")", "{", "if", "(", "!", "array", ".", "contains", "(", "array2", ",", "i", ")", ")", "{", "array", ".", "add", "(", "result", ",", "i", ")", ";", "}", "}", ")", ";", "array", ".", "each", "(", "array2", ",", "function", "(", "i", ")", "{", "if", "(", "!", "array", ".", "contains", "(", "array1", ",", "i", ")", ")", "{", "array", ".", "add", "(", "result", ",", "i", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Finds the difference between array1 and array2 @method diff @param {Array} array1 Source Array @param {Array} array2 Comparison Array @return {Array} Array of the differences
[ "Finds", "the", "difference", "between", "array1", "and", "array2" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L380-L396
36,430
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg, start, offset ) { var fn = typeof arg === "function", l = obj.length, i = !isNaN( start ) ? start : 0, nth = !isNaN( offset ) ? i + offset : l - 1; if ( nth > ( l - 1) ) { nth = l - 1; } while ( i <= nth ) { obj[i] = fn ? arg( obj[i] ) : arg; i++; } return obj; }
javascript
function ( obj, arg, start, offset ) { var fn = typeof arg === "function", l = obj.length, i = !isNaN( start ) ? start : 0, nth = !isNaN( offset ) ? i + offset : l - 1; if ( nth > ( l - 1) ) { nth = l - 1; } while ( i <= nth ) { obj[i] = fn ? arg( obj[i] ) : arg; i++; } return obj; }
[ "function", "(", "obj", ",", "arg", ",", "start", ",", "offset", ")", "{", "var", "fn", "=", "typeof", "arg", "===", "\"function\"", ",", "l", "=", "obj", ".", "length", ",", "i", "=", "!", "isNaN", "(", "start", ")", "?", "start", ":", "0", ",", "nth", "=", "!", "isNaN", "(", "offset", ")", "?", "i", "+", "offset", ":", "l", "-", "1", ";", "if", "(", "nth", ">", "(", "l", "-", "1", ")", ")", "{", "nth", "=", "l", "-", "1", ";", "}", "while", "(", "i", "<=", "nth", ")", "{", "obj", "[", "i", "]", "=", "fn", "?", "arg", "(", "obj", "[", "i", "]", ")", ":", "arg", ";", "i", "++", ";", "}", "return", "obj", ";", "}" ]
Fills `obj` with the evalution of `arg`, optionally from `start` to `offset` @method fill @param {Array} obj Array to fill @param {Mixed} arg String, Number of Function to fill with @param {Number} start [Optional] Index to begin filling at @param {Number} end [Optional] Offset from start to stop filling at @return {Array} Filled Array
[ "Fills", "obj", "with", "the", "evalution", "of", "arg", "optionally", "from", "start", "to", "offset" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L515-L531
36,431
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { var result = []; result = obj.reduce( function ( a, b ) { return a.concat( b ); }, result ); return result; }
javascript
function ( obj ) { var result = []; result = obj.reduce( function ( a, b ) { return a.concat( b ); }, result ); return result; }
[ "function", "(", "obj", ")", "{", "var", "result", "=", "[", "]", ";", "result", "=", "obj", ".", "reduce", "(", "function", "(", "a", ",", "b", ")", "{", "return", "a", ".", "concat", "(", "b", ")", ";", "}", ",", "result", ")", ";", "return", "result", ";", "}" ]
Flattens a 2D Array @method flat @param {Array} obj 2D Array to flatten @return {Array} Flatten Array
[ "Flattens", "a", "2D", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L551-L559
36,432
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { var indexed = []; utility.iterate( obj, function ( v ) { indexed.push( v ); }); return indexed; }
javascript
function ( obj ) { var indexed = []; utility.iterate( obj, function ( v ) { indexed.push( v ); }); return indexed; }
[ "function", "(", "obj", ")", "{", "var", "indexed", "=", "[", "]", ";", "utility", ".", "iterate", "(", "obj", ",", "function", "(", "v", ")", "{", "indexed", ".", "push", "(", "v", ")", ";", "}", ")", ";", "return", "indexed", ";", "}" ]
Returns an Associative Array as an Indexed Array @method indexed @param {Array} obj Array to index @return {Array} Indexed Array
[ "Returns", "an", "Associative", "Array", "as", "an", "Indexed", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L591-L599
36,433
avoidwork/abaaso
lib/abaaso.js
function ( array1, array2 ) { var a = array1.length > array2.length ? array1 : array2, b = ( a === array1 ? array2 : array1 ); return a.filter( function ( key ) { return array.contains( b, key ); }); }
javascript
function ( array1, array2 ) { var a = array1.length > array2.length ? array1 : array2, b = ( a === array1 ? array2 : array1 ); return a.filter( function ( key ) { return array.contains( b, key ); }); }
[ "function", "(", "array1", ",", "array2", ")", "{", "var", "a", "=", "array1", ".", "length", ">", "array2", ".", "length", "?", "array1", ":", "array2", ",", "b", "=", "(", "a", "===", "array1", "?", "array2", ":", "array1", ")", ";", "return", "a", ".", "filter", "(", "function", "(", "key", ")", "{", "return", "array", ".", "contains", "(", "b", ",", "key", ")", ";", "}", ")", ";", "}" ]
Finds the intersections between array1 and array2 @method intersect @param {Array} array1 Source Array @param {Array} array2 Comparison Array @return {Array} Array of the intersections
[ "Finds", "the", "intersections", "between", "array1", "and", "array2" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L609-L616
36,434
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { var n = obj.length - 1; if ( arg >= ( n + 1 ) ) { return obj; } else if ( isNaN( arg ) || arg === 1 ) { return obj[n]; } else { return array.limit( obj, ( n - ( --arg ) ), n ); } }
javascript
function ( obj, arg ) { var n = obj.length - 1; if ( arg >= ( n + 1 ) ) { return obj; } else if ( isNaN( arg ) || arg === 1 ) { return obj[n]; } else { return array.limit( obj, ( n - ( --arg ) ), n ); } }
[ "function", "(", "obj", ",", "arg", ")", "{", "var", "n", "=", "obj", ".", "length", "-", "1", ";", "if", "(", "arg", ">=", "(", "n", "+", "1", ")", ")", "{", "return", "obj", ";", "}", "else", "if", "(", "isNaN", "(", "arg", ")", "||", "arg", "===", "1", ")", "{", "return", "obj", "[", "n", "]", ";", "}", "else", "{", "return", "array", ".", "limit", "(", "obj", ",", "(", "n", "-", "(", "--", "arg", ")", ")", ",", "n", ")", ";", "}", "}" ]
Returns the last index of the Array @method last @param {Array} obj Array @param {Number} arg [Optional] Negative offset from last index to return @return {Mixed} Last index( s ) of Array
[ "Returns", "the", "last", "index", "of", "the", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L717-L729
36,435
avoidwork/abaaso
lib/abaaso.js
function ( obj, start, offset ) { var result = [], i = start - 1, nth = start + offset, max = obj.length; if ( max > 0 ) { while ( ++i < nth && i < max ) { result.push( obj[i] ); } } return result; }
javascript
function ( obj, start, offset ) { var result = [], i = start - 1, nth = start + offset, max = obj.length; if ( max > 0 ) { while ( ++i < nth && i < max ) { result.push( obj[i] ); } } return result; }
[ "function", "(", "obj", ",", "start", ",", "offset", ")", "{", "var", "result", "=", "[", "]", ",", "i", "=", "start", "-", "1", ",", "nth", "=", "start", "+", "offset", ",", "max", "=", "obj", ".", "length", ";", "if", "(", "max", ">", "0", ")", "{", "while", "(", "++", "i", "<", "nth", "&&", "i", "<", "max", ")", "{", "result", ".", "push", "(", "obj", "[", "i", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Returns a limited range of indices from the Array @method limit @param {Array} obj Array to iterate @param {Number} start Starting index @param {Number} offset Number of indices to return @return {Array} Array of indices
[ "Returns", "a", "limited", "range", "of", "indices", "from", "the", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L740-L753
36,436
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { array.each( arg, function ( i ) { array.add( obj, i ); }); return obj; }
javascript
function ( obj, arg ) { array.each( arg, function ( i ) { array.add( obj, i ); }); return obj; }
[ "function", "(", "obj", ",", "arg", ")", "{", "array", ".", "each", "(", "arg", ",", "function", "(", "i", ")", "{", "array", ".", "add", "(", "obj", ",", "i", ")", ";", "}", ")", ";", "return", "obj", ";", "}" ]
Merges `arg` into `obj`, excluding duplicate indices @method merge @param {Array} obj Array to receive indices @param {Array} arg Array to merge @return {Array} obj
[ "Merges", "arg", "into", "obj", "excluding", "duplicate", "indices" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L800-L806
36,437
avoidwork/abaaso
lib/abaaso.js
function ( obj1, obj2 ) { var result; result = obj1.map( function ( i, idx ) { return [i, obj2[idx]]; }); return result; }
javascript
function ( obj1, obj2 ) { var result; result = obj1.map( function ( i, idx ) { return [i, obj2[idx]]; }); return result; }
[ "function", "(", "obj1", ",", "obj2", ")", "{", "var", "result", ";", "result", "=", "obj1", ".", "map", "(", "function", "(", "i", ",", "idx", ")", "{", "return", "[", "i", ",", "obj2", "[", "idx", "]", "]", ";", "}", ")", ";", "return", "result", ";", "}" ]
Mingles Arrays and returns a 2D Array @method mingle @param {Array} obj1 Array to mingle @param {Array} obj2 Array to mingle @return {Array} 2D Array
[ "Mingles", "Arrays", "and", "returns", "a", "2D", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L827-L835
36,438
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { var values = {}, count = 0, nth = 0, mode = [], result; // Counting values array.each( obj, function ( i ) { if ( !isNaN( values[i] ) ) { values[i]++; } else { values[i] = 1; } }); // Finding the highest occurring count count = array.max( array.cast( values ) ); // Finding values that match the count utility.iterate( values, function ( v, k ) { if ( v === count ) { mode.push( number.parse( k ) ); } }); // Determining the result nth = mode.length; if ( nth > 0 ) { result = nth === 1 ? mode[0] : mode; } return result; }
javascript
function ( obj ) { var values = {}, count = 0, nth = 0, mode = [], result; // Counting values array.each( obj, function ( i ) { if ( !isNaN( values[i] ) ) { values[i]++; } else { values[i] = 1; } }); // Finding the highest occurring count count = array.max( array.cast( values ) ); // Finding values that match the count utility.iterate( values, function ( v, k ) { if ( v === count ) { mode.push( number.parse( k ) ); } }); // Determining the result nth = mode.length; if ( nth > 0 ) { result = nth === 1 ? mode[0] : mode; } return result; }
[ "function", "(", "obj", ")", "{", "var", "values", "=", "{", "}", ",", "count", "=", "0", ",", "nth", "=", "0", ",", "mode", "=", "[", "]", ",", "result", ";", "// Counting values", "array", ".", "each", "(", "obj", ",", "function", "(", "i", ")", "{", "if", "(", "!", "isNaN", "(", "values", "[", "i", "]", ")", ")", "{", "values", "[", "i", "]", "++", ";", "}", "else", "{", "values", "[", "i", "]", "=", "1", ";", "}", "}", ")", ";", "// Finding the highest occurring count", "count", "=", "array", ".", "max", "(", "array", ".", "cast", "(", "values", ")", ")", ";", "// Finding values that match the count", "utility", ".", "iterate", "(", "values", ",", "function", "(", "v", ",", "k", ")", "{", "if", "(", "v", "===", "count", ")", "{", "mode", ".", "push", "(", "number", ".", "parse", "(", "k", ")", ")", ";", "}", "}", ")", ";", "// Determining the result", "nth", "=", "mode", ".", "length", ";", "if", "(", "nth", ">", "0", ")", "{", "result", "=", "nth", "===", "1", "?", "mode", "[", "0", "]", ":", "mode", ";", "}", "return", "result", ";", "}" ]
Finds the mode value of an Array @method mode @param {Array} obj Array to parse @return {Mixed} Mode value of the Array
[ "Finds", "the", "mode", "value", "of", "an", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L844-L879
36,439
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { array.remove( obj, 0, obj.length ); array.each( arg, function ( i ) { obj.push( i ); }); return obj; }
javascript
function ( obj, arg ) { array.remove( obj, 0, obj.length ); array.each( arg, function ( i ) { obj.push( i ); }); return obj; }
[ "function", "(", "obj", ",", "arg", ")", "{", "array", ".", "remove", "(", "obj", ",", "0", ",", "obj", ".", "length", ")", ";", "array", ".", "each", "(", "arg", ",", "function", "(", "i", ")", "{", "obj", ".", "push", "(", "i", ")", ";", "}", ")", ";", "return", "obj", ";", "}" ]
Replaces the contents of `obj` with `arg` @method replace @param {Array} obj Array to modify @param {Array} arg Array to become `obj` @return {Array} New version of `obj`
[ "Replaces", "the", "contents", "of", "obj", "with", "arg" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L980-L987
36,440
avoidwork/abaaso
lib/abaaso.js
function ( obj, start, end ) { if ( isNaN( start ) ) { start = obj.index( start ); if ( start === -1 ) { return obj; } } else { start = start || 0; } var length = obj.length, remaining = obj.slice( ( end || start ) + 1 || length ); obj.length = start < 0 ? ( length + start ) : start; obj.push.apply( obj, remaining ); return obj; }
javascript
function ( obj, start, end ) { if ( isNaN( start ) ) { start = obj.index( start ); if ( start === -1 ) { return obj; } } else { start = start || 0; } var length = obj.length, remaining = obj.slice( ( end || start ) + 1 || length ); obj.length = start < 0 ? ( length + start ) : start; obj.push.apply( obj, remaining ); return obj; }
[ "function", "(", "obj", ",", "start", ",", "end", ")", "{", "if", "(", "isNaN", "(", "start", ")", ")", "{", "start", "=", "obj", ".", "index", "(", "start", ")", ";", "if", "(", "start", "===", "-", "1", ")", "{", "return", "obj", ";", "}", "}", "else", "{", "start", "=", "start", "||", "0", ";", "}", "var", "length", "=", "obj", ".", "length", ",", "remaining", "=", "obj", ".", "slice", "(", "(", "end", "||", "start", ")", "+", "1", "||", "length", ")", ";", "obj", ".", "length", "=", "start", "<", "0", "?", "(", "length", "+", "start", ")", ":", "start", ";", "obj", ".", "push", ".", "apply", "(", "obj", ",", "remaining", ")", ";", "return", "obj", ";", "}" ]
Removes indices from an Array without recreating it @method remove @param {Array} obj Array to remove from @param {Mixed} start Starting index, or value to find within obj @param {Number} end [Optional] Ending index @return {Array} Modified Array
[ "Removes", "indices", "from", "an", "Array", "without", "recreating", "it" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L998-L1017
36,441
avoidwork/abaaso
lib/abaaso.js
function ( obj, fn ) { var remove; if ( typeof fn !== "function" ) { throw new Error( label.error.invalidArguments ); } remove = obj.filter( fn ); array.each( remove, function ( i ) { array.remove( obj, array.index ( obj, i ) ); }); return obj; }
javascript
function ( obj, fn ) { var remove; if ( typeof fn !== "function" ) { throw new Error( label.error.invalidArguments ); } remove = obj.filter( fn ); array.each( remove, function ( i ) { array.remove( obj, array.index ( obj, i ) ); }); return obj; }
[ "function", "(", "obj", ",", "fn", ")", "{", "var", "remove", ";", "if", "(", "typeof", "fn", "!==", "\"function\"", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "invalidArguments", ")", ";", "}", "remove", "=", "obj", ".", "filter", "(", "fn", ")", ";", "array", ".", "each", "(", "remove", ",", "function", "(", "i", ")", "{", "array", ".", "remove", "(", "obj", ",", "array", ".", "index", "(", "obj", ",", "i", ")", ")", ";", "}", ")", ";", "return", "obj", ";", "}" ]
Deletes every element of `obj` for which `fn` evaluates to true @method removeIf @param {Array} obj Array to iterate @param {Function} fn Function to test indices against @return {Array} Array
[ "Deletes", "every", "element", "of", "obj", "for", "which", "fn", "evaluates", "to", "true" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1027-L1041
36,442
avoidwork/abaaso
lib/abaaso.js
function ( obj, fn ) { if ( typeof fn !== "function" ) { throw new Error( label.error.invalidArguments ); } var remove = []; array.each( obj, function ( i ) { if ( fn( i ) !== false ) { remove.push( i ); } else { return false; } }); array.each( remove, function ( i ) { array.remove( obj, array.index( obj, i) ); }); return obj; }
javascript
function ( obj, fn ) { if ( typeof fn !== "function" ) { throw new Error( label.error.invalidArguments ); } var remove = []; array.each( obj, function ( i ) { if ( fn( i ) !== false ) { remove.push( i ); } else { return false; } }); array.each( remove, function ( i ) { array.remove( obj, array.index( obj, i) ); }); return obj; }
[ "function", "(", "obj", ",", "fn", ")", "{", "if", "(", "typeof", "fn", "!==", "\"function\"", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "invalidArguments", ")", ";", "}", "var", "remove", "=", "[", "]", ";", "array", ".", "each", "(", "obj", ",", "function", "(", "i", ")", "{", "if", "(", "fn", "(", "i", ")", "!==", "false", ")", "{", "remove", ".", "push", "(", "i", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", ")", ";", "array", ".", "each", "(", "remove", ",", "function", "(", "i", ")", "{", "array", ".", "remove", "(", "obj", ",", "array", ".", "index", "(", "obj", ",", "i", ")", ")", ";", "}", ")", ";", "return", "obj", ";", "}" ]
Deletes elements of `obj` until `fn` evaluates to false @method removeWhile @param {Array} obj Array to iterate @param {Function} fn Function to test indices against @return {Array} Array
[ "Deletes", "elements", "of", "obj", "until", "fn", "evaluates", "to", "false" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1051-L1072
36,443
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { arg = arg || 1; if ( arg < 1 ) { arg = 1; } return array.limit( obj, arg, obj.length ); }
javascript
function ( obj, arg ) { arg = arg || 1; if ( arg < 1 ) { arg = 1; } return array.limit( obj, arg, obj.length ); }
[ "function", "(", "obj", ",", "arg", ")", "{", "arg", "=", "arg", "||", "1", ";", "if", "(", "arg", "<", "1", ")", "{", "arg", "=", "1", ";", "}", "return", "array", ".", "limit", "(", "obj", ",", "arg", ",", "obj", ".", "length", ")", ";", "}" ]
Returns the "rest" of `obj` from `arg` @method rest @param {Array} obj Array to parse @param {Number} arg [Optional] Start position of subset of `obj` ( positive number only ) @return {Array} Array of a subset of `obj`
[ "Returns", "the", "rest", "of", "obj", "from", "arg" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1082-L1090
36,444
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { var result = -1; array.each( obj, function ( i, idx ) { if ( i === arg ) { result = idx; } }); return result; }
javascript
function ( obj, arg ) { var result = -1; array.each( obj, function ( i, idx ) { if ( i === arg ) { result = idx; } }); return result; }
[ "function", "(", "obj", ",", "arg", ")", "{", "var", "result", "=", "-", "1", ";", "array", ".", "each", "(", "obj", ",", "function", "(", "i", ",", "idx", ")", "{", "if", "(", "i", "===", "arg", ")", "{", "result", "=", "idx", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Finds the last index of `arg` in `obj` @method rindex @param {Array} obj Array to search @param {Mixed} arg Primitive to find @return {Mixed} Index or undefined
[ "Finds", "the", "last", "index", "of", "arg", "in", "obj" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1100-L1110
36,445
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { var nth = obj.length, result; if ( arg === 0 ) { result = obj; } else { if ( arg < 0 ) { arg += nth; } else { arg--; } result = array.limit( obj, arg, nth ); result = result.concat( array.limit( obj, 0, arg ) ); } return result; }
javascript
function ( obj, arg ) { var nth = obj.length, result; if ( arg === 0 ) { result = obj; } else { if ( arg < 0 ) { arg += nth; } else { arg--; } result = array.limit( obj, arg, nth ); result = result.concat( array.limit( obj, 0, arg ) ); } return result; }
[ "function", "(", "obj", ",", "arg", ")", "{", "var", "nth", "=", "obj", ".", "length", ",", "result", ";", "if", "(", "arg", "===", "0", ")", "{", "result", "=", "obj", ";", "}", "else", "{", "if", "(", "arg", "<", "0", ")", "{", "arg", "+=", "nth", ";", "}", "else", "{", "arg", "--", ";", "}", "result", "=", "array", ".", "limit", "(", "obj", ",", "arg", ",", "nth", ")", ";", "result", "=", "result", ".", "concat", "(", "array", ".", "limit", "(", "obj", ",", "0", ",", "arg", ")", ")", ";", "}", "return", "result", ";", "}" ]
Returns new Array with `arg` moved to the first index @method rotate @param {Array} obj Array to rotate @param {Number} arg Index to become the first index, if negative the rotation is in the opposite direction @return {Array} Newly rotated Array
[ "Returns", "new", "Array", "with", "arg", "moved", "to", "the", "first", "index" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1120-L1140
36,446
avoidwork/abaaso
lib/abaaso.js
function ( start, end, offset ) { start = start || 0; end = end || start; offset = offset || 1; var result = [], n = -1, nth = Math.max( 0, Math.ceil( ( end - start ) / offset ) ); while ( ++n < nth ) { result[n] = start; start += offset; } return result; }
javascript
function ( start, end, offset ) { start = start || 0; end = end || start; offset = offset || 1; var result = [], n = -1, nth = Math.max( 0, Math.ceil( ( end - start ) / offset ) ); while ( ++n < nth ) { result[n] = start; start += offset; } return result; }
[ "function", "(", "start", ",", "end", ",", "offset", ")", "{", "start", "=", "start", "||", "0", ";", "end", "=", "end", "||", "start", ";", "offset", "=", "offset", "||", "1", ";", "var", "result", "=", "[", "]", ",", "n", "=", "-", "1", ",", "nth", "=", "Math", ".", "max", "(", "0", ",", "Math", ".", "ceil", "(", "(", "end", "-", "start", ")", "/", "offset", ")", ")", ";", "while", "(", "++", "n", "<", "nth", ")", "{", "result", "[", "n", "]", "=", "start", ";", "start", "+=", "offset", ";", "}", "return", "result", ";", "}" ]
Generates a series Array @method series @param {Number} start Start value the series @param {Number} end [Optional] The end of the series @param {Number} offset [Optional] Offset for indices, default is 1 @return {Array} Array of new series
[ "Generates", "a", "series", "Array" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1151-L1165
36,447
avoidwork/abaaso
lib/abaaso.js
function ( obj, divisor ) { var result = [], total = obj.length, nth = Math.ceil( total / divisor ), low = Math.floor( total / divisor ), lower = Math.ceil( total / nth ), lowered = false, start = 0, i = -1; // Finding the fold if ( number.diff( total, ( divisor * nth ) ) > nth ) { lower = total - ( low * divisor ) + low - 1; } else if ( total % divisor > 0 && lower * nth >= total ) { lower--; } while ( ++i < divisor ) { if ( i > 0 ) { start = start + nth; } if ( !lowered && lower < divisor && i === lower ) { --nth; lowered = true; } result.push( array.limit( obj, start, nth ) ); } return result; }
javascript
function ( obj, divisor ) { var result = [], total = obj.length, nth = Math.ceil( total / divisor ), low = Math.floor( total / divisor ), lower = Math.ceil( total / nth ), lowered = false, start = 0, i = -1; // Finding the fold if ( number.diff( total, ( divisor * nth ) ) > nth ) { lower = total - ( low * divisor ) + low - 1; } else if ( total % divisor > 0 && lower * nth >= total ) { lower--; } while ( ++i < divisor ) { if ( i > 0 ) { start = start + nth; } if ( !lowered && lower < divisor && i === lower ) { --nth; lowered = true; } result.push( array.limit( obj, start, nth ) ); } return result; }
[ "function", "(", "obj", ",", "divisor", ")", "{", "var", "result", "=", "[", "]", ",", "total", "=", "obj", ".", "length", ",", "nth", "=", "Math", ".", "ceil", "(", "total", "/", "divisor", ")", ",", "low", "=", "Math", ".", "floor", "(", "total", "/", "divisor", ")", ",", "lower", "=", "Math", ".", "ceil", "(", "total", "/", "nth", ")", ",", "lowered", "=", "false", ",", "start", "=", "0", ",", "i", "=", "-", "1", ";", "// Finding the fold", "if", "(", "number", ".", "diff", "(", "total", ",", "(", "divisor", "*", "nth", ")", ")", ">", "nth", ")", "{", "lower", "=", "total", "-", "(", "low", "*", "divisor", ")", "+", "low", "-", "1", ";", "}", "else", "if", "(", "total", "%", "divisor", ">", "0", "&&", "lower", "*", "nth", ">=", "total", ")", "{", "lower", "--", ";", "}", "while", "(", "++", "i", "<", "divisor", ")", "{", "if", "(", "i", ">", "0", ")", "{", "start", "=", "start", "+", "nth", ";", "}", "if", "(", "!", "lowered", "&&", "lower", "<", "divisor", "&&", "i", "===", "lower", ")", "{", "--", "nth", ";", "lowered", "=", "true", ";", "}", "result", ".", "push", "(", "array", ".", "limit", "(", "obj", ",", "start", ",", "nth", ")", ")", ";", "}", "return", "result", ";", "}" ]
Splits an Array by divisor @method split @param {Array} obj Array to parse @param {Number} divisor Integer to divide the Array by @return {Array} Split Array
[ "Splits", "an", "Array", "by", "divisor" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1175-L1207
36,448
avoidwork/abaaso
lib/abaaso.js
function ( a, b ) { var types = {a: typeof a, b: typeof b}, c, d, result; if ( types.a === "number" && types.b === "number" ) { result = a - b; } else { c = a.toString(); d = b.toString(); if ( c < d ) { result = -1; } else if ( c > d ) { result = 1; } else if ( types.a === types.b ) { result = 0; } else if ( types.a === "boolean" ) { result = -1; } else { result = 1; } } return result; }
javascript
function ( a, b ) { var types = {a: typeof a, b: typeof b}, c, d, result; if ( types.a === "number" && types.b === "number" ) { result = a - b; } else { c = a.toString(); d = b.toString(); if ( c < d ) { result = -1; } else if ( c > d ) { result = 1; } else if ( types.a === types.b ) { result = 0; } else if ( types.a === "boolean" ) { result = -1; } else { result = 1; } } return result; }
[ "function", "(", "a", ",", "b", ")", "{", "var", "types", "=", "{", "a", ":", "typeof", "a", ",", "b", ":", "typeof", "b", "}", ",", "c", ",", "d", ",", "result", ";", "if", "(", "types", ".", "a", "===", "\"number\"", "&&", "types", ".", "b", "===", "\"number\"", ")", "{", "result", "=", "a", "-", "b", ";", "}", "else", "{", "c", "=", "a", ".", "toString", "(", ")", ";", "d", "=", "b", ".", "toString", "(", ")", ";", "if", "(", "c", "<", "d", ")", "{", "result", "=", "-", "1", ";", "}", "else", "if", "(", "c", ">", "d", ")", "{", "result", "=", "1", ";", "}", "else", "if", "(", "types", ".", "a", "===", "types", ".", "b", ")", "{", "result", "=", "0", ";", "}", "else", "if", "(", "types", ".", "a", "===", "\"boolean\"", ")", "{", "result", "=", "-", "1", ";", "}", "else", "{", "result", "=", "1", ";", "}", "}", "return", "result", ";", "}" ]
Sorts the Array by parsing values @method sort @param {Mixed} a Argument to compare @param {Mixed} b Argument to compare @return {Number} Number indicating sort order
[ "Sorts", "the", "Array", "by", "parsing", "values" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1217-L1246
36,449
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { var result = 0; if ( obj.length > 0 ) { result = obj.reduce( function ( prev, cur ) { return prev + cur; }); } return result; }
javascript
function ( obj ) { var result = 0; if ( obj.length > 0 ) { result = obj.reduce( function ( prev, cur ) { return prev + cur; }); } return result; }
[ "function", "(", "obj", ")", "{", "var", "result", "=", "0", ";", "if", "(", "obj", ".", "length", ">", "0", ")", "{", "result", "=", "obj", ".", "reduce", "(", "function", "(", "prev", ",", "cur", ")", "{", "return", "prev", "+", "cur", ";", "}", ")", ";", "}", "return", "result", ";", "}" ]
Gets the summation of an Array of numbers @method sum @param {Array} obj Array to sum @return {Number} Summation of Array
[ "Gets", "the", "summation", "of", "an", "Array", "of", "numbers" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1277-L1287
36,450
avoidwork/abaaso
lib/abaaso.js
function ( ar ) { var obj = {}, i = ar.length; while ( i-- ) { obj[i.toString()] = ar[i]; } return obj; }
javascript
function ( ar ) { var obj = {}, i = ar.length; while ( i-- ) { obj[i.toString()] = ar[i]; } return obj; }
[ "function", "(", "ar", ")", "{", "var", "obj", "=", "{", "}", ",", "i", "=", "ar", ".", "length", ";", "while", "(", "i", "--", ")", "{", "obj", "[", "i", ".", "toString", "(", ")", "]", "=", "ar", "[", "i", "]", ";", "}", "return", "obj", ";", "}" ]
Casts an Array to Object @method toObject @param {Array} ar Array to transform @return {Object} New object
[ "Casts", "an", "Array", "to", "Object" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1319-L1328
36,451
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { var result = []; array.each( obj, function ( i ) { array.add( result, i ); }); return result; }
javascript
function ( obj ) { var result = []; array.each( obj, function ( i ) { array.add( result, i ); }); return result; }
[ "function", "(", "obj", ")", "{", "var", "result", "=", "[", "]", ";", "array", ".", "each", "(", "obj", ",", "function", "(", "i", ")", "{", "array", ".", "add", "(", "result", ",", "i", ")", ";", "}", ")", ";", "return", "result", ";", "}" ]
Returns an Array of unique indices of `obj` @method unique @param {Array} obj Array to parse @return {Array} Array of unique indices
[ "Returns", "an", "Array", "of", "unique", "indices", "of", "obj" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1337-L1345
36,452
avoidwork/abaaso
lib/abaaso.js
function ( obj, args ) { var result = []; // Preparing args if ( !(args instanceof Array) ) { args = typeof args === "object" ? array.cast( args ) : [args]; } array.each( args, function ( i, idx ) { if ( !( i instanceof Array ) ) { this[idx] = [i]; } }); // Building result Array array.each( obj, function ( i, idx ) { result[idx] = [i]; array.each( args, function ( x ) { result[idx].push( x[idx] || null ); }); }); return result; }
javascript
function ( obj, args ) { var result = []; // Preparing args if ( !(args instanceof Array) ) { args = typeof args === "object" ? array.cast( args ) : [args]; } array.each( args, function ( i, idx ) { if ( !( i instanceof Array ) ) { this[idx] = [i]; } }); // Building result Array array.each( obj, function ( i, idx ) { result[idx] = [i]; array.each( args, function ( x ) { result[idx].push( x[idx] || null ); }); }); return result; }
[ "function", "(", "obj", ",", "args", ")", "{", "var", "result", "=", "[", "]", ";", "// Preparing args", "if", "(", "!", "(", "args", "instanceof", "Array", ")", ")", "{", "args", "=", "typeof", "args", "===", "\"object\"", "?", "array", ".", "cast", "(", "args", ")", ":", "[", "args", "]", ";", "}", "array", ".", "each", "(", "args", ",", "function", "(", "i", ",", "idx", ")", "{", "if", "(", "!", "(", "i", "instanceof", "Array", ")", ")", "{", "this", "[", "idx", "]", "=", "[", "i", "]", ";", "}", "}", ")", ";", "// Building result Array", "array", ".", "each", "(", "obj", ",", "function", "(", "i", ",", "idx", ")", "{", "result", "[", "idx", "]", "=", "[", "i", "]", ";", "array", ".", "each", "(", "args", ",", "function", "(", "x", ")", "{", "result", "[", "idx", "]", ".", "push", "(", "x", "[", "idx", "]", "||", "null", ")", ";", "}", ")", ";", "}", ")", ";", "return", "result", ";", "}" ]
Converts any arguments to Arrays, then merges elements of `obj` with corresponding elements from each argument @method zip @param {Array} obj Array to transform @param {Mixed} args Argument instance or Array to merge @return {Array} Array
[ "Converts", "any", "arguments", "to", "Arrays", "then", "merges", "elements", "of", "obj", "with", "corresponding", "elements", "from", "each", "argument" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1381-L1404
36,453
avoidwork/abaaso
lib/abaaso.js
function () { return utility.iterate( cache.items, function ( v, k ) { if ( cache.expired( k ) ) { cache.expire( k, true ); } }); }
javascript
function () { return utility.iterate( cache.items, function ( v, k ) { if ( cache.expired( k ) ) { cache.expire( k, true ); } }); }
[ "function", "(", ")", "{", "return", "utility", ".", "iterate", "(", "cache", ".", "items", ",", "function", "(", "v", ",", "k", ")", "{", "if", "(", "cache", ".", "expired", "(", "k", ")", ")", "{", "cache", ".", "expire", "(", "k", ",", "true", ")", ";", "}", "}", ")", ";", "}" ]
Garbage collector for the cached items @method clean @private @return {Undefined} undefined
[ "Garbage", "collector", "for", "the", "cached", "items" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1419-L1425
36,454
avoidwork/abaaso
lib/abaaso.js
function ( uri, silent ) { silent = ( silent === true ); if ( cache.items[uri] !== undefined ) { delete cache.items[uri]; if ( !silent ) { observer.fire( uri, "beforeExpire, expire, afterExpire" ); } return true; } else { return false; } }
javascript
function ( uri, silent ) { silent = ( silent === true ); if ( cache.items[uri] !== undefined ) { delete cache.items[uri]; if ( !silent ) { observer.fire( uri, "beforeExpire, expire, afterExpire" ); } return true; } else { return false; } }
[ "function", "(", "uri", ",", "silent", ")", "{", "silent", "=", "(", "silent", "===", "true", ")", ";", "if", "(", "cache", ".", "items", "[", "uri", "]", "!==", "undefined", ")", "{", "delete", "cache", ".", "items", "[", "uri", "]", ";", "if", "(", "!", "silent", ")", "{", "observer", ".", "fire", "(", "uri", ",", "\"beforeExpire, expire, afterExpire\"", ")", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Expires a URI from the local cache Events: expire Fires when the URI expires @method expire @private @param {String} uri URI of the local representation @param {Boolean} silent [Optional] If 'true', the event will not fire @return {Undefined} undefined
[ "Expires", "a", "URI", "from", "the", "local", "cache" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1438-L1452
36,455
avoidwork/abaaso
lib/abaaso.js
function ( uri ) { var item = cache.items[uri]; return item !== undefined && item.expires !== undefined && item.expires < new Date(); }
javascript
function ( uri ) { var item = cache.items[uri]; return item !== undefined && item.expires !== undefined && item.expires < new Date(); }
[ "function", "(", "uri", ")", "{", "var", "item", "=", "cache", ".", "items", "[", "uri", "]", ";", "return", "item", "!==", "undefined", "&&", "item", ".", "expires", "!==", "undefined", "&&", "item", ".", "expires", "<", "new", "Date", "(", ")", ";", "}" ]
Determines if a URI has expired @method expired @private @param {Object} uri Cached URI object @return {Boolean} True if the URI has expired
[ "Determines", "if", "a", "URI", "has", "expired" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1462-L1466
36,456
avoidwork/abaaso
lib/abaaso.js
function ( uri, property, value ) { uri = utility.parse( uri ).href; if ( cache.items[uri] === undefined ) { cache.items[uri] = {}; cache.items[uri].permission = 0; } if ( property === "permission" ) { cache.items[uri].permission |= value; } else if ( property === "!permission" ) { cache.items[uri].permission &= ~value; } else { cache.items[uri][property] = value; } return cache.items[uri]; }
javascript
function ( uri, property, value ) { uri = utility.parse( uri ).href; if ( cache.items[uri] === undefined ) { cache.items[uri] = {}; cache.items[uri].permission = 0; } if ( property === "permission" ) { cache.items[uri].permission |= value; } else if ( property === "!permission" ) { cache.items[uri].permission &= ~value; } else { cache.items[uri][property] = value; } return cache.items[uri]; }
[ "function", "(", "uri", ",", "property", ",", "value", ")", "{", "uri", "=", "utility", ".", "parse", "(", "uri", ")", ".", "href", ";", "if", "(", "cache", ".", "items", "[", "uri", "]", "===", "undefined", ")", "{", "cache", ".", "items", "[", "uri", "]", "=", "{", "}", ";", "cache", ".", "items", "[", "uri", "]", ".", "permission", "=", "0", ";", "}", "if", "(", "property", "===", "\"permission\"", ")", "{", "cache", ".", "items", "[", "uri", "]", ".", "permission", "|=", "value", ";", "}", "else", "if", "(", "property", "===", "\"!permission\"", ")", "{", "cache", ".", "items", "[", "uri", "]", ".", "permission", "&=", "~", "value", ";", "}", "else", "{", "cache", ".", "items", "[", "uri", "]", "[", "property", "]", "=", "value", ";", "}", "return", "cache", ".", "items", "[", "uri", "]", ";", "}" ]
Sets, or updates an item in cache.items @method set @private @param {String} uri URI to set or update @param {String} property Property of the cached URI to set @param {Mixed} value Value to set @return {Mixed} URI Object {headers, response} or undefined
[ "Sets", "or", "updates", "an", "item", "in", "cache", ".", "items" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1505-L1524
36,457
avoidwork/abaaso
lib/abaaso.js
function ( uri, verb ) { if ( string.isEmpty( uri ) || string.isEmpty( verb ) ) { throw new Error( label.error.invalidArguments ); } uri = utility.parse( uri ).href; verb = verb.toLowerCase(); var result = false, bit = 0; if ( !cache.get( uri, false ) ) { result = undefined; } else { if ( regex.del.test( verb ) ) { bit = 1; } else if ( regex.get_headers.test( verb ) ) { bit = 4; } else if ( regex.put_post.test( verb ) ) { bit = 2; } else if ( regex.patch.test( verb ) ) { bit = 8; } result = Boolean( client.permissions( uri, verb ).bit & bit ); } return result; }
javascript
function ( uri, verb ) { if ( string.isEmpty( uri ) || string.isEmpty( verb ) ) { throw new Error( label.error.invalidArguments ); } uri = utility.parse( uri ).href; verb = verb.toLowerCase(); var result = false, bit = 0; if ( !cache.get( uri, false ) ) { result = undefined; } else { if ( regex.del.test( verb ) ) { bit = 1; } else if ( regex.get_headers.test( verb ) ) { bit = 4; } else if ( regex.put_post.test( verb ) ) { bit = 2; } else if ( regex.patch.test( verb ) ) { bit = 8; } result = Boolean( client.permissions( uri, verb ).bit & bit ); } return result; }
[ "function", "(", "uri", ",", "verb", ")", "{", "if", "(", "string", ".", "isEmpty", "(", "uri", ")", "||", "string", ".", "isEmpty", "(", "verb", ")", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "invalidArguments", ")", ";", "}", "uri", "=", "utility", ".", "parse", "(", "uri", ")", ".", "href", ";", "verb", "=", "verb", ".", "toLowerCase", "(", ")", ";", "var", "result", "=", "false", ",", "bit", "=", "0", ";", "if", "(", "!", "cache", ".", "get", "(", "uri", ",", "false", ")", ")", "{", "result", "=", "undefined", ";", "}", "else", "{", "if", "(", "regex", ".", "del", ".", "test", "(", "verb", ")", ")", "{", "bit", "=", "1", ";", "}", "else", "if", "(", "regex", ".", "get_headers", ".", "test", "(", "verb", ")", ")", "{", "bit", "=", "4", ";", "}", "else", "if", "(", "regex", ".", "put_post", ".", "test", "(", "verb", ")", ")", "{", "bit", "=", "2", ";", "}", "else", "if", "(", "regex", ".", "patch", ".", "test", "(", "verb", ")", ")", "{", "bit", "=", "8", ";", "}", "result", "=", "Boolean", "(", "client", ".", "permissions", "(", "uri", ",", "verb", ")", ".", "bit", "&", "bit", ")", ";", "}", "return", "result", ";", "}" ]
Quick way to see if a URI allows a specific verb @method allows @param {String} uri URI to query @param {String} verb HTTP verb @return {Boolean} `true` if the verb is allowed, undefined if unknown
[ "Quick", "way", "to", "see", "if", "a", "URI", "allows", "a", "specific", "verb" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1816-L1847
36,458
avoidwork/abaaso
lib/abaaso.js
function ( args ) { var result = 0; array.each( args, function ( verb ) { verb = verb.toLowerCase(); if ( regex.get_headers.test( verb ) ) { result |= 4; } else if ( regex.put_post.test( verb ) ) { result |= 2; } else if ( regex.patch.test( verb ) ) { result |= 8; } else if ( regex.del.test( verb ) ) { result |= 1; } }); return result; }
javascript
function ( args ) { var result = 0; array.each( args, function ( verb ) { verb = verb.toLowerCase(); if ( regex.get_headers.test( verb ) ) { result |= 4; } else if ( regex.put_post.test( verb ) ) { result |= 2; } else if ( regex.patch.test( verb ) ) { result |= 8; } else if ( regex.del.test( verb ) ) { result |= 1; } }); return result; }
[ "function", "(", "args", ")", "{", "var", "result", "=", "0", ";", "array", ".", "each", "(", "args", ",", "function", "(", "verb", ")", "{", "verb", "=", "verb", ".", "toLowerCase", "(", ")", ";", "if", "(", "regex", ".", "get_headers", ".", "test", "(", "verb", ")", ")", "{", "result", "|=", "4", ";", "}", "else", "if", "(", "regex", ".", "put_post", ".", "test", "(", "verb", ")", ")", "{", "result", "|=", "2", ";", "}", "else", "if", "(", "regex", ".", "patch", ".", "test", "(", "verb", ")", ")", "{", "result", "|=", "8", ";", "}", "else", "if", "(", "regex", ".", "del", ".", "test", "(", "verb", ")", ")", "{", "result", "|=", "1", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Gets bit value based on args @method bit @param {Array} args Array of commands the URI accepts @return {Number} To be set as a bit
[ "Gets", "bit", "value", "based", "on", "args" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1856-L1877
36,459
avoidwork/abaaso
lib/abaaso.js
function ( xhr, uri, type ) { var headers = string.trim( xhr.getAllResponseHeaders() ).split( "\n" ), items = {}, o = {}, allow = null, expires = new Date(), cors = client.cors( uri ); array.each( headers, function ( i ) { var header, value; value = i.replace( regex.header_value_replace, "" ); header = i.replace( regex.header_replace, "" ); header = string.unhyphenate( header, true ).replace( /\s+/g, "-" ); items[header] = value; if ( allow === null ) { if ( ( !cors && regex.allow.test( header) ) || ( cors && regex.allow_cors.test( header) ) ) { allow = value; } } }); if ( regex.no.test( items["Cache-Control"] ) ) { // Do nothing } else if ( items["Cache-Control"] !== undefined && regex.number_present.test( items["Cache-Control"] ) ) { expires = expires.setSeconds( expires.getSeconds() + number.parse( regex.number_present.exec( items["Cache-Control"] )[0], 10 ) ); } else if ( items.Expires !== undefined ) { expires = new Date( items.Expires ); } else { expires = expires.setSeconds( expires.getSeconds() + $.expires ); } o.expires = expires; o.headers = items; o.permission = client.bit( allow !== null ? string.explode( allow ) : [type] ); if ( type === "get" ) { cache.set( uri, "expires", o.expires ); cache.set( uri, "headers", o.headers ); cache.set( uri, "permission", o.permission ); } return o; }
javascript
function ( xhr, uri, type ) { var headers = string.trim( xhr.getAllResponseHeaders() ).split( "\n" ), items = {}, o = {}, allow = null, expires = new Date(), cors = client.cors( uri ); array.each( headers, function ( i ) { var header, value; value = i.replace( regex.header_value_replace, "" ); header = i.replace( regex.header_replace, "" ); header = string.unhyphenate( header, true ).replace( /\s+/g, "-" ); items[header] = value; if ( allow === null ) { if ( ( !cors && regex.allow.test( header) ) || ( cors && regex.allow_cors.test( header) ) ) { allow = value; } } }); if ( regex.no.test( items["Cache-Control"] ) ) { // Do nothing } else if ( items["Cache-Control"] !== undefined && regex.number_present.test( items["Cache-Control"] ) ) { expires = expires.setSeconds( expires.getSeconds() + number.parse( regex.number_present.exec( items["Cache-Control"] )[0], 10 ) ); } else if ( items.Expires !== undefined ) { expires = new Date( items.Expires ); } else { expires = expires.setSeconds( expires.getSeconds() + $.expires ); } o.expires = expires; o.headers = items; o.permission = client.bit( allow !== null ? string.explode( allow ) : [type] ); if ( type === "get" ) { cache.set( uri, "expires", o.expires ); cache.set( uri, "headers", o.headers ); cache.set( uri, "permission", o.permission ); } return o; }
[ "function", "(", "xhr", ",", "uri", ",", "type", ")", "{", "var", "headers", "=", "string", ".", "trim", "(", "xhr", ".", "getAllResponseHeaders", "(", ")", ")", ".", "split", "(", "\"\\n\"", ")", ",", "items", "=", "{", "}", ",", "o", "=", "{", "}", ",", "allow", "=", "null", ",", "expires", "=", "new", "Date", "(", ")", ",", "cors", "=", "client", ".", "cors", "(", "uri", ")", ";", "array", ".", "each", "(", "headers", ",", "function", "(", "i", ")", "{", "var", "header", ",", "value", ";", "value", "=", "i", ".", "replace", "(", "regex", ".", "header_value_replace", ",", "\"\"", ")", ";", "header", "=", "i", ".", "replace", "(", "regex", ".", "header_replace", ",", "\"\"", ")", ";", "header", "=", "string", ".", "unhyphenate", "(", "header", ",", "true", ")", ".", "replace", "(", "/", "\\s+", "/", "g", ",", "\"-\"", ")", ";", "items", "[", "header", "]", "=", "value", ";", "if", "(", "allow", "===", "null", ")", "{", "if", "(", "(", "!", "cors", "&&", "regex", ".", "allow", ".", "test", "(", "header", ")", ")", "||", "(", "cors", "&&", "regex", ".", "allow_cors", ".", "test", "(", "header", ")", ")", ")", "{", "allow", "=", "value", ";", "}", "}", "}", ")", ";", "if", "(", "regex", ".", "no", ".", "test", "(", "items", "[", "\"Cache-Control\"", "]", ")", ")", "{", "// Do nothing", "}", "else", "if", "(", "items", "[", "\"Cache-Control\"", "]", "!==", "undefined", "&&", "regex", ".", "number_present", ".", "test", "(", "items", "[", "\"Cache-Control\"", "]", ")", ")", "{", "expires", "=", "expires", ".", "setSeconds", "(", "expires", ".", "getSeconds", "(", ")", "+", "number", ".", "parse", "(", "regex", ".", "number_present", ".", "exec", "(", "items", "[", "\"Cache-Control\"", "]", ")", "[", "0", "]", ",", "10", ")", ")", ";", "}", "else", "if", "(", "items", ".", "Expires", "!==", "undefined", ")", "{", "expires", "=", "new", "Date", "(", "items", ".", "Expires", ")", ";", "}", "else", "{", "expires", "=", "expires", ".", "setSeconds", "(", "expires", ".", "getSeconds", "(", ")", "+", "$", ".", "expires", ")", ";", "}", "o", ".", "expires", "=", "expires", ";", "o", ".", "headers", "=", "items", ";", "o", ".", "permission", "=", "client", ".", "bit", "(", "allow", "!==", "null", "?", "string", ".", "explode", "(", "allow", ")", ":", "[", "type", "]", ")", ";", "if", "(", "type", "===", "\"get\"", ")", "{", "cache", ".", "set", "(", "uri", ",", "\"expires\"", ",", "o", ".", "expires", ")", ";", "cache", ".", "set", "(", "uri", ",", "\"headers\"", ",", "o", ".", "headers", ")", ";", "cache", ".", "set", "(", "uri", ",", "\"permission\"", ",", "o", ".", "permission", ")", ";", "}", "return", "o", ";", "}" ]
Caches the headers from the XHR response @method headers @param {Object} xhr XMLHttpRequest Object @param {String} uri URI to request @param {String} type Type of request @return {Object} Cached URI representation
[ "Caches", "the", "headers", "from", "the", "XHR", "response" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1899-L1946
36,460
avoidwork/abaaso
lib/abaaso.js
function ( xhr, type ) { type = type || ""; var result, obj; if ( ( regex.json_maybe.test( type ) || string.isEmpty( type ) ) && ( regex.json_wrap.test( xhr.responseText ) && Boolean( obj = json.decode( xhr.responseText, true ) ) ) ) { result = obj; } else if ( regex.xml.test( type ) ) { if ( type !== "text/xml" ) { xhr.overrideMimeType( "text/xml" ); } result = xhr.responseXML; } else if ( type === "text/plain" && regex.is_xml.test( xhr.responseText) && xml.valid( xhr.responseText ) ) { result = xml.decode( xhr.responseText ); } else { result = xhr.responseText; } return result; }
javascript
function ( xhr, type ) { type = type || ""; var result, obj; if ( ( regex.json_maybe.test( type ) || string.isEmpty( type ) ) && ( regex.json_wrap.test( xhr.responseText ) && Boolean( obj = json.decode( xhr.responseText, true ) ) ) ) { result = obj; } else if ( regex.xml.test( type ) ) { if ( type !== "text/xml" ) { xhr.overrideMimeType( "text/xml" ); } result = xhr.responseXML; } else if ( type === "text/plain" && regex.is_xml.test( xhr.responseText) && xml.valid( xhr.responseText ) ) { result = xml.decode( xhr.responseText ); } else { result = xhr.responseText; } return result; }
[ "function", "(", "xhr", ",", "type", ")", "{", "type", "=", "type", "||", "\"\"", ";", "var", "result", ",", "obj", ";", "if", "(", "(", "regex", ".", "json_maybe", ".", "test", "(", "type", ")", "||", "string", ".", "isEmpty", "(", "type", ")", ")", "&&", "(", "regex", ".", "json_wrap", ".", "test", "(", "xhr", ".", "responseText", ")", "&&", "Boolean", "(", "obj", "=", "json", ".", "decode", "(", "xhr", ".", "responseText", ",", "true", ")", ")", ")", ")", "{", "result", "=", "obj", ";", "}", "else", "if", "(", "regex", ".", "xml", ".", "test", "(", "type", ")", ")", "{", "if", "(", "type", "!==", "\"text/xml\"", ")", "{", "xhr", ".", "overrideMimeType", "(", "\"text/xml\"", ")", ";", "}", "result", "=", "xhr", ".", "responseXML", ";", "}", "else", "if", "(", "type", "===", "\"text/plain\"", "&&", "regex", ".", "is_xml", ".", "test", "(", "xhr", ".", "responseText", ")", "&&", "xml", ".", "valid", "(", "xhr", ".", "responseText", ")", ")", "{", "result", "=", "xml", ".", "decode", "(", "xhr", ".", "responseText", ")", ";", "}", "else", "{", "result", "=", "xhr", ".", "responseText", ";", "}", "return", "result", ";", "}" ]
Parses an XHR response @method parse @param {Object} xhr XHR Object @param {String} type [Optional] Content-Type header value @return {Mixed} Array, Boolean, Document, Number, Object or String
[ "Parses", "an", "XHR", "response" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1956-L1978
36,461
avoidwork/abaaso
lib/abaaso.js
function ( uri ) { var cached = cache.get( uri, false ), bit = !cached ? 0 : cached.permission, result = {allows: [], bit: bit, map: {partial: 8, read: 4, write: 2, "delete": 1, unknown: 0}}; if ( bit & 1) { result.allows.push( "DELETE" ); } if ( bit & 2) { result.allows.push( "POST" ); result.allows.push( "PUT" ); } if ( bit & 4) { result.allows.push( "GET" ); } if ( bit & 8) { result.allows.push( "PATCH" ); } return result; }
javascript
function ( uri ) { var cached = cache.get( uri, false ), bit = !cached ? 0 : cached.permission, result = {allows: [], bit: bit, map: {partial: 8, read: 4, write: 2, "delete": 1, unknown: 0}}; if ( bit & 1) { result.allows.push( "DELETE" ); } if ( bit & 2) { result.allows.push( "POST" ); result.allows.push( "PUT" ); } if ( bit & 4) { result.allows.push( "GET" ); } if ( bit & 8) { result.allows.push( "PATCH" ); } return result; }
[ "function", "(", "uri", ")", "{", "var", "cached", "=", "cache", ".", "get", "(", "uri", ",", "false", ")", ",", "bit", "=", "!", "cached", "?", "0", ":", "cached", ".", "permission", ",", "result", "=", "{", "allows", ":", "[", "]", ",", "bit", ":", "bit", ",", "map", ":", "{", "partial", ":", "8", ",", "read", ":", "4", ",", "write", ":", "2", ",", "\"delete\"", ":", "1", ",", "unknown", ":", "0", "}", "}", ";", "if", "(", "bit", "&", "1", ")", "{", "result", ".", "allows", ".", "push", "(", "\"DELETE\"", ")", ";", "}", "if", "(", "bit", "&", "2", ")", "{", "result", ".", "allows", ".", "push", "(", "\"POST\"", ")", ";", "result", ".", "allows", ".", "push", "(", "\"PUT\"", ")", ";", "}", "if", "(", "bit", "&", "4", ")", "{", "result", ".", "allows", ".", "push", "(", "\"GET\"", ")", ";", "}", "if", "(", "bit", "&", "8", ")", "{", "result", ".", "allows", ".", "push", "(", "\"PATCH\"", ")", ";", "}", "return", "result", ";", "}" ]
Returns the permission of the cached URI @method permissions @param {String} uri URI to query @return {Object} Contains an Array of available commands, the permission bit and a map
[ "Returns", "the", "permission", "of", "the", "cached", "URI" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L1987-L2010
36,462
avoidwork/abaaso
lib/abaaso.js
function ( uri, success, failure, args ) { var defer = deferred(), callback = "callback", cbid, s; if ( external === undefined ) { if ( global.abaaso === undefined ) { utility.define( "abaaso.callback", {}, global ); } external = "abaaso"; } if ( args instanceof Object && args.callback !== undefined ) { callback = args.callback; } defer.then( function (arg ) { if ( typeof success === "function") { success( arg ); } }, function ( e ) { if ( typeof failure === "function") { failure( e ); } throw e; }); do { cbid = utility.genId().slice( 0, 10 ); } while ( global.abaaso.callback[cbid] !== undefined ); uri = uri.replace( callback + "=?", callback + "=" + external + ".callback." + cbid ); global.abaaso.callback[cbid] = function ( arg ) { clearTimeout( utility.timer[cbid] ); delete utility.timer[cbid]; delete global.abaaso.callback[cbid]; defer.resolve( arg ); element.destroy( s ); }; s = element.create( "script", {src: uri, type: "text/javascript"}, utility.$( "head" )[0] ); utility.defer( function () { defer.reject( undefined ); }, 30000, cbid ); return defer; }
javascript
function ( uri, success, failure, args ) { var defer = deferred(), callback = "callback", cbid, s; if ( external === undefined ) { if ( global.abaaso === undefined ) { utility.define( "abaaso.callback", {}, global ); } external = "abaaso"; } if ( args instanceof Object && args.callback !== undefined ) { callback = args.callback; } defer.then( function (arg ) { if ( typeof success === "function") { success( arg ); } }, function ( e ) { if ( typeof failure === "function") { failure( e ); } throw e; }); do { cbid = utility.genId().slice( 0, 10 ); } while ( global.abaaso.callback[cbid] !== undefined ); uri = uri.replace( callback + "=?", callback + "=" + external + ".callback." + cbid ); global.abaaso.callback[cbid] = function ( arg ) { clearTimeout( utility.timer[cbid] ); delete utility.timer[cbid]; delete global.abaaso.callback[cbid]; defer.resolve( arg ); element.destroy( s ); }; s = element.create( "script", {src: uri, type: "text/javascript"}, utility.$( "head" )[0] ); utility.defer( function () { defer.reject( undefined ); }, 30000, cbid ); return defer; }
[ "function", "(", "uri", ",", "success", ",", "failure", ",", "args", ")", "{", "var", "defer", "=", "deferred", "(", ")", ",", "callback", "=", "\"callback\"", ",", "cbid", ",", "s", ";", "if", "(", "external", "===", "undefined", ")", "{", "if", "(", "global", ".", "abaaso", "===", "undefined", ")", "{", "utility", ".", "define", "(", "\"abaaso.callback\"", ",", "{", "}", ",", "global", ")", ";", "}", "external", "=", "\"abaaso\"", ";", "}", "if", "(", "args", "instanceof", "Object", "&&", "args", ".", "callback", "!==", "undefined", ")", "{", "callback", "=", "args", ".", "callback", ";", "}", "defer", ".", "then", "(", "function", "(", "arg", ")", "{", "if", "(", "typeof", "success", "===", "\"function\"", ")", "{", "success", "(", "arg", ")", ";", "}", "}", ",", "function", "(", "e", ")", "{", "if", "(", "typeof", "failure", "===", "\"function\"", ")", "{", "failure", "(", "e", ")", ";", "}", "throw", "e", ";", "}", ")", ";", "do", "{", "cbid", "=", "utility", ".", "genId", "(", ")", ".", "slice", "(", "0", ",", "10", ")", ";", "}", "while", "(", "global", ".", "abaaso", ".", "callback", "[", "cbid", "]", "!==", "undefined", ")", ";", "uri", "=", "uri", ".", "replace", "(", "callback", "+", "\"=?\"", ",", "callback", "+", "\"=\"", "+", "external", "+", "\".callback.\"", "+", "cbid", ")", ";", "global", ".", "abaaso", ".", "callback", "[", "cbid", "]", "=", "function", "(", "arg", ")", "{", "clearTimeout", "(", "utility", ".", "timer", "[", "cbid", "]", ")", ";", "delete", "utility", ".", "timer", "[", "cbid", "]", ";", "delete", "global", ".", "abaaso", ".", "callback", "[", "cbid", "]", ";", "defer", ".", "resolve", "(", "arg", ")", ";", "element", ".", "destroy", "(", "s", ")", ";", "}", ";", "s", "=", "element", ".", "create", "(", "\"script\"", ",", "{", "src", ":", "uri", ",", "type", ":", "\"text/javascript\"", "}", ",", "utility", ".", "$", "(", "\"head\"", ")", "[", "0", "]", ")", ";", "utility", ".", "defer", "(", "function", "(", ")", "{", "defer", ".", "reject", "(", "undefined", ")", ";", "}", ",", "30000", ",", "cbid", ")", ";", "return", "defer", ";", "}" ]
Creates a JSONP request @method jsonp @param {String} uri URI to request @param {Function} success A handler function to execute when an appropriate response been received @param {Function} failure [Optional] A handler function to execute on error @param {Mixed} args Custom JSONP handler parameter name, default is "callback"; or custom headers for GET request ( CORS ) @return {Object} Deferred
[ "Creates", "a", "JSONP", "request" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2022-L2072
36,463
avoidwork/abaaso
lib/abaaso.js
function ( arg, target, pos ) { return element.create( "script", {type: "application/javascript", src: arg}, target || utility.$( "head" )[0], pos ); }
javascript
function ( arg, target, pos ) { return element.create( "script", {type: "application/javascript", src: arg}, target || utility.$( "head" )[0], pos ); }
[ "function", "(", "arg", ",", "target", ",", "pos", ")", "{", "return", "element", ".", "create", "(", "\"script\"", ",", "{", "type", ":", "\"application/javascript\"", ",", "src", ":", "arg", "}", ",", "target", "||", "utility", ".", "$", "(", "\"head\"", ")", "[", "0", "]", ",", "pos", ")", ";", "}" ]
Creates a script Element to load an external script @method script @param {String} arg URL to script @param {Object} target [Optional] Element to receive the script @param {String} pos [Optional] Position to create the script at within the target @return {Object} Script
[ "Creates", "a", "script", "Element", "to", "load", "an", "external", "script" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2431-L2433
36,464
avoidwork/abaaso
lib/abaaso.js
function ( dest, ms ) { var defer = deferred(), start = client.scrollPos(), t = 0; ms = ( !isNaN( ms ) ? ms : 250 ) / 100; utility.repeat( function () { var pos = math.bezier( start[0], start[1], dest[0], dest[1], ++t / 100 ); window.scrollTo( pos[0], pos[1] ); if ( t === 100 ) { defer.resolve( true ); return false; } }, ms, "scrolling" ); return defer; }
javascript
function ( dest, ms ) { var defer = deferred(), start = client.scrollPos(), t = 0; ms = ( !isNaN( ms ) ? ms : 250 ) / 100; utility.repeat( function () { var pos = math.bezier( start[0], start[1], dest[0], dest[1], ++t / 100 ); window.scrollTo( pos[0], pos[1] ); if ( t === 100 ) { defer.resolve( true ); return false; } }, ms, "scrolling" ); return defer; }
[ "function", "(", "dest", ",", "ms", ")", "{", "var", "defer", "=", "deferred", "(", ")", ",", "start", "=", "client", ".", "scrollPos", "(", ")", ",", "t", "=", "0", ";", "ms", "=", "(", "!", "isNaN", "(", "ms", ")", "?", "ms", ":", "250", ")", "/", "100", ";", "utility", ".", "repeat", "(", "function", "(", ")", "{", "var", "pos", "=", "math", ".", "bezier", "(", "start", "[", "0", "]", ",", "start", "[", "1", "]", ",", "dest", "[", "0", "]", ",", "dest", "[", "1", "]", ",", "++", "t", "/", "100", ")", ";", "window", ".", "scrollTo", "(", "pos", "[", "0", "]", ",", "pos", "[", "1", "]", ")", ";", "if", "(", "t", "===", "100", ")", "{", "defer", ".", "resolve", "(", "true", ")", ";", "return", "false", ";", "}", "}", ",", "ms", ",", "\"scrolling\"", ")", ";", "return", "defer", ";", "}" ]
Scrolls to a position in the view using a two point bezier curve @method scroll @param {Array} dest Coordinates @param {Number} ms [Optional] Milliseconds to scroll, default is 250, min is 100 @return {Object} Deferred
[ "Scrolls", "to", "a", "position", "in", "the", "view", "using", "a", "two", "point", "bezier", "curve" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2443-L2462
36,465
avoidwork/abaaso
lib/abaaso.js
function ( arg, media ) { return element.create( "link", {rel: "stylesheet", type: "text/css", href: arg, media: media || "print, screen"}, utility.$( "head" )[0] ); }
javascript
function ( arg, media ) { return element.create( "link", {rel: "stylesheet", type: "text/css", href: arg, media: media || "print, screen"}, utility.$( "head" )[0] ); }
[ "function", "(", "arg", ",", "media", ")", "{", "return", "element", ".", "create", "(", "\"link\"", ",", "{", "rel", ":", "\"stylesheet\"", ",", "type", ":", "\"text/css\"", ",", "href", ":", "arg", ",", "media", ":", "media", "||", "\"print, screen\"", "}", ",", "utility", ".", "$", "(", "\"head\"", ")", "[", "0", "]", ")", ";", "}" ]
Creates a link Element to load an external stylesheet @method stylesheet @param {String} arg URL to stylesheet @param {String} media [Optional] Medias the stylesheet applies to @return {Objecct} Stylesheet
[ "Creates", "a", "link", "Element", "to", "load", "an", "external", "stylesheet" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2498-L2500
36,466
avoidwork/abaaso
lib/abaaso.js
function ( name, domain, secure, path, jar ) { cookie.set( name, "", "-1s", domain, secure, path, jar ); return name; }
javascript
function ( name, domain, secure, path, jar ) { cookie.set( name, "", "-1s", domain, secure, path, jar ); return name; }
[ "function", "(", "name", ",", "domain", ",", "secure", ",", "path", ",", "jar", ")", "{", "cookie", ".", "set", "(", "name", ",", "\"\"", ",", "\"-1s\"", ",", "domain", ",", "secure", ",", "path", ",", "jar", ")", ";", "return", "name", ";", "}" ]
Expires a cookie if it exists @method expire @param {String} name Name of the cookie to expire @param {String} domain [Optional] Domain to set the cookie for @param {Boolean} secure [Optional] Make the cookie only accessible via SSL @param {String} path [Optional] Path the cookie is for @param {String} jar [Optional] Cookie jar, defaults to document.cookie @return {String} Name of the expired cookie
[ "Expires", "a", "cookie", "if", "it", "exists" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2516-L2520
36,467
avoidwork/abaaso
lib/abaaso.js
function ( jar ) { var result = {}; if ( jar === undefined ) { jar = server ? "" : document.cookie; } if ( !string.isEmpty( jar ) ) { array.each( string.explode( jar, ";" ), function ( i ) { var item = string.explode( i, "=" ); result[item[0]] = utility.coerce( item[1] ); } ); } return result; }
javascript
function ( jar ) { var result = {}; if ( jar === undefined ) { jar = server ? "" : document.cookie; } if ( !string.isEmpty( jar ) ) { array.each( string.explode( jar, ";" ), function ( i ) { var item = string.explode( i, "=" ); result[item[0]] = utility.coerce( item[1] ); } ); } return result; }
[ "function", "(", "jar", ")", "{", "var", "result", "=", "{", "}", ";", "if", "(", "jar", "===", "undefined", ")", "{", "jar", "=", "server", "?", "\"\"", ":", "document", ".", "cookie", ";", "}", "if", "(", "!", "string", ".", "isEmpty", "(", "jar", ")", ")", "{", "array", ".", "each", "(", "string", ".", "explode", "(", "jar", ",", "\";\"", ")", ",", "function", "(", "i", ")", "{", "var", "item", "=", "string", ".", "explode", "(", "i", ",", "\"=\"", ")", ";", "result", "[", "item", "[", "0", "]", "]", "=", "utility", ".", "coerce", "(", "item", "[", "1", "]", ")", ";", "}", ")", ";", "}", "return", "result", ";", "}" ]
Gets the cookies for the domain @method list @param {String} jar [Optional] Cookie jar, defaults to document.cookie @return {Object} Collection of cookies
[ "Gets", "the", "cookies", "for", "the", "domain" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2541-L2557
36,468
avoidwork/abaaso
lib/abaaso.js
function ( name, value, offset, domain, secure, path, jar ) { value = ( value || "" ) + ";"; offset = offset || ""; domain = typeof domain === "string" ? ( " Domain=" + domain + ";" ) : ""; secure = ( secure === true ) ? " secure" : ""; path = typeof path === "string" ? ( " Path=" + path + ";" ) : ""; var expire = "", span = null, type = null, types = ["d", "h", "m", "s"], regex = new RegExp(), i = types.length, cookies; if ( !string.isEmpty( offset ) ) { while ( i-- ) { utility.compile( regex, types[i] ); if ( regex.test( offset ) ) { type = types[i]; span = number.parse( offset, 10 ); break; } } if ( isNaN( span ) ) { throw new Error( label.error.invalidArguments ); } expire = new Date(); if ( type === "d" ) { expire.setDate( expire.getDate() + span ); } else if ( type === "h" ) { expire.setHours( expire.getHours() + span ); } else if ( type === "m" ) { expire.setMinutes( expire.getMinutes() + span ); } else if ( type === "s" ) { expire.setSeconds( expire.getSeconds() + span ); } } if ( expire instanceof Date) { expire = " Expires=" + expire.toUTCString() + ";"; } if ( !server ) { document.cookie = ( string.trim( name.toString() ) + "=" + value + expire + domain + path + secure ); } else { cookies = jar.getHeader( "Set-Cookie" ) || []; cookies.push( ( string.trim( name.toString() ) + "=" + value + expire + domain + path + secure ).replace( /;$/, "" ) ); jar.setHeader( "Set-Cookie", cookies ); } }
javascript
function ( name, value, offset, domain, secure, path, jar ) { value = ( value || "" ) + ";"; offset = offset || ""; domain = typeof domain === "string" ? ( " Domain=" + domain + ";" ) : ""; secure = ( secure === true ) ? " secure" : ""; path = typeof path === "string" ? ( " Path=" + path + ";" ) : ""; var expire = "", span = null, type = null, types = ["d", "h", "m", "s"], regex = new RegExp(), i = types.length, cookies; if ( !string.isEmpty( offset ) ) { while ( i-- ) { utility.compile( regex, types[i] ); if ( regex.test( offset ) ) { type = types[i]; span = number.parse( offset, 10 ); break; } } if ( isNaN( span ) ) { throw new Error( label.error.invalidArguments ); } expire = new Date(); if ( type === "d" ) { expire.setDate( expire.getDate() + span ); } else if ( type === "h" ) { expire.setHours( expire.getHours() + span ); } else if ( type === "m" ) { expire.setMinutes( expire.getMinutes() + span ); } else if ( type === "s" ) { expire.setSeconds( expire.getSeconds() + span ); } } if ( expire instanceof Date) { expire = " Expires=" + expire.toUTCString() + ";"; } if ( !server ) { document.cookie = ( string.trim( name.toString() ) + "=" + value + expire + domain + path + secure ); } else { cookies = jar.getHeader( "Set-Cookie" ) || []; cookies.push( ( string.trim( name.toString() ) + "=" + value + expire + domain + path + secure ).replace( /;$/, "" ) ); jar.setHeader( "Set-Cookie", cookies ); } }
[ "function", "(", "name", ",", "value", ",", "offset", ",", "domain", ",", "secure", ",", "path", ",", "jar", ")", "{", "value", "=", "(", "value", "||", "\"\"", ")", "+", "\";\"", ";", "offset", "=", "offset", "||", "\"\"", ";", "domain", "=", "typeof", "domain", "===", "\"string\"", "?", "(", "\" Domain=\"", "+", "domain", "+", "\";\"", ")", ":", "\"\"", ";", "secure", "=", "(", "secure", "===", "true", ")", "?", "\" secure\"", ":", "\"\"", ";", "path", "=", "typeof", "path", "===", "\"string\"", "?", "(", "\" Path=\"", "+", "path", "+", "\";\"", ")", ":", "\"\"", ";", "var", "expire", "=", "\"\"", ",", "span", "=", "null", ",", "type", "=", "null", ",", "types", "=", "[", "\"d\"", ",", "\"h\"", ",", "\"m\"", ",", "\"s\"", "]", ",", "regex", "=", "new", "RegExp", "(", ")", ",", "i", "=", "types", ".", "length", ",", "cookies", ";", "if", "(", "!", "string", ".", "isEmpty", "(", "offset", ")", ")", "{", "while", "(", "i", "--", ")", "{", "utility", ".", "compile", "(", "regex", ",", "types", "[", "i", "]", ")", ";", "if", "(", "regex", ".", "test", "(", "offset", ")", ")", "{", "type", "=", "types", "[", "i", "]", ";", "span", "=", "number", ".", "parse", "(", "offset", ",", "10", ")", ";", "break", ";", "}", "}", "if", "(", "isNaN", "(", "span", ")", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "invalidArguments", ")", ";", "}", "expire", "=", "new", "Date", "(", ")", ";", "if", "(", "type", "===", "\"d\"", ")", "{", "expire", ".", "setDate", "(", "expire", ".", "getDate", "(", ")", "+", "span", ")", ";", "}", "else", "if", "(", "type", "===", "\"h\"", ")", "{", "expire", ".", "setHours", "(", "expire", ".", "getHours", "(", ")", "+", "span", ")", ";", "}", "else", "if", "(", "type", "===", "\"m\"", ")", "{", "expire", ".", "setMinutes", "(", "expire", ".", "getMinutes", "(", ")", "+", "span", ")", ";", "}", "else", "if", "(", "type", "===", "\"s\"", ")", "{", "expire", ".", "setSeconds", "(", "expire", ".", "getSeconds", "(", ")", "+", "span", ")", ";", "}", "}", "if", "(", "expire", "instanceof", "Date", ")", "{", "expire", "=", "\" Expires=\"", "+", "expire", ".", "toUTCString", "(", ")", "+", "\";\"", ";", "}", "if", "(", "!", "server", ")", "{", "document", ".", "cookie", "=", "(", "string", ".", "trim", "(", "name", ".", "toString", "(", ")", ")", "+", "\"=\"", "+", "value", "+", "expire", "+", "domain", "+", "path", "+", "secure", ")", ";", "}", "else", "{", "cookies", "=", "jar", ".", "getHeader", "(", "\"Set-Cookie\"", ")", "||", "[", "]", ";", "cookies", ".", "push", "(", "(", "string", ".", "trim", "(", "name", ".", "toString", "(", ")", ")", "+", "\"=\"", "+", "value", "+", "expire", "+", "domain", "+", "path", "+", "secure", ")", ".", "replace", "(", "/", ";$", "/", ",", "\"\"", ")", ")", ";", "jar", ".", "setHeader", "(", "\"Set-Cookie\"", ",", "cookies", ")", ";", "}", "}" ]
Creates a cookie The offset specifies a positive or negative span of time as day, hour, minute or second @method set @param {String} name Name of the cookie to create @param {String} value Value to set @param {String} offset A positive or negative integer followed by "d", "h", "m" or "s" @param {String} domain [Optional] Domain to set the cookie for @param {Boolean} secure [Optional] Make the cookie only accessible via SSL @param {String} path [Optional] Path the cookie is for @param {String} jar [Optional] Cookie jar, defaults to document.cookie @return {Undefined} undefined
[ "Creates", "a", "cookie" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2574-L2631
36,469
avoidwork/abaaso
lib/abaaso.js
function ( obj, recs, args ) { utility.genId( obj ); // Decorating observer if not present in prototype chain if ( typeof obj.fire !== "function" ) { observer.decorate( obj ); } // Creating store obj.data = new DataStore( obj ); if ( args instanceof Object ) { utility.merge( obj.data, args ); } if ( recs !== null && typeof recs === "object" ) { obj.data.batch( "set", recs ); } return obj; }
javascript
function ( obj, recs, args ) { utility.genId( obj ); // Decorating observer if not present in prototype chain if ( typeof obj.fire !== "function" ) { observer.decorate( obj ); } // Creating store obj.data = new DataStore( obj ); if ( args instanceof Object ) { utility.merge( obj.data, args ); } if ( recs !== null && typeof recs === "object" ) { obj.data.batch( "set", recs ); } return obj; }
[ "function", "(", "obj", ",", "recs", ",", "args", ")", "{", "utility", ".", "genId", "(", "obj", ")", ";", "// Decorating observer if not present in prototype chain", "if", "(", "typeof", "obj", ".", "fire", "!==", "\"function\"", ")", "{", "observer", ".", "decorate", "(", "obj", ")", ";", "}", "// Creating store", "obj", ".", "data", "=", "new", "DataStore", "(", "obj", ")", ";", "if", "(", "args", "instanceof", "Object", ")", "{", "utility", ".", "merge", "(", "obj", ".", "data", ",", "args", ")", ";", "}", "if", "(", "recs", "!==", "null", "&&", "typeof", "recs", "===", "\"object\"", ")", "{", "obj", ".", "data", ".", "batch", "(", "\"set\"", ",", "recs", ")", ";", "}", "return", "obj", ";", "}" ]
Decorates a DataStore on an Object @method decorator @param {Object} obj Object @param {Mixed} recs [Optional] Data to set with this.batch @param {Object} args [Optional] Arguments to set on the store @return {Object} Decorated Object
[ "Decorates", "a", "DataStore", "on", "an", "Object" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L2643-L2663
36,470
avoidwork/abaaso
lib/abaaso.js
function ( obj, key, value ) { var target, result; if ( regex.svg.test( obj.namespaceURI ) ) { if ( value === undefined ) { result = obj.getAttributeNS( obj.namespaceURI, key ); if ( result === null || string.isEmpty( result ) ) { result = undefined; } else { result = utility.coerce( result ); } } else { obj.setAttributeNS( obj.namespaceURI, key, value ); } } else { if ( typeof value === "string" ) { value = string.trim( value ); } if ( regex.checked_disabled.test( key ) && value === undefined ) { return utility.coerce( obj[key] ); } else if ( regex.checked_disabled.test( key ) && value !== undefined ) { obj[key] = value; } else if ( obj.nodeName === "SELECT" && key === "selected" && value === undefined) { return utility.$( "#" + obj.id + " option[selected=\"selected\"]" )[0] || utility.$( "#" + obj.id + " option" )[0]; } else if ( obj.nodeName === "SELECT" && key === "selected" && value !== undefined ) { target = utility.$( "#" + obj.id + " option[selected=\"selected\"]" )[0]; if ( target !== undefined ) { target.selected = false; target.removeAttribute( "selected" ); } target = utility.$( "#" + obj.id + " option[value=\"" + value + "\"]" )[0]; target.selected = true; target.setAttribute( "selected", "selected" ); } else if ( value === undefined ) { result = obj.getAttribute( key ); if ( result === null || string.isEmpty( result ) ) { result = undefined; } else { result = utility.coerce( result ); } return result; } else { obj.setAttribute( key, value ); } } return obj; }
javascript
function ( obj, key, value ) { var target, result; if ( regex.svg.test( obj.namespaceURI ) ) { if ( value === undefined ) { result = obj.getAttributeNS( obj.namespaceURI, key ); if ( result === null || string.isEmpty( result ) ) { result = undefined; } else { result = utility.coerce( result ); } } else { obj.setAttributeNS( obj.namespaceURI, key, value ); } } else { if ( typeof value === "string" ) { value = string.trim( value ); } if ( regex.checked_disabled.test( key ) && value === undefined ) { return utility.coerce( obj[key] ); } else if ( regex.checked_disabled.test( key ) && value !== undefined ) { obj[key] = value; } else if ( obj.nodeName === "SELECT" && key === "selected" && value === undefined) { return utility.$( "#" + obj.id + " option[selected=\"selected\"]" )[0] || utility.$( "#" + obj.id + " option" )[0]; } else if ( obj.nodeName === "SELECT" && key === "selected" && value !== undefined ) { target = utility.$( "#" + obj.id + " option[selected=\"selected\"]" )[0]; if ( target !== undefined ) { target.selected = false; target.removeAttribute( "selected" ); } target = utility.$( "#" + obj.id + " option[value=\"" + value + "\"]" )[0]; target.selected = true; target.setAttribute( "selected", "selected" ); } else if ( value === undefined ) { result = obj.getAttribute( key ); if ( result === null || string.isEmpty( result ) ) { result = undefined; } else { result = utility.coerce( result ); } return result; } else { obj.setAttribute( key, value ); } } return obj; }
[ "function", "(", "obj", ",", "key", ",", "value", ")", "{", "var", "target", ",", "result", ";", "if", "(", "regex", ".", "svg", ".", "test", "(", "obj", ".", "namespaceURI", ")", ")", "{", "if", "(", "value", "===", "undefined", ")", "{", "result", "=", "obj", ".", "getAttributeNS", "(", "obj", ".", "namespaceURI", ",", "key", ")", ";", "if", "(", "result", "===", "null", "||", "string", ".", "isEmpty", "(", "result", ")", ")", "{", "result", "=", "undefined", ";", "}", "else", "{", "result", "=", "utility", ".", "coerce", "(", "result", ")", ";", "}", "}", "else", "{", "obj", ".", "setAttributeNS", "(", "obj", ".", "namespaceURI", ",", "key", ",", "value", ")", ";", "}", "}", "else", "{", "if", "(", "typeof", "value", "===", "\"string\"", ")", "{", "value", "=", "string", ".", "trim", "(", "value", ")", ";", "}", "if", "(", "regex", ".", "checked_disabled", ".", "test", "(", "key", ")", "&&", "value", "===", "undefined", ")", "{", "return", "utility", ".", "coerce", "(", "obj", "[", "key", "]", ")", ";", "}", "else", "if", "(", "regex", ".", "checked_disabled", ".", "test", "(", "key", ")", "&&", "value", "!==", "undefined", ")", "{", "obj", "[", "key", "]", "=", "value", ";", "}", "else", "if", "(", "obj", ".", "nodeName", "===", "\"SELECT\"", "&&", "key", "===", "\"selected\"", "&&", "value", "===", "undefined", ")", "{", "return", "utility", ".", "$", "(", "\"#\"", "+", "obj", ".", "id", "+", "\" option[selected=\\\"selected\\\"]\"", ")", "[", "0", "]", "||", "utility", ".", "$", "(", "\"#\"", "+", "obj", ".", "id", "+", "\" option\"", ")", "[", "0", "]", ";", "}", "else", "if", "(", "obj", ".", "nodeName", "===", "\"SELECT\"", "&&", "key", "===", "\"selected\"", "&&", "value", "!==", "undefined", ")", "{", "target", "=", "utility", ".", "$", "(", "\"#\"", "+", "obj", ".", "id", "+", "\" option[selected=\\\"selected\\\"]\"", ")", "[", "0", "]", ";", "if", "(", "target", "!==", "undefined", ")", "{", "target", ".", "selected", "=", "false", ";", "target", ".", "removeAttribute", "(", "\"selected\"", ")", ";", "}", "target", "=", "utility", ".", "$", "(", "\"#\"", "+", "obj", ".", "id", "+", "\" option[value=\\\"\"", "+", "value", "+", "\"\\\"]\"", ")", "[", "0", "]", ";", "target", ".", "selected", "=", "true", ";", "target", ".", "setAttribute", "(", "\"selected\"", ",", "\"selected\"", ")", ";", "}", "else", "if", "(", "value", "===", "undefined", ")", "{", "result", "=", "obj", ".", "getAttribute", "(", "key", ")", ";", "if", "(", "result", "===", "null", "||", "string", ".", "isEmpty", "(", "result", ")", ")", "{", "result", "=", "undefined", ";", "}", "else", "{", "result", "=", "utility", ".", "coerce", "(", "result", ")", ";", "}", "return", "result", ";", "}", "else", "{", "obj", ".", "setAttribute", "(", "key", ",", "value", ")", ";", "}", "}", "return", "obj", ";", "}" ]
Gets or sets an Element attribute @method attr @param {Mixed} obj Element @param {String} name Attribute name @param {Mixed} value Attribute value @return {Object} Element
[ "Gets", "or", "sets", "an", "Element", "attribute" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L4926-L4988
36,471
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { if ( typeof obj.reset === "function" ) { obj.reset(); } else if ( obj.value !== undefined ) { element.update( obj, {innerHTML: "", value: ""} ); } else { element.update( obj, {innerHTML: ""} ); } return obj; }
javascript
function ( obj ) { if ( typeof obj.reset === "function" ) { obj.reset(); } else if ( obj.value !== undefined ) { element.update( obj, {innerHTML: "", value: ""} ); } else { element.update( obj, {innerHTML: ""} ); } return obj; }
[ "function", "(", "obj", ")", "{", "if", "(", "typeof", "obj", ".", "reset", "===", "\"function\"", ")", "{", "obj", ".", "reset", "(", ")", ";", "}", "else", "if", "(", "obj", ".", "value", "!==", "undefined", ")", "{", "element", ".", "update", "(", "obj", ",", "{", "innerHTML", ":", "\"\"", ",", "value", ":", "\"\"", "}", ")", ";", "}", "else", "{", "element", ".", "update", "(", "obj", ",", "{", "innerHTML", ":", "\"\"", "}", ")", ";", "}", "return", "obj", ";", "}" ]
Clears an object's innerHTML, or resets it's state @method clear @param {Mixed} obj Element @return {Object} Element
[ "Clears", "an", "object", "s", "innerHTML", "or", "resets", "it", "s", "state" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L4997-L5009
36,472
avoidwork/abaaso
lib/abaaso.js
function ( type, args, target, pos ) { var svg = false, frag = false, obj, uid, result; // Removing potential HTML template formatting type = type.replace( /\t|\n|\r/g, "" ); if ( target !== undefined ) { svg = ( target.namespaceURI !== undefined && regex.svg.test( target.namespaceURI ) ); } else { target = document.body; } if ( args instanceof Object && args.id !== undefined && utility.$( "#" + args.id ) === undefined ) { uid = args.id; delete args.id; } else if ( !svg ) { uid = utility.genId( undefined, true ); } // String injection, create a frag and apply it if ( regex.html.test( type ) ) { frag = true; obj = element.frag( type ); result = obj.childNodes.length === 1 ? obj.childNodes[0] : array.cast( obj.childNodes ); } // Original syntax else { if ( !svg && !regex.svg.test( type ) ) { obj = document.createElement( type ); } else { obj = document.createElementNS( "http://www.w3.org/2000/svg", type ); } if ( uid !== undefined ) { obj.id = uid; } if ( args instanceof Object ) { element.update( obj, args ); } } if ( pos === undefined || pos === "last" ) { target.appendChild( obj ); } else if ( pos === "first" ) { element.prependChild( target, obj ); } else if ( pos === "after" ) { pos = {}; pos.after = target; target = target.parentNode; target.insertBefore( obj, pos.after.nextSibling ); } else if ( pos.after !== undefined ) { target.insertBefore( obj, pos.after.nextSibling ); } else if ( pos === "before" ) { pos = {}; pos.before = target; target = target.parentNode; target.insertBefore( obj, pos.before ); } else if ( pos.before !== undefined ) { target.insertBefore( obj, pos.before ); } else { target.appendChild( obj ); } return !frag ? obj : result; }
javascript
function ( type, args, target, pos ) { var svg = false, frag = false, obj, uid, result; // Removing potential HTML template formatting type = type.replace( /\t|\n|\r/g, "" ); if ( target !== undefined ) { svg = ( target.namespaceURI !== undefined && regex.svg.test( target.namespaceURI ) ); } else { target = document.body; } if ( args instanceof Object && args.id !== undefined && utility.$( "#" + args.id ) === undefined ) { uid = args.id; delete args.id; } else if ( !svg ) { uid = utility.genId( undefined, true ); } // String injection, create a frag and apply it if ( regex.html.test( type ) ) { frag = true; obj = element.frag( type ); result = obj.childNodes.length === 1 ? obj.childNodes[0] : array.cast( obj.childNodes ); } // Original syntax else { if ( !svg && !regex.svg.test( type ) ) { obj = document.createElement( type ); } else { obj = document.createElementNS( "http://www.w3.org/2000/svg", type ); } if ( uid !== undefined ) { obj.id = uid; } if ( args instanceof Object ) { element.update( obj, args ); } } if ( pos === undefined || pos === "last" ) { target.appendChild( obj ); } else if ( pos === "first" ) { element.prependChild( target, obj ); } else if ( pos === "after" ) { pos = {}; pos.after = target; target = target.parentNode; target.insertBefore( obj, pos.after.nextSibling ); } else if ( pos.after !== undefined ) { target.insertBefore( obj, pos.after.nextSibling ); } else if ( pos === "before" ) { pos = {}; pos.before = target; target = target.parentNode; target.insertBefore( obj, pos.before ); } else if ( pos.before !== undefined ) { target.insertBefore( obj, pos.before ); } else { target.appendChild( obj ); } return !frag ? obj : result; }
[ "function", "(", "type", ",", "args", ",", "target", ",", "pos", ")", "{", "var", "svg", "=", "false", ",", "frag", "=", "false", ",", "obj", ",", "uid", ",", "result", ";", "// Removing potential HTML template formatting", "type", "=", "type", ".", "replace", "(", "/", "\\t|\\n|\\r", "/", "g", ",", "\"\"", ")", ";", "if", "(", "target", "!==", "undefined", ")", "{", "svg", "=", "(", "target", ".", "namespaceURI", "!==", "undefined", "&&", "regex", ".", "svg", ".", "test", "(", "target", ".", "namespaceURI", ")", ")", ";", "}", "else", "{", "target", "=", "document", ".", "body", ";", "}", "if", "(", "args", "instanceof", "Object", "&&", "args", ".", "id", "!==", "undefined", "&&", "utility", ".", "$", "(", "\"#\"", "+", "args", ".", "id", ")", "===", "undefined", ")", "{", "uid", "=", "args", ".", "id", ";", "delete", "args", ".", "id", ";", "}", "else", "if", "(", "!", "svg", ")", "{", "uid", "=", "utility", ".", "genId", "(", "undefined", ",", "true", ")", ";", "}", "// String injection, create a frag and apply it", "if", "(", "regex", ".", "html", ".", "test", "(", "type", ")", ")", "{", "frag", "=", "true", ";", "obj", "=", "element", ".", "frag", "(", "type", ")", ";", "result", "=", "obj", ".", "childNodes", ".", "length", "===", "1", "?", "obj", ".", "childNodes", "[", "0", "]", ":", "array", ".", "cast", "(", "obj", ".", "childNodes", ")", ";", "}", "// Original syntax", "else", "{", "if", "(", "!", "svg", "&&", "!", "regex", ".", "svg", ".", "test", "(", "type", ")", ")", "{", "obj", "=", "document", ".", "createElement", "(", "type", ")", ";", "}", "else", "{", "obj", "=", "document", ".", "createElementNS", "(", "\"http://www.w3.org/2000/svg\"", ",", "type", ")", ";", "}", "if", "(", "uid", "!==", "undefined", ")", "{", "obj", ".", "id", "=", "uid", ";", "}", "if", "(", "args", "instanceof", "Object", ")", "{", "element", ".", "update", "(", "obj", ",", "args", ")", ";", "}", "}", "if", "(", "pos", "===", "undefined", "||", "pos", "===", "\"last\"", ")", "{", "target", ".", "appendChild", "(", "obj", ")", ";", "}", "else", "if", "(", "pos", "===", "\"first\"", ")", "{", "element", ".", "prependChild", "(", "target", ",", "obj", ")", ";", "}", "else", "if", "(", "pos", "===", "\"after\"", ")", "{", "pos", "=", "{", "}", ";", "pos", ".", "after", "=", "target", ";", "target", "=", "target", ".", "parentNode", ";", "target", ".", "insertBefore", "(", "obj", ",", "pos", ".", "after", ".", "nextSibling", ")", ";", "}", "else", "if", "(", "pos", ".", "after", "!==", "undefined", ")", "{", "target", ".", "insertBefore", "(", "obj", ",", "pos", ".", "after", ".", "nextSibling", ")", ";", "}", "else", "if", "(", "pos", "===", "\"before\"", ")", "{", "pos", "=", "{", "}", ";", "pos", ".", "before", "=", "target", ";", "target", "=", "target", ".", "parentNode", ";", "target", ".", "insertBefore", "(", "obj", ",", "pos", ".", "before", ")", ";", "}", "else", "if", "(", "pos", ".", "before", "!==", "undefined", ")", "{", "target", ".", "insertBefore", "(", "obj", ",", "pos", ".", "before", ")", ";", "}", "else", "{", "target", ".", "appendChild", "(", "obj", ")", ";", "}", "return", "!", "frag", "?", "obj", ":", "result", ";", "}" ]
Creates an Element in document.body or a target Element An id is generated if not specified with args @method create @param {String} type Type of Element to create @param {Object} args [Optional] Collection of properties to apply to the new element @param {Mixed} target [Optional] Target Element @param {Mixed} pos [Optional] "first", "last" or Object describing how to add the new Element, e.g. {before: referenceElement} @return {Mixed} Element that was created, or an Array if `type` is a String of multiple Elements (frag)
[ "Creates", "an", "Element", "in", "document", ".", "body", "or", "a", "target", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5023-L5099
36,473
avoidwork/abaaso
lib/abaaso.js
function ( obj, key, value ) { key = string.toCamelCase( key ); if ( value !== undefined ) { obj.style[key] = value; return obj; } else { return obj.style[key]; } }
javascript
function ( obj, key, value ) { key = string.toCamelCase( key ); if ( value !== undefined ) { obj.style[key] = value; return obj; } else { return obj.style[key]; } }
[ "function", "(", "obj", ",", "key", ",", "value", ")", "{", "key", "=", "string", ".", "toCamelCase", "(", "key", ")", ";", "if", "(", "value", "!==", "undefined", ")", "{", "obj", ".", "style", "[", "key", "]", "=", "value", ";", "return", "obj", ";", "}", "else", "{", "return", "obj", ".", "style", "[", "key", "]", ";", "}", "}" ]
Gets or sets a CSS style attribute on an Element @method css @param {Mixed} obj Element @param {String} key CSS to put in a style tag @param {String} value [Optional] Value to set @return {Object} Element
[ "Gets", "or", "sets", "a", "CSS", "style", "attribute", "on", "an", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5110-L5120
36,474
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { observer.remove( obj ); if ( obj.parentNode !== null ) { obj.parentNode.removeChild( obj ); } return undefined; }
javascript
function ( obj ) { observer.remove( obj ); if ( obj.parentNode !== null ) { obj.parentNode.removeChild( obj ); } return undefined; }
[ "function", "(", "obj", ")", "{", "observer", ".", "remove", "(", "obj", ")", ";", "if", "(", "obj", ".", "parentNode", "!==", "null", ")", "{", "obj", ".", "parentNode", ".", "removeChild", "(", "obj", ")", ";", "}", "return", "undefined", ";", "}" ]
Destroys an Element @method destroy @param {Mixed} obj Element @return {Undefined} undefined
[ "Destroys", "an", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5148-L5156
36,475
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { var result = []; utility.genId( obj, true ); array.each( string.explode( arg ), function ( i ) { result = result.concat( utility.$( "#" + obj.id + " " + i ) ); }); return result; }
javascript
function ( obj, arg ) { var result = []; utility.genId( obj, true ); array.each( string.explode( arg ), function ( i ) { result = result.concat( utility.$( "#" + obj.id + " " + i ) ); }); return result; }
[ "function", "(", "obj", ",", "arg", ")", "{", "var", "result", "=", "[", "]", ";", "utility", ".", "genId", "(", "obj", ",", "true", ")", ";", "array", ".", "each", "(", "string", ".", "explode", "(", "arg", ")", ",", "function", "(", "i", ")", "{", "result", "=", "result", ".", "concat", "(", "utility", ".", "$", "(", "\"#\"", "+", "obj", ".", "id", "+", "\" \"", "+", "i", ")", ")", ";", "}", ")", ";", "return", "result", ";", "}" ]
Finds descendant childNodes of Element matched by arg @method find @param {Mixed} obj Element to search @param {String} arg Comma delimited string of descendant selectors @return {Mixed} Array of Elements or undefined
[ "Finds", "descendant", "childNodes", "of", "Element", "matched", "by", "arg" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5257-L5267
36,476
avoidwork/abaaso
lib/abaaso.js
function ( arg ) { var obj = document.createDocumentFragment(); if ( arg ) { array.each( array.cast( element.create( "div", {innerHTML: arg}, obj ).childNodes ), function ( i ) { obj.appendChild( i ); }); obj.removeChild( obj.childNodes[0] ); } return obj; }
javascript
function ( arg ) { var obj = document.createDocumentFragment(); if ( arg ) { array.each( array.cast( element.create( "div", {innerHTML: arg}, obj ).childNodes ), function ( i ) { obj.appendChild( i ); }); obj.removeChild( obj.childNodes[0] ); } return obj; }
[ "function", "(", "arg", ")", "{", "var", "obj", "=", "document", ".", "createDocumentFragment", "(", ")", ";", "if", "(", "arg", ")", "{", "array", ".", "each", "(", "array", ".", "cast", "(", "element", ".", "create", "(", "\"div\"", ",", "{", "innerHTML", ":", "arg", "}", ",", "obj", ")", ".", "childNodes", ")", ",", "function", "(", "i", ")", "{", "obj", ".", "appendChild", "(", "i", ")", ";", "}", ")", ";", "obj", ".", "removeChild", "(", "obj", ".", "childNodes", "[", "0", "]", ")", ";", "}", "return", "obj", ";", "}" ]
Creates a document fragment @method frag @param {String} arg [Optional] innerHTML @return {Object} Document fragment
[ "Creates", "a", "document", "fragment" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5276-L5288
36,477
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { var result = element.find( obj, arg ); return ( !isNaN( result.length ) && result.length > 0 ); }
javascript
function ( obj, arg ) { var result = element.find( obj, arg ); return ( !isNaN( result.length ) && result.length > 0 ); }
[ "function", "(", "obj", ",", "arg", ")", "{", "var", "result", "=", "element", ".", "find", "(", "obj", ",", "arg", ")", ";", "return", "(", "!", "isNaN", "(", "result", ".", "length", ")", "&&", "result", ".", "length", ">", "0", ")", ";", "}" ]
Determines if Element has descendants matching arg @method has @param {Mixed} obj Element or Array of Elements or $ queries @param {String} arg Type of Element to find @return {Boolean} True if 1 or more Elements are found
[ "Determines", "if", "Element", "has", "descendants", "matching", "arg" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5298-L5302
36,478
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { if ( arg === undefined ) { return obj.innerHTML; } else { obj.innerHTML = arg; return obj; } }
javascript
function ( obj, arg ) { if ( arg === undefined ) { return obj.innerHTML; } else { obj.innerHTML = arg; return obj; } }
[ "function", "(", "obj", ",", "arg", ")", "{", "if", "(", "arg", "===", "undefined", ")", "{", "return", "obj", ".", "innerHTML", ";", "}", "else", "{", "obj", ".", "innerHTML", "=", "arg", ";", "return", "obj", ";", "}", "}" ]
Gets or sets an Elements innerHTML @method html @param {Object} obj Element @param {String} arg [Optional] innerHTML value @return {Object} Element
[ "Gets", "or", "sets", "an", "Elements", "innerHTML" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5334-L5342
36,479
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg ) { if ( regex.selector_is.test( arg ) ) { utility.id( obj ); return ( element.find( obj.parentNode, obj.nodeName.toLowerCase() + arg ).filter( function ( i ) { return ( i.id === obj.id ); }).length === 1 ); } else { return new RegExp( arg, "i" ).test( obj.nodeName ); } }
javascript
function ( obj, arg ) { if ( regex.selector_is.test( arg ) ) { utility.id( obj ); return ( element.find( obj.parentNode, obj.nodeName.toLowerCase() + arg ).filter( function ( i ) { return ( i.id === obj.id ); }).length === 1 ); } else { return new RegExp( arg, "i" ).test( obj.nodeName ); } }
[ "function", "(", "obj", ",", "arg", ")", "{", "if", "(", "regex", ".", "selector_is", ".", "test", "(", "arg", ")", ")", "{", "utility", ".", "id", "(", "obj", ")", ";", "return", "(", "element", ".", "find", "(", "obj", ".", "parentNode", ",", "obj", ".", "nodeName", ".", "toLowerCase", "(", ")", "+", "arg", ")", ".", "filter", "(", "function", "(", "i", ")", "{", "return", "(", "i", ".", "id", "===", "obj", ".", "id", ")", ";", "}", ")", ".", "length", "===", "1", ")", ";", "}", "else", "{", "return", "new", "RegExp", "(", "arg", ",", "\"i\"", ")", ".", "test", "(", "obj", ".", "nodeName", ")", ";", "}", "}" ]
Determines if Element is equal to arg, supports nodeNames & CSS2+ selectors @method is @param {Mixed} obj Element @param {String} arg Property to query @return {Boolean} True if a match
[ "Determines", "if", "Element", "is", "equal", "to", "arg", "supports", "nodeNames", "&", "CSS2", "+", "selectors" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5352-L5362
36,480
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : validate.test( {alphanum : obj.value || element.text( obj )} ).pass; }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : validate.test( {alphanum : obj.value || element.text( obj )} ).pass; }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "validate", ".", "test", "(", "{", "alphanum", ":", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", "}", ")", ".", "pass", ";", "}" ]
Tests if Element value or text is alpha-numeric @method isAlphaNum @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "alpha", "-", "numeric" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5371-L5373
36,481
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isDate( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isDate( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isDate", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is a date @method isDate @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "a", "date" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5404-L5406
36,482
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isDomain( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isDomain( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isDomain", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is a domain @method isDomain @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "a", "domain" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5426-L5428
36,483
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isEmail( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isEmail( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isEmail", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is an email address @method isEmail @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "an", "email", "address" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5437-L5439
36,484
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isEmpty( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isEmpty( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isEmpty", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is empty @method isEmpty @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "empty" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5448-L5450
36,485
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isIP( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isIP( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isIP", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is an IP address @method isIP @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "an", "IP", "address" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5459-L5461
36,486
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isInt( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isInt( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isInt", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is an integer @method isInt @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "an", "integer" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5470-L5472
36,487
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isNumber( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isNumber( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isNumber", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is numeric @method isNumber @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "numeric" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5481-L5483
36,488
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isPhone( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isPhone( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isPhone", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is a phone number @method isPhone @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "a", "phone", "number" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5492-L5494
36,489
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isUrl( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? false : string.isUrl( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "false", ":", "string", ".", "isUrl", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Tests if Element value or text is a URL @method isUrl @param {Object} obj Element to test @return {Boolean} Result of test
[ "Tests", "if", "Element", "value", "or", "text", "is", "a", "URL" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5503-L5505
36,490
avoidwork/abaaso
lib/abaaso.js
function ( obj, arg, add ) { add = ( add !== false ); arg = string.explode( arg, " " ); if ( add ) { array.each( arg, function ( i ) { obj.classList.add( i ); }); } else { array.each( arg, function ( i ) { if ( i !== "*" ) { obj.classList.remove( i ); } else { array.each( obj.classList, function ( x ) { this.remove( x ); }); return false; } }); } return obj; }
javascript
function ( obj, arg, add ) { add = ( add !== false ); arg = string.explode( arg, " " ); if ( add ) { array.each( arg, function ( i ) { obj.classList.add( i ); }); } else { array.each( arg, function ( i ) { if ( i !== "*" ) { obj.classList.remove( i ); } else { array.each( obj.classList, function ( x ) { this.remove( x ); }); return false; } }); } return obj; }
[ "function", "(", "obj", ",", "arg", ",", "add", ")", "{", "add", "=", "(", "add", "!==", "false", ")", ";", "arg", "=", "string", ".", "explode", "(", "arg", ",", "\" \"", ")", ";", "if", "(", "add", ")", "{", "array", ".", "each", "(", "arg", ",", "function", "(", "i", ")", "{", "obj", ".", "classList", ".", "add", "(", "i", ")", ";", "}", ")", ";", "}", "else", "{", "array", ".", "each", "(", "arg", ",", "function", "(", "i", ")", "{", "if", "(", "i", "!==", "\"*\"", ")", "{", "obj", ".", "classList", ".", "remove", "(", "i", ")", ";", "}", "else", "{", "array", ".", "each", "(", "obj", ".", "classList", ",", "function", "(", "x", ")", "{", "this", ".", "remove", "(", "x", ")", ";", "}", ")", ";", "return", "false", ";", "}", "}", ")", ";", "}", "return", "obj", ";", "}" ]
Adds or removes a CSS class @method klass @param {Mixed} obj Element @param {String} arg Class to add or remove ( can be a wildcard ) @param {Boolean} add Boolean to add or remove, defaults to true @return {Object} Element
[ "Adds", "or", "removes", "a", "CSS", "class" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5516-L5541
36,491
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { obj = obj || document.body; var left, top, right, bottom, height, width; left = top = 0; width = obj.offsetWidth; height = obj.offsetHeight; if ( obj.offsetParent ) { top = obj.offsetTop; left = obj.offsetLeft; while ( obj = obj.offsetParent ) { left += obj.offsetLeft; top += obj.offsetTop; } right = document.body.offsetWidth - ( left + width ); bottom = document.body.offsetHeight - ( top + height ); } else { right = width; bottom = height; } return [left, top, right, bottom]; }
javascript
function ( obj ) { obj = obj || document.body; var left, top, right, bottom, height, width; left = top = 0; width = obj.offsetWidth; height = obj.offsetHeight; if ( obj.offsetParent ) { top = obj.offsetTop; left = obj.offsetLeft; while ( obj = obj.offsetParent ) { left += obj.offsetLeft; top += obj.offsetTop; } right = document.body.offsetWidth - ( left + width ); bottom = document.body.offsetHeight - ( top + height ); } else { right = width; bottom = height; } return [left, top, right, bottom]; }
[ "function", "(", "obj", ")", "{", "obj", "=", "obj", "||", "document", ".", "body", ";", "var", "left", ",", "top", ",", "right", ",", "bottom", ",", "height", ",", "width", ";", "left", "=", "top", "=", "0", ";", "width", "=", "obj", ".", "offsetWidth", ";", "height", "=", "obj", ".", "offsetHeight", ";", "if", "(", "obj", ".", "offsetParent", ")", "{", "top", "=", "obj", ".", "offsetTop", ";", "left", "=", "obj", ".", "offsetLeft", ";", "while", "(", "obj", "=", "obj", ".", "offsetParent", ")", "{", "left", "+=", "obj", ".", "offsetLeft", ";", "top", "+=", "obj", ".", "offsetTop", ";", "}", "right", "=", "document", ".", "body", ".", "offsetWidth", "-", "(", "left", "+", "width", ")", ";", "bottom", "=", "document", ".", "body", ".", "offsetHeight", "-", "(", "top", "+", "height", ")", ";", "}", "else", "{", "right", "=", "width", ";", "bottom", "=", "height", ";", "}", "return", "[", "left", ",", "top", ",", "right", ",", "bottom", "]", ";", "}" ]
Finds the position of an element @method position @param {Mixed} obj Element @return {Array} Coordinates [left, top, right, bottom]
[ "Finds", "the", "position", "of", "an", "element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5550-L5576
36,492
avoidwork/abaaso
lib/abaaso.js
function ( obj, child ) { return obj.childNodes.length === 0 ? obj.appendChild( child ) : obj.insertBefore( child, obj.childNodes[0] ); }
javascript
function ( obj, child ) { return obj.childNodes.length === 0 ? obj.appendChild( child ) : obj.insertBefore( child, obj.childNodes[0] ); }
[ "function", "(", "obj", ",", "child", ")", "{", "return", "obj", ".", "childNodes", ".", "length", "===", "0", "?", "obj", ".", "appendChild", "(", "child", ")", ":", "obj", ".", "insertBefore", "(", "child", ",", "obj", ".", "childNodes", "[", "0", "]", ")", ";", "}" ]
Prepends an Element to an Element @method prependChild @param {Object} obj Element @param {Object} child Child Element @return {Object} Element
[ "Prepends", "an", "Element", "to", "an", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5586-L5588
36,493
avoidwork/abaaso
lib/abaaso.js
function ( obj, key ) { var target; if ( regex.svg.test( obj.namespaceURI ) ) { obj.removeAttributeNS( obj.namespaceURI, key ); } else { if ( obj.nodeName === "SELECT" && key === "selected") { target = utility.$( "#" + obj.id + " option[selected=\"selected\"]" )[0]; if ( target !== undefined ) { target.selected = false; target.removeAttribute( "selected" ); } } else { obj.removeAttribute( key ); } } return obj; }
javascript
function ( obj, key ) { var target; if ( regex.svg.test( obj.namespaceURI ) ) { obj.removeAttributeNS( obj.namespaceURI, key ); } else { if ( obj.nodeName === "SELECT" && key === "selected") { target = utility.$( "#" + obj.id + " option[selected=\"selected\"]" )[0]; if ( target !== undefined ) { target.selected = false; target.removeAttribute( "selected" ); } } else { obj.removeAttribute( key ); } } return obj; }
[ "function", "(", "obj", ",", "key", ")", "{", "var", "target", ";", "if", "(", "regex", ".", "svg", ".", "test", "(", "obj", ".", "namespaceURI", ")", ")", "{", "obj", ".", "removeAttributeNS", "(", "obj", ".", "namespaceURI", ",", "key", ")", ";", "}", "else", "{", "if", "(", "obj", ".", "nodeName", "===", "\"SELECT\"", "&&", "key", "===", "\"selected\"", ")", "{", "target", "=", "utility", ".", "$", "(", "\"#\"", "+", "obj", ".", "id", "+", "\" option[selected=\\\"selected\\\"]\"", ")", "[", "0", "]", ";", "if", "(", "target", "!==", "undefined", ")", "{", "target", ".", "selected", "=", "false", ";", "target", ".", "removeAttribute", "(", "\"selected\"", ")", ";", "}", "}", "else", "{", "obj", ".", "removeAttribute", "(", "key", ")", ";", "}", "}", "return", "obj", ";", "}" ]
Removes an Element attribute @method removeAttr @param {Mixed} obj Element @param {String} key Attribute name @return {Object} Element
[ "Removes", "an", "Element", "attribute" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5598-L5619
36,494
avoidwork/abaaso
lib/abaaso.js
function ( obj, ms ) { return client.scroll( array.remove( element.position( obj ), 2, 3 ), ms ); }
javascript
function ( obj, ms ) { return client.scroll( array.remove( element.position( obj ), 2, 3 ), ms ); }
[ "function", "(", "obj", ",", "ms", ")", "{", "return", "client", ".", "scroll", "(", "array", ".", "remove", "(", "element", ".", "position", "(", "obj", ")", ",", "2", ",", "3", ")", ",", "ms", ")", ";", "}" ]
Scrolls to the position of an Element @method scrollTo @param {Object} obj Element to scroll to @param {Number} ms [Optional] Milliseconds to scroll, default is 250, min is 100 @return {Object} Deferred
[ "Scrolls", "to", "the", "position", "of", "an", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5629-L5631
36,495
avoidwork/abaaso
lib/abaaso.js
function ( obj, string, encode ) { string = ( string === true ); encode = ( encode !== false ); var children = [], registry = {}, result; children = obj.nodeName === "FORM" ? ( obj.elements !== undefined ? array.cast( obj.elements ) : obj.find( "button, input, select, textarea" ) ) : [obj]; array.each( children, function ( i ) { if ( i.nodeName === "FORM" ) { utility.merge( registry, json.decode( element.serialize( i ) ) ); } else if ( registry[i.name] === undefined ) { registry[i.name] = element.val( i ); } }); if ( !string ) { result = json.encode( registry ); } else { result = ""; utility.iterate( registry, function ( v, k ) { encode ? result += "&" + encodeURIComponent( k ) + "=" + encodeURIComponent( v ) : result += "&" + k + "=" + v; }); result = result.replace( regex.and, "?" ); } return result; }
javascript
function ( obj, string, encode ) { string = ( string === true ); encode = ( encode !== false ); var children = [], registry = {}, result; children = obj.nodeName === "FORM" ? ( obj.elements !== undefined ? array.cast( obj.elements ) : obj.find( "button, input, select, textarea" ) ) : [obj]; array.each( children, function ( i ) { if ( i.nodeName === "FORM" ) { utility.merge( registry, json.decode( element.serialize( i ) ) ); } else if ( registry[i.name] === undefined ) { registry[i.name] = element.val( i ); } }); if ( !string ) { result = json.encode( registry ); } else { result = ""; utility.iterate( registry, function ( v, k ) { encode ? result += "&" + encodeURIComponent( k ) + "=" + encodeURIComponent( v ) : result += "&" + k + "=" + v; }); result = result.replace( regex.and, "?" ); } return result; }
[ "function", "(", "obj", ",", "string", ",", "encode", ")", "{", "string", "=", "(", "string", "===", "true", ")", ";", "encode", "=", "(", "encode", "!==", "false", ")", ";", "var", "children", "=", "[", "]", ",", "registry", "=", "{", "}", ",", "result", ";", "children", "=", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "(", "obj", ".", "elements", "!==", "undefined", "?", "array", ".", "cast", "(", "obj", ".", "elements", ")", ":", "obj", ".", "find", "(", "\"button, input, select, textarea\"", ")", ")", ":", "[", "obj", "]", ";", "array", ".", "each", "(", "children", ",", "function", "(", "i", ")", "{", "if", "(", "i", ".", "nodeName", "===", "\"FORM\"", ")", "{", "utility", ".", "merge", "(", "registry", ",", "json", ".", "decode", "(", "element", ".", "serialize", "(", "i", ")", ")", ")", ";", "}", "else", "if", "(", "registry", "[", "i", ".", "name", "]", "===", "undefined", ")", "{", "registry", "[", "i", ".", "name", "]", "=", "element", ".", "val", "(", "i", ")", ";", "}", "}", ")", ";", "if", "(", "!", "string", ")", "{", "result", "=", "json", ".", "encode", "(", "registry", ")", ";", "}", "else", "{", "result", "=", "\"\"", ";", "utility", ".", "iterate", "(", "registry", ",", "function", "(", "v", ",", "k", ")", "{", "encode", "?", "result", "+=", "\"&\"", "+", "encodeURIComponent", "(", "k", ")", "+", "\"=\"", "+", "encodeURIComponent", "(", "v", ")", ":", "result", "+=", "\"&\"", "+", "k", "+", "\"=\"", "+", "v", ";", "}", ")", ";", "result", "=", "result", ".", "replace", "(", "regex", ".", "and", ",", "\"?\"", ")", ";", "}", "return", "result", ";", "}" ]
Serializes the elements of an Element @method serialize @param {Object} obj Element @param {Boolean} string [Optional] true if you want a query string, default is false ( JSON ) @param {Boolean} encode [Optional] true if you want to URI encode the value, default is true @return {Mixed} String or Object
[ "Serializes", "the", "elements", "of", "an", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5642-L5674
36,496
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { var parse = function ( arg ) { return number.parse(arg, 10); }; return { height : obj.offsetHeight + parse( obj.style.paddingTop || 0 ) + parse( obj.style.paddingBottom || 0 ) + parse( obj.style.borderTop || 0 ) + parse( obj.style.borderBottom || 0 ), width : obj.offsetWidth + parse( obj.style.paddingLeft || 0 ) + parse( obj.style.paddingRight || 0 ) + parse( obj.style.borderLeft || 0 ) + parse( obj.style.borderRight || 0 ) }; }
javascript
function ( obj ) { var parse = function ( arg ) { return number.parse(arg, 10); }; return { height : obj.offsetHeight + parse( obj.style.paddingTop || 0 ) + parse( obj.style.paddingBottom || 0 ) + parse( obj.style.borderTop || 0 ) + parse( obj.style.borderBottom || 0 ), width : obj.offsetWidth + parse( obj.style.paddingLeft || 0 ) + parse( obj.style.paddingRight || 0 ) + parse( obj.style.borderLeft || 0 ) + parse( obj.style.borderRight || 0 ) }; }
[ "function", "(", "obj", ")", "{", "var", "parse", "=", "function", "(", "arg", ")", "{", "return", "number", ".", "parse", "(", "arg", ",", "10", ")", ";", "}", ";", "return", "{", "height", ":", "obj", ".", "offsetHeight", "+", "parse", "(", "obj", ".", "style", ".", "paddingTop", "||", "0", ")", "+", "parse", "(", "obj", ".", "style", ".", "paddingBottom", "||", "0", ")", "+", "parse", "(", "obj", ".", "style", ".", "borderTop", "||", "0", ")", "+", "parse", "(", "obj", ".", "style", ".", "borderBottom", "||", "0", ")", ",", "width", ":", "obj", ".", "offsetWidth", "+", "parse", "(", "obj", ".", "style", ".", "paddingLeft", "||", "0", ")", "+", "parse", "(", "obj", ".", "style", ".", "paddingRight", "||", "0", ")", "+", "parse", "(", "obj", ".", "style", ".", "borderLeft", "||", "0", ")", "+", "parse", "(", "obj", ".", "style", ".", "borderRight", "||", "0", ")", "}", ";", "}" ]
Returns the size of the Object @method size @param {Mixed} obj Element @return {Object} Size {height: n, width:n}
[ "Returns", "the", "size", "of", "the", "Object" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5683-L5692
36,497
avoidwork/abaaso
lib/abaaso.js
function ( obj, args ) { args = args || {}; utility.iterate( args, function ( v, k ) { if ( regex.element_update.test( k ) ) { obj[k] = v; } else if ( k === "class" ) { !string.isEmpty( v ) ? element.klass( obj, v ) : element.klass( obj, "*", false ); } else if ( k.indexOf( "data-" ) === 0 ) { element.data( obj, k.replace( "data-", "" ), v ); } else if ( k === "id" ) { var o = observer.listeners; if ( o[obj.id] !== undefined ) { o[k] = o[obj.id]; delete o[obj.id]; } } else { element.attr ( obj, k, v ); } }); return obj; }
javascript
function ( obj, args ) { args = args || {}; utility.iterate( args, function ( v, k ) { if ( regex.element_update.test( k ) ) { obj[k] = v; } else if ( k === "class" ) { !string.isEmpty( v ) ? element.klass( obj, v ) : element.klass( obj, "*", false ); } else if ( k.indexOf( "data-" ) === 0 ) { element.data( obj, k.replace( "data-", "" ), v ); } else if ( k === "id" ) { var o = observer.listeners; if ( o[obj.id] !== undefined ) { o[k] = o[obj.id]; delete o[obj.id]; } } else { element.attr ( obj, k, v ); } }); return obj; }
[ "function", "(", "obj", ",", "args", ")", "{", "args", "=", "args", "||", "{", "}", ";", "utility", ".", "iterate", "(", "args", ",", "function", "(", "v", ",", "k", ")", "{", "if", "(", "regex", ".", "element_update", ".", "test", "(", "k", ")", ")", "{", "obj", "[", "k", "]", "=", "v", ";", "}", "else", "if", "(", "k", "===", "\"class\"", ")", "{", "!", "string", ".", "isEmpty", "(", "v", ")", "?", "element", ".", "klass", "(", "obj", ",", "v", ")", ":", "element", ".", "klass", "(", "obj", ",", "\"*\"", ",", "false", ")", ";", "}", "else", "if", "(", "k", ".", "indexOf", "(", "\"data-\"", ")", "===", "0", ")", "{", "element", ".", "data", "(", "obj", ",", "k", ".", "replace", "(", "\"data-\"", ",", "\"\"", ")", ",", "v", ")", ";", "}", "else", "if", "(", "k", "===", "\"id\"", ")", "{", "var", "o", "=", "observer", ".", "listeners", ";", "if", "(", "o", "[", "obj", ".", "id", "]", "!==", "undefined", ")", "{", "o", "[", "k", "]", "=", "o", "[", "obj", ".", "id", "]", ";", "delete", "o", "[", "obj", ".", "id", "]", ";", "}", "}", "else", "{", "element", ".", "attr", "(", "obj", ",", "k", ",", "v", ")", ";", "}", "}", ")", ";", "return", "obj", ";", "}" ]
Updates an Element @method update @param {Mixed} obj Element @param {Object} args Collection of properties @return {Object} Element
[ "Updates", "an", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5737-L5764
36,498
avoidwork/abaaso
lib/abaaso.js
function ( obj, value ) { var event = "input", output; if ( value === undefined ) { if ( regex.radio_checkbox.test( obj.type ) ) { if ( string.isEmpty( obj.name ) ) { throw new Error( label.error.expectedProperty ); } array.each( utility.$( "input[name='" + obj.name + "']" ), function ( i ) { if ( i.checked ) { output = i.value; return false; } }); } else if ( regex.select.test( obj.type ) ) { output = obj.options[obj.selectedIndex].value; } else if ( "value" in obj ) { output = obj.value; } else { output = element.text( obj ); } if ( output !== undefined ) { output = utility.coerce( output ); } if ( typeof output === "string" ) { output = string.trim( output ); } } else { value = value.toString(); if ( regex.radio_checkbox.test( obj.type ) ) { event = "click"; array.each( utility.$( "input[name='" + obj.name + "']" ), function ( i ) { if ( i.value === value ) { i.checked = true; output = i; return false; } }); } else if ( regex.select.test( obj.type ) ) { event = "change"; array.each( element.find( obj, "> *" ), function ( i ) { if ( i.value === value ) { i.selected = true; output = i; return false; } }); } else { obj.value !== undefined ? obj.value = value : element.text( obj, value ); } element.dispatch( obj, event ); output = obj; } return output; }
javascript
function ( obj, value ) { var event = "input", output; if ( value === undefined ) { if ( regex.radio_checkbox.test( obj.type ) ) { if ( string.isEmpty( obj.name ) ) { throw new Error( label.error.expectedProperty ); } array.each( utility.$( "input[name='" + obj.name + "']" ), function ( i ) { if ( i.checked ) { output = i.value; return false; } }); } else if ( regex.select.test( obj.type ) ) { output = obj.options[obj.selectedIndex].value; } else if ( "value" in obj ) { output = obj.value; } else { output = element.text( obj ); } if ( output !== undefined ) { output = utility.coerce( output ); } if ( typeof output === "string" ) { output = string.trim( output ); } } else { value = value.toString(); if ( regex.radio_checkbox.test( obj.type ) ) { event = "click"; array.each( utility.$( "input[name='" + obj.name + "']" ), function ( i ) { if ( i.value === value ) { i.checked = true; output = i; return false; } }); } else if ( regex.select.test( obj.type ) ) { event = "change"; array.each( element.find( obj, "> *" ), function ( i ) { if ( i.value === value ) { i.selected = true; output = i; return false; } }); } else { obj.value !== undefined ? obj.value = value : element.text( obj, value ); } element.dispatch( obj, event ); output = obj; } return output; }
[ "function", "(", "obj", ",", "value", ")", "{", "var", "event", "=", "\"input\"", ",", "output", ";", "if", "(", "value", "===", "undefined", ")", "{", "if", "(", "regex", ".", "radio_checkbox", ".", "test", "(", "obj", ".", "type", ")", ")", "{", "if", "(", "string", ".", "isEmpty", "(", "obj", ".", "name", ")", ")", "{", "throw", "new", "Error", "(", "label", ".", "error", ".", "expectedProperty", ")", ";", "}", "array", ".", "each", "(", "utility", ".", "$", "(", "\"input[name='\"", "+", "obj", ".", "name", "+", "\"']\"", ")", ",", "function", "(", "i", ")", "{", "if", "(", "i", ".", "checked", ")", "{", "output", "=", "i", ".", "value", ";", "return", "false", ";", "}", "}", ")", ";", "}", "else", "if", "(", "regex", ".", "select", ".", "test", "(", "obj", ".", "type", ")", ")", "{", "output", "=", "obj", ".", "options", "[", "obj", ".", "selectedIndex", "]", ".", "value", ";", "}", "else", "if", "(", "\"value\"", "in", "obj", ")", "{", "output", "=", "obj", ".", "value", ";", "}", "else", "{", "output", "=", "element", ".", "text", "(", "obj", ")", ";", "}", "if", "(", "output", "!==", "undefined", ")", "{", "output", "=", "utility", ".", "coerce", "(", "output", ")", ";", "}", "if", "(", "typeof", "output", "===", "\"string\"", ")", "{", "output", "=", "string", ".", "trim", "(", "output", ")", ";", "}", "}", "else", "{", "value", "=", "value", ".", "toString", "(", ")", ";", "if", "(", "regex", ".", "radio_checkbox", ".", "test", "(", "obj", ".", "type", ")", ")", "{", "event", "=", "\"click\"", ";", "array", ".", "each", "(", "utility", ".", "$", "(", "\"input[name='\"", "+", "obj", ".", "name", "+", "\"']\"", ")", ",", "function", "(", "i", ")", "{", "if", "(", "i", ".", "value", "===", "value", ")", "{", "i", ".", "checked", "=", "true", ";", "output", "=", "i", ";", "return", "false", ";", "}", "}", ")", ";", "}", "else", "if", "(", "regex", ".", "select", ".", "test", "(", "obj", ".", "type", ")", ")", "{", "event", "=", "\"change\"", ";", "array", ".", "each", "(", "element", ".", "find", "(", "obj", ",", "\"> *\"", ")", ",", "function", "(", "i", ")", "{", "if", "(", "i", ".", "value", "===", "value", ")", "{", "i", ".", "selected", "=", "true", ";", "output", "=", "i", ";", "return", "false", ";", "}", "}", ")", ";", "}", "else", "{", "obj", ".", "value", "!==", "undefined", "?", "obj", ".", "value", "=", "value", ":", "element", ".", "text", "(", "obj", ",", "value", ")", ";", "}", "element", ".", "dispatch", "(", "obj", ",", "event", ")", ";", "output", "=", "obj", ";", "}", "return", "output", ";", "}" ]
Gets or sets the value of Element @method val @param {Mixed} obj Element @param {Mixed} value [Optional] Value to set @return {Object} Element
[ "Gets", "or", "sets", "the", "value", "of", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5774-L5844
36,499
avoidwork/abaaso
lib/abaaso.js
function ( obj ) { return obj.nodeName === "FORM" ? validate.test( obj ) : !string.isEmpty( obj.value || element.text( obj ) ); }
javascript
function ( obj ) { return obj.nodeName === "FORM" ? validate.test( obj ) : !string.isEmpty( obj.value || element.text( obj ) ); }
[ "function", "(", "obj", ")", "{", "return", "obj", ".", "nodeName", "===", "\"FORM\"", "?", "validate", ".", "test", "(", "obj", ")", ":", "!", "string", ".", "isEmpty", "(", "obj", ".", "value", "||", "element", ".", "text", "(", "obj", ")", ")", ";", "}" ]
Validates the contents of Element @method validate @param {Object} obj Element to test @return {Object} Result of test
[ "Validates", "the", "contents", "of", "Element" ]
07c147684bccd28868f377881eb80ffc285cd483
https://github.com/avoidwork/abaaso/blob/07c147684bccd28868f377881eb80ffc285cd483/lib/abaaso.js#L5853-L5855