This repo contains a bunch of plain JavaScript functions that come in handy while working on various projects. They are mostly provided as ES modules, but a subset of them are also offered as CommonJS modules so they can easily be used in an older node.js environment.
From the command line, run:
npm install ksjs
or
yarn add ksjs
Preferred: For any of the modules, you can import functions like so:
import {example1, example2} from 'ksjs/example.mjs'
// Depending on your project, ES modules are available in
// files with the .js extension, too. For example:
// import {example1, example2} from 'ksjs/example.js'
example1('foo');
example2('bar');
Not recommended: If your bundler supports ES module tree shaking, you might be able to import functions from various files like so (for Webpack, you might need to configure it to treat bamfjs as ES6+):
import {$, debounce, deepCopy} from 'bamfjs';
The following modules & their corresponding functions can be used in a node.js environment:
Preferred: You can require them from their respective files with the .cjs
extension, like so:
const {example1} = require('ksjs/example.cjs');
example1('foo');
or like so:
const examples = require('ksjs/example.cjs');
examples.example1('foo');
Otherwise: You could require them from the cjs
directory, like so (Note the “.js” extension here):
const {example1} = require('ksjs/cjs/example.js');
example1('foo');
or like so:
const examples = require('ksjs/cjs/example.js');
examples.example1('foo');
ESM Import Example:
import {getJSON} from 'ksjs';
// or:
import {getJSON} from 'ksjs/ajax.js';
// or:
import {getJSON} from 'ksjs/ajax.mjs';
Promise
Promise
Promise
Promise
Promise
Low-level ajax request
Returns: Promise
- A resolved or rejected Promise from the server
| Param | Type | Default | Description |
|---|---|---|---|
| [url] | string |
location.href |
The URL of the resource |
| options | object |
||
| [options.dataType] | string |
One of ‘json’, ‘html’, ‘xml’, ‘form’, ‘formData’. Used for setting the Content-Type request header (e.g. multipart/form-data when 'formData`) and processing the response (e.g. calling JSON.parse() on a string response when ‘json’); |
|
| [options.data] | Object | string |
Data to send along with the request. If it’s a GET request and options.data is an object, the object is converted to a query string and appended to the URL. |
|
| [options.method] | string |
"GET" |
One of ‘GET’, ‘POST’, etc. |
| [options.cache] | boolean |
true |
If set to false , will not let server use cached response |
| [options.memcache] | boolean |
false |
If set to true , and a previous request sent to the same url was successful, will circumvent request and use the previous response |
| [options.headers] | Object |
{} |
Advanced: Additional headers to send with the request. If headers such as ‘Accept’, ‘Content-Type’, ‘Cache-Control’, ‘X-Requested-With’, etc., are set here, they will override their respective headers set automatically based on other options such as options.dataType and options.cache . |
| [options.form] | HTMLFormElement |
An optional form element |
Promise
Send a GET request and return parsed JSON response from the resolved Promise
Returns: Promise
- A resolved or rejected Promise from the server
See: ajax
| Param | Type | Default | Description |
|---|---|---|---|
| [url] | string |
location.href |
The URL of the resource |
| [options] | Object |
{} |
See ajax for details |
Promise
Send a POST request and return parsed JSON response from the resolved Promise
Returns: Promise
- A resolved or rejected Promise from the server
See: ajax
| Param | Type | Default | Description |
|---|---|---|---|
| [url] | string |
location.href |
The URL of the resource |
| [options] | Object |
{} |
See ajax for details |
Promise
Send a POST request with FormData
derived from form element provided by options.form
Returns: Promise
- A resolved or rejected Promise from the server
See: ajax
| Param | Type | Default | Description |
|---|---|---|---|
| [url] | string |
location.href |
The URL of the resource |
| [options] | Object |
{} |
See ajax for details |
ESM Import Example:
import {isArray} from 'ksjs';
// or:
import {isArray} from 'ksjs/array.mjs';
// or:
import {isArray} from 'ksjs/array.js';
CommonJS Require Example:
const {isArray} = require('ksjs/array.cjs');
// or:
const {isArray} = require('ksjs/cjs/array.js');
boolean
boolean
array
array
any
array
array
array
array
array
array
array
array
array
array
boolean
Determine whether “arr” is a true array
Returns: boolean
- true
if arr is array, false
if not
| Param | Type | Description |
|---|---|---|
| arr | array |
item to determine whether it’s an array |
Example
import {isArray} from 'ksjs/array.js';
if (isArray(window.foo)) {
window.foo.push('bar');
}
boolean
Determine whether item “el” is in array “arr”
Returns: boolean
- Boolean (true
if el is in array, false
if not)
| Param | Type | Description |
|---|---|---|
| el | any |
An item to test against the array |
| arr | array |
The array to test against |
array
Convert an object to an array of objects with name and value properties
Returns: array
- An array of objects with name and value properties
| Param | Type | Description |
|---|---|---|
| obj | object |
The object to convert |
Example
import {objectToArray} from 'ksjs/array.js';
const obj = {
foo: 'bar',
baz: 'qux'
};
const arr = objectToArray(obj);
// arr = [
// {name: 'foo', value: 'bar'},
// {name: 'baz', value: 'qux'}
// ];
array
Return an array based on the given value: a) Strings are split by a delimiter (defaults to /\s+/). b) Plain objects are converted to an array of objects with name and value properties. b2) …unless wrapObject is true in which case they are just wrapped in an array c) Undefined and null are returned as an empty array. d) Arrays are returned as is. e) Anything else is wrapped in an array.
Returns: array
- The value converted to an array
| Param | Type | Default | Description |
|---|---|---|---|
| value | any |
The value to convert to an array | |
| [delimiter] | string | RegExp |
"= /\s+/" |
A string or regular expression to use for splitting a string into an array (defaults to /\s+/) |
| [wrapObject] | Boolean |
Whether to simply wrap an object in an array (true) or convert to array of objects with name/value properties |
Example
import {makeArray} from 'ksjs/array.js';
const foo = makeArray('one two three');
// foo is now ['one', 'two', 'three']
const bar = makeArray('one,two,three', ',');
// bar is now ['one', 'two', 'three']
const baz = makeArray(['one', 'two', 'three']);
// baz is still ['one', 'two', 'three']
const quz = makeArray({foo: 'bar'});
// quz is now [{name: 'foo': value: 'bar'}]
const quuz = makeArray(null);
// quuz is now []
any
Return a random item from the provided array
Returns: any
- A random element from the provided array
| Param | Type | Description |
|---|---|---|
| arr | array |
An array of elements |
array
Take an array of objects and a property and return an array of values of that property
Returns: array
- Array of values of the property (if the value is undefined
, returns null
instead)
| Param | Type | Description |
|---|---|---|
| arr | array |
Array from which to pluck |
| prop | string |
Property to pluck |
Example
import {pluck} from 'ksjs/array.js';
let family = [
{
id: 'dad',
name: 'Karl'
},
{
id: 'mom',
name: 'Sara',
color: 'blue'
},
{
id: 'son',
name: 'Ben',
color: 'green'
},
{
id: 'daughter',
name: 'Lucy'
}
];
let names = pluck(family, 'name');
let ids = pluck(family, 'id');
let colors = pluck(family, 'color');
console.log(names);
// Logs: ['Karl', 'Sara', 'Ben', 'Lucy']
console.log(ids);
// Logs: ['dad', 'mom', 'son', 'daughter']
console.log(colors);
// Logs: [null, 'blue', 'green', null]
array
Fisher-Yates (aka Knuth) shuffle. Takes an array of elements and returns the same array, but with its elements shuffled
Returns: array
- The array passed to arr
, shuffled
See: knuth-shuffle
| Param | Type | Description |
|---|---|---|
| els | array |
Array to be shuffled |
array
Merge two or more arrays into a single, new array.
Returns: array
- A new merged array
| Param | Type | Description |
|---|---|---|
| …arrays | array |
2 or more arrays to collapse |
Deprecated
See: merge instead
array
Return a subset of array1
, only including elements from array2
that are also in array1
.
prop
is provided, only that property of an element needs to match for the two arrays to be considered intersecting at that elementReturns: array
- A new filtered array
| Param | Type | Description |
|---|---|---|
| array1 | array |
First array |
| array2 | array |
Second array |
| [prop] | any |
Optional property to compare in each element of the array |
Example
const array1 = [{name: 'Foo', id: 'a'}, {name: 'Bar', id: 'b'}];
const array2 = [{name: 'Foo', id: 'z'}, {name: 'Zippy', id: 'b'}];
console.log(intersect(array1, array2, 'name'));
// Logs [{name: 'Foo', id: 'a'}]
console.log(intersect(array1, array2, 'id'));
// Logs [{name: 'Bar', id: 'b'}]
array
Take an array of elements and return an array containing unique elements. If an element is an object or array:
prop
is undefined, uses JSON.stringify()
when checking the elementsprop
is provided, only that property needs to match for the element to be considered a duplicate and thus excluded from the returned arrayReturns: array
- A new filtered array
| Param | Type | Description |
|---|---|---|
| arr | array |
Array to be filtered by uniqueness of elements (or property of elements) |
| [prop] | any |
Optional property to be tested if an element in arr is an object or array |
Example
const array1 = [1, 2, 3, 2, 5, 1];
const uniq = unique(array1);
console.log(uniq);
// Logs: [1, 2, 3, 5]
array
Return a subset of array1
, only including elements that are NOT also in array2
. The returned array won’t include any elements from array2
.
If an element is an object or array:
prop
is undefined, uses JSON.stringify()
when performing the comparison on an object or arrayprop
is provided, only that property needs to match for the item to be excluded fom the returned arrayReturns: array
- A filtered array
| Param | Type | Description |
|---|---|---|
| array1 | array |
Array for which to return a subset |
| array2 | array |
Array to use as a comparison |
| [prop] | string |
Optional property to be tested if an element in array1 is an object or array |
Example
const array1 = [1, 2, 3, 4];
const array2 = [2, 3, 5, 6, -1];
console.log(diff(array1, array2));
// Logs: [1, 4]
array
From an array passed into the first argument, create an array of arrays, each one consisting of n
items. (The final nested array may have fewer than n
items.)
Returns: array
- A new, chunked, array
| Param | Type | Description |
|---|---|---|
| arr | array |
Array to be chunked. This array itself will not be modified. |
| n | number |
Number of elements per chunk |
array
Create an array of numbers from 0 to a
- 1 (if b
not provided) or from a
to b
(if b
is provided).
Returns: array
- A new array of numbers
| Param | Type | Description |
|---|---|---|
| a | number |
The length of the 0-based array to be returned if b is NOT provided; the first number in the array if b IS provided. |
| [b] | number |
The (optional) last number of the array. |
array
Pad an array with value
until its length equals size
Returns: array
- The array passed to arr
, padded
| Param | Type | Description |
|---|---|---|
| arr | array |
Array to pad |
| size | number |
Total length of the array after padding it |
| value | any |
Value to use for each “padded” element of the array |
array
Sort an array with sensible defaults: numbers (or numeric strings) before letters and case and diacritics ignored
Returns: array
- The sorted array
| Param | Type | Default | Description |
|---|---|---|---|
| arr | array |
Array to sort | |
| [prop] | string |
If dealing with an array of objects, the property by which to sort | |
| [options] | object |
Object indicating options to override defaults (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options) | |
| [options.sensitivity] | string |
"base" |
One of ‘base’, ‘accent’, ‘case’, ‘variant’. Default is ‘base’ |
| [options.numeric] | boolean |
true |
Whether to treat numeric strings as numbers. Default is true |
| [options[…rest]] | any |
Other options (besides sensitivity:‘base’ and numeric: true) per the spec for Intl.Collator.prototype.compare |
ESM Import Example
import {rgb2Hex} from 'ksjs'
// or:
import {rgb2Hex} from 'ksjs/color.mjs'
// or:
import {rgb2Hex} from 'ksjs/color.js'
CJS Require Example
const {rgb2Hex} = require('ksjs/color.cjs');
// or:
const {rgb2Hex} = require('ksjs/cjs/color.js');
string
string
number
string
Convert a hex value to an rgb or rgba value
| Param | Type | Description |
|---|---|---|
| hex | string |
Hex color code in shorthand format (e.g. #333, #333a) or longhand (e.g. #333333, #333333aa) |
| [alpha] | number |
Optional number from 0 to 1 to be used with 3- or 6-character hex format |
string
Convert an rgb value to a 6-digit hex value. If an rgba value is passed, the opacity is ignored
Returns: string
- Hex value (e.g. #ff780a
)
| Param | Type | Description |
|---|---|---|
| rgb | string | array |
either an rgb string such as 'rgb(255, 120, 10)' or an rgb array such as [255, 120, 10] |
Example
rgb2Hex('rgb(255, 136, 0)')
// => '#ff8800'
rgb2Hex([255, 136, 0])
// => '#ff8800'
rgb2Hex('rgba(255, 136, 0, .8)')
// => '#ff8800'
string
Convert an rgba value to an 8-digit hex value, or an rgb value to a 6-digit hex value
Returns: string
- Hex value (e.g. #ff780a80
)
| Param | Type | Description |
|---|---|---|
| rgba | string | array |
either an rgba string such as 'rgba(255, 120, 10, .5)' or an rgba array such as [255, 120, 10, .5] |
Example
rgba2Hex('rgba(255, 136, 0, .8)')
// => '#ff8800cc'
rgba2Hex([255, 136, 0, .8])
// => '#ff8800cc'
rgba2Hex('rgb(255, 136, 0)')
// => '#ff8800'
number
Convert an RGB color to a luminance value. You probably don’t want to use this on its own
Returns: number
- The luminance value
See
| Param | Type | Description |
|---|---|---|
| rgb | string | array |
RGB value represented as a string (e.g. rgb(200, 100, 78) ) or an array (e.g. [200, 100, 78] ) |
string
Return darkColor if bgColor is light and lightColor if bgColor is dark. “Light” and “dark” are determined by the rgb2Luminance algorithm
Returns: string
- Contrasting color
| Param | Type | Default | Description |
|---|---|---|---|
| bgColor | string |
hex code (e.g. #daf or #3d31c2) of the color to contrast | |
| [darkColor] | string |
"'#000'" |
The dark color to return if bgColor is considered light |
| [lightColor] | string |
"'#fff'" |
The light color to return if bgColor is considered dark |
ESM Import Example:
import {getCookie} from 'ksjs';
// or:
import {getCookie} from 'ksjs/cookie.mjs';
// or:
import {getCookie} from 'ksjs/cookie.js';
string
string
string
Get the value of a cookie
Returns: string
- value The value of the cookie
| Param | Type | Description |
|---|---|---|
| name | string |
The name of the cookie whose value you wish to get |
string
Set the value of a cookie. Use either expires or maxAge (or max-age). NOT BOTH.
Returns: string
- The new cookie
| Param | Type | Default | Description |
|---|---|---|---|
| name | string |
Name of the cookie | |
| value | string |
Value of the cookie | |
| [options] | object |
Optional object | |
| [options.path] | string |
"'/'" |
Path within which the cookie can be read. Default is ‘/’. |
| [options.domain] | string |
If not specified, browser defaults to host portion of current location. If domain specified, subdomains always included. (Note: don’t use leading “.”). Default is undefined. | |
| [options.expires] | number |
Number of days after which the cookie should expire. Default is undefined. | |
| [options.maxAge] | number |
Number of seconds after which the cookie should expire. Default is undefined. | |
| [options.samesite] | string |
One of ‘strict’ or ‘lax’. Default is undefined. | |
| [options.secure] | boolean |
If true , cookie can only be sent over secure protocol (e.g. https). Default is undefined. |
Remove a cookie
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the cookie to remove |
| [path] | string |
Optional path of the cookie to remove. If not provided, all name cookies in location.pathname or any of its parents will be removed. |
ESM Import Example:
import {addClass} from 'ksjs';
// or:
import {addClass} from 'ksjs/dom.mjs';
// or:
import {addClass} from 'ksjs/dom.js';
array
Array
Element
string
string
string
string
Object
Element
Element
Object
string
Element
Element
Element
Element
Element(s)
Element(s)
Element
Element
Promise
array
Converts a selector string, DOM element, or collection of DOM elements into an array of DOM elements
Returns: array
- An array of DOM elements
| Param | Type | Description |
|---|---|---|
| element(s) | Element | NodeList | array | string |
The selector string, element, or collection of elements (NodeList, HTMLCollection, Array, etc) |
Array
Return an array of DOM Nodes within the document or provided element/nodelist
Returns: Array
- Array of DOM nodes matching the selector within the context
| Param | Type | Default | Description |
|---|---|---|---|
| selector | string |
The CSS selector of the DOM elements | |
| [context] | Element | NodeList | array | string |
document |
The selector string, element, or collection of elements (NodeList, HTMLCollection, Array, etc) representing one or more elements within which to search for selector |
Element
Return the first found DOM Element within the document or provided element/nodelist/HTMLCollection
Returns: Element
- First DOM Element matching the selector within the context
| Param | Type | Default | Description |
|---|---|---|---|
| selector | string |
Selector string for finding the DOM element | |
| [context] | Element | NodeList | array | string |
document |
The selector string, element, or collection of elements (NodeList, HTMLCollection, Array, etc) representing one or more elements within which to search for selector |
string
Add one or more classes to an element
Returns: string
- the resulting class after classes have been removed
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM element for which to add the class |
| className | string |
class to add to the DOM element |
| […classNameN] | string |
one or more additional className arguments representing classes to add to the element |
string
Remove one or more classes from an element
Returns: string
- the resulting class after classes have been removed
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM element from which to remove the class |
| className | string |
class to remove from the DOM element |
| […classNameN] | string |
one or more additional className arguments representing classes to remove from the element |
string
Add a class if it’s not present (or if toggle is true); remove the class if it is present (or if toggle is false)
Returns: string
- The className
property of the element after the class has been toggled
| Param | Type | Description |
|---|---|---|
| el | Element |
Element on which to toggle the class |
| className | string |
The class name to either add or remove |
| [toggle] | boolean |
Optional boolean argument to indicate whether className is to be added (true) or removed (false) |
string
Replace oldClass with newClass
Returns: string
- The className
property of the element after the class has been replaced
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM element for which you want to replace oldClass with newClass |
| oldClass | string |
The class name you want to get rid of |
| newClass | string |
The class name you want to add in place of oldClass |
Object
Get the top and left distance to the element (from the top of the document)
Returns: Object
- Object with top
and left
properties representing the top and left offset of the element
| Param | Type | Description |
|---|---|---|
| el | Element |
Element for which to get the offset |
Element
Set one or more styles on an element.
Returns: Element
- The original element, with the styles set
| Param | Type | Description |
|---|---|---|
| el | Element |
element on which to add styles |
| styles | Object.<string, (string|number)> |
object of styles and their values to add to the element |
Element
Set one or more attributes on an element. For boolean attributes (‘async’, ‘required’, etc.), set the element’s property to either true
or false
Returns: Element
- The original element, with the attributes set
| Param | Type | Description |
|---|---|---|
| el | Element |
element on which to add attributes |
| attrs | Object.<string, (string|boolean|number)> |
object of attributes and their values to add to the element |
Object
Given an array of attribute names, get an object containing attribute names/values for an element
Returns: Object
- Object of attribute names along with their values
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM Element. If NodeList is provided, uses the first element in the list |
| attrs | Array.<string> |
Array of attribute names |
string
Add an attribute to an element if it’s not present (or if toggle is true
); remove the attribute if it is present (or if toggle is false
)
Returns: string
- The attribute name if it has been added, undefined
if it has been removed
| Param | Type | Description |
|---|---|---|
| el | Element |
Element on which to toggle the attribute |
| attribute | string |
The attribute to either add or remove |
| [toggle] | boolean |
Optional boolean argument to indicate whether the attribute is to be added (true) or removed (false) * |
| Param | Type | Description |
|---|---|---|
| element | Element |
html element |
| position | string |
position for insertion |
| toInsert | string |
html string to insert |
Element
Insert an element as the first child of el
Returns: Element
- The inserted element
| Param | Type | Description |
|---|---|---|
| el | Element |
Reference element |
| toInsert | Element | string |
DOM element or HTML string to insert as the first child of el |
Element
Insert an element as the last child of el
Returns: Element
- The inserted element
| Param | Type | Description |
|---|---|---|
| el | Element |
Reference element |
| toInsert | Element | string |
DOM element or HTML string to insert as the last child of el |
Element
Insert an element as the previous sibling of el
Returns: Element
- The inserted element
| Param | Type | Description |
|---|---|---|
| el | Element |
Reference element |
| toInsert | Element | string |
DOM element or HTML string to insert as the previous sibling of el |
Element
Insert an element as the next sibling of el
Returns: Element
- The inserted element
| Param | Type | Description |
|---|---|---|
| el | Element |
Reference element |
| toInsert | Element | string |
DOM element or HTML string to insert as the next sibling of el |
Element(s)
Provide an object, along with possible child objects, to create a node tree ready to be inserted into the DOM.
Returns: Element(s)
- The created Element node tree
| Param | Type | Description |
|---|---|---|
| options | object |
|
| [options.tag] | string |
Optional tag name for the element. If none provided, a document fragment is created instead |
| [options.text] | string |
Optional inner text of the element. |
| [options.children] | Array.<Object> |
Optional array of objects, with each object representing a child node |
| […options[attr]] | string |
One or more optional attributes to set on the element |
Element(s)
Provide an object, along with possible child objects, to create an HTML string that can be inserted into the DOM.
Returns: Element(s)
- The created Element node tree
| Param | Type | Description |
|---|---|---|
| options | object |
|
| [options.tag] | string |
Optional tag name for the element. If none provided, a document fragment is created instead |
| [options.text] | string |
Optional inner text of the element. |
| [options.children] | Array.<Object> |
Optional array of objects, with each object representing a child node |
| […options[attr]] | string |
One or more optional attributes to set on the element |
Element
Remove an element from the DOM
Returns: Element
- DOM element removed from the DOM
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM element to be removed |
Element
Empty an element’s children from the DOM
Returns: Element
- DOM element provided by el
argument
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM element to clear of all children |
Replace a DOM element with one or more other elements
| Param | Type | Description |
|---|---|---|
| oldEl | Element |
The element to be replaced |
| replacement | Element | Array.<Element> |
An element, or an array of elements, to insert in place of oldEl |
Promise
Insert a script into the DOM with reasonable default properties, returning a promise. If options.id
is set, will avoid loading script if the id is already in the DOM.
Returns: Promise
- Promise that is either resolved or rejected. If options.id
is NOT provided or if no element exists with id of options.id
, promise is resolved when script is loaded. If options.id
IS provided and element with same id exists, promise is resolved or rejected (depending on options.onDuplicateId
) with no attempt to load new script.
| Param | Type | Default | Description |
|---|---|---|---|
| options | object |
An object of options for loading the script. All except complete and completeDelay will be set as properties on the script element before it is inserted. |
|
| [options.src] | string |
The value of the script’s src property. Required if options.textContent not set |
|
| [options.textContent] | string |
The text content of the script. Ignored if options.src set. Required if options.src NOT set. |
|
| [options.async] | boolean |
true |
The value of the script’s async property. Default is true . |
| [options.completeDelay] | number |
0 |
Number of milliseconds to wait when the script has loaded before resolving the Promise to account for time it might take for the script to be parsed |
| [options.id] | string |
String representing a valid identifier to set as the script element’s id property. If set, the script will not be loaded if an element with the same id already appears in the DOM |
|
| [options.onDuplicateId] | string |
"resolve" |
One of ‘resolve’ or ‘reject’. Whether to return a resolved or rejected promise when a script with an id matching the provided options.id is already in the DOM. Either way, the function will not attempt to load the script again and the resolved/rejected promise will be passed an object with {duplicate: true} . |
| […options[scriptProperties]] | boolean | string |
Any other values to be set as properties of the script element |
ESM Import Example:
import {addEvent} from 'ksjs';
// or:
import {addEvent} from 'ksjs/event.mjs';
// or:
import {addEvent} from 'ksjs/event.js';
A wrapper around addEventListener
that deals with browser inconsistencies (e.g. capture
, passive
, once
props on options
param; see param documentation below for details) and handles window load similar to how jQuery handles document ready by triggering handler immediately if called after the event has already fired.
For triggering window load, this file MUST be imported before window.load occurs.
| Param | Type | Default | Description |
|---|---|---|---|
| el | Window | Element |
DOM element to which to attach the event handler | |
| type | string |
Event type | |
| handler(event) | function |
Handler function. Takes event as its argument |
|
| [options] | Object | boolean |
false |
Optional object or boolean. If boolean, indicates whether the event should be in “capture mode” rather than starting from innermost element and bubbling out. Default is false . If object, and browser does not support object, argument is set to capture property if provided |
| [options.capture] | boolean |
false |
Indicates if the event should be in “capture mode” rather than starting from innermost element and bubbling out. Default is false . |
| [options.passive] | boolean |
If true , uses passive mode to reduce jank. This is automatically set to true for supported browsers if not explicitly set to false for the following event types: touchstart, touchmove, wheel, mousewheel. Ignored if not supported. |
|
| [options.once] | boolean |
If true , removes listener after it is triggered once on the element. |
A wrapper around removeEventListener
that naïvely deals with oldIE inconsistency.
| Param | Type | Default | Description |
|---|---|---|---|
| el | Element |
DOM element to which to attach the event handler | |
| type | string |
Event type. | |
| [handler] | function |
Handler function to remove. | |
| [options] | Object | boolean |
false |
Optional object or boolean. If boolean, indicates whether event to be removed was added in “capture mode”. Important: non-capturing here only removes non-capturing added event and vice-versa. |
| [options.capture] | boolean |
Indicates whether event to be removed was added in “capture mode” |
Trigger a custom event on an element for which a listener has been set up
Derived from emitEvent(): © 2019 Chris Ferdinandi, MIT License, https://gomakethings.com
| Param | Type | Description |
|---|---|---|
| el | Element |
DOM element on which to trigger the event |
| type | string |
Name representing the custom event type |
| detail | Object |
Object to make available as the detail property of the event handler’s event argument |
Example
// Using this module's addEvent() function
// Add a custom event handler
addEvent(document.body, 'myCustomEvent', (event) => console.log(event.detail.weather));
// Later…
// Trigger the custom event
triggerEvent(document.body, 'myCustomEvent', {weather: 'sunshine'});
// Logs: 'sunshine'
ESM Import Example:
import {getFormData} from 'ksjs';
// or:
import {getFormData} from 'ksjs/form.mjs';
// or:
import {getFormData} from 'ksjs/form.js';
any
FormData
any
Return the set of successful form controls of the provided form
element in one of four types: object, string, formData, or array.
Returns: any
- The set of successful form controls as the provided type
| Param | Type | Default | Description |
|---|---|---|---|
| form | Element |
The form element | |
| [type] | string |
"object" |
One of ‘object’, ‘string’, ‘formData’, or ‘array’ |
Methods
| Name | Type | Description |
|---|---|---|
| .object(form) | function |
Return form data as an object of key/value pairs |
| .string(form) | function |
Return form data as a query string |
| .formData(form) | function |
Return a FormData instance |
| .array(form) | function |
Return form data as an array of objects with name and value properties |
Example
const myform = document.getElementById('myform');
console.log(getFormData.object(myform));
// Logs:
// {
// email<EMAIL_ADDRESS>// gender: 'female',
// meals: ['breakfast', 'dinner']
// }
Example
const myform = document.getElementById('myform');
console.log(getFormData.string(myform));
// Logs:
// email=name%40example.com&gender=female&meals[]=breakfast&meals[]=dinner
Example
const myform = document.getElementById('myform');
console.log(getFormData.array(myform));
// Logs:
// [
// {
// name: 'email',
// value<EMAIL_ADDRESS>// },
// {
// name: 'gender',
// value: 'femail'
// },
// {
// name: 'meals[]',
// value: 'breakfast'
// },
// {
// name: 'meals[]',
// value: 'dinner'
// }
// ]
FormData
Note: if the value of a key is an object with a files
property, each file in the files array will be appended to the FormData object.
Returns: FormData
- The form data object
| Param | Type | Description |
|---|---|---|
| values | Object | Array |
The object or array of objects to convert |
ESM Import Example:
import {getJSONP} from 'ksjs';
// or:
import {getJSONP} from 'ksjs/jsonp.mjs';
// or:
import {getJSONP} from 'ksjs/jsonp.js';
Function for those times when you just need to make a “jsonp” request (and you can’t set up CORS on the server). In other words, x-site script grabbing.
| Param | Type | Default | Description |
|---|---|---|---|
| options | Object |
||
| options.url | string |
URL of the jsonp endpoint | |
| [options.data] | Object |
Optional data to include with the request | |
| [options.data.callback] | string |
"jsonp.[timestamp]" |
Optional value of the callback query-string parameter to append to the script’s src |
| callback(json) | function |
Function to be called when request is complete. A json object is passed to it. |
Example
getJSONP({url: 'https://example.com/api/'})
ESM Import Example:
import {median} from 'ksjs';
// or:
import {median} from 'ksjs/math.mjs';
// or:
import {median} from 'ksjs/math.js';
CommonJS Require Example:
const {median} = require('ksjs/math.cjs');
// or:
const {median} = require('ksjs/cjs/math.js');
number
number
number
number
number
number
number
number
number
number
Return the result of adding an array of numbers (sum)
Returns: number
- Sum
| Param | Type | Description |
|---|---|---|
| array | array |
Array of numbers |
number
Return the result of subtracting an array of numbers (difference)
Returns: number
- Difference
| Param | Type | Description |
|---|---|---|
| array | array |
Array of numbers |
number
Return the result of multiplying an array of numbers (product)
Returns: number
- Product
| Param | Type | Description |
|---|---|---|
| array | array |
Array of numbers |
number
Return the result of dividing an array of numbers (quotient)
Returns: number
- Quotient
| Param | Type | Description |
|---|---|---|
| array | array |
Array of numbers |
number
Return the remainder after dividing two numbers (modulo)
Returns: number
- Remainder
| Param | Type | Description |
|---|---|---|
| dividend | number | array |
A number representing the dividend OR an array of [dividend, divisor] |
| [divisor] | number |
Number representing the divisor if the first argument is a number |
number
Return the average of an array of numbers
Returns: number
- Average
| Param | Type | Description |
|---|---|---|
| nums | array |
Array of numbers |
number
Return the median of an array of numbers
Returns: number
- Median
| Param | Type | Description |
|---|---|---|
| nums | array |
Array of numbers |
number
Return the number with the lowest value from an array of numbers
Returns: number
- Minimum value
| Param | Type | Description |
|---|---|---|
| nums | array |
Array of numbers |
number
Return the number with the highest value from an array of numbers
Returns: number
- Maximum value
| Param | Type | Description |
|---|---|---|
| nums | array |
Array of numbers |
ESM Import Example:
import {deepCopy} from 'ksjs';
// or:
import {deepCopy} from 'ksjs/object.mjs';
// or:
import {deepCopy} from 'ksjs/object.js';
CommonJS Require Example:
import {deepCopy} from 'ksjs/object.cjs';
// or:
const {deepCopy} = require('ksjs/cjs/object.js');
Object
Object
Object
*
*
boolean
Object
void
Object
Object
Indicate if the provided argument is an object/array
| Param | Type | Description |
|---|---|---|
| obj | Object |
The argument that will be checked to see if it is an object |
Indicate if the provided argument is a plain object Derived from lodash _.isPlainObject
| Param | Type | Description |
|---|---|---|
| obj | Object |
The argument that will be checked to see if it is a plain object |
Object
Deep copy an object (alternative to deepCopy), using graph theory and new Map(). Avoids circular refs and infinite loops.
Returns: Object
- A copy of the object
See: Cloning JavaScript objects with Graph Theory
| Param | Type |
|---|---|
| obj | Object |
Object
Deep copy an object, avoiding circular references and the infinite loops they might cause.
Returns: Object
- A copy of the object
| Param | Type | Description |
|---|---|---|
| obj | Object |
The object to copy |
| [forceFallback] | Boolean |
If set to true , doesn’t try to use native structuredClone function first. |
| [cache] | Array.<Object> |
Used internally to avoid circular references |
Object
Deep merge two or more objects in turn, with right overriding left
Heavily influenced by/mostly ripped off from jQuery.extend
Returns: Object
- The merged object
| Param | Type | Description |
|---|---|---|
| target | Object |
The target object that will be mutated. Use {} to create new object |
| …objects | Object |
One or more objects to merge into the first |
Example
const foo = {
one: 'singular',
two: 'are better'
};
const bar = {
one: 'taste',
choco: 'hershey',
saloon: 'wild west',
};
const merged = extend(foo, bar);
// merged is now:
// {
// one: 'taste',
// two: 'are better',
// choco: 'hershey',
// saloon: 'wild west',
// }
// because foo was mutated, it is also:
// {
// one: 'taste',
// two: 'are better',
// choco: 'hershey',
// saloon: 'wild west',
// }
*
Get a nested property of an object in a safe way
Returns: *
- The value of the nested property, or undefined
, or the designated fallback value
| Param | Type | Description |
|---|---|---|
| root | Object |
The root object |
| properties | Array.<String> | String |
Either an array of properties or a dot-delimited string of properties |
| fallbackValue | any |
A value to assign if it’s otherwise undefined |
Example
const foo = {
could: {
keep: {
going: 'but will stop'
}
};
console.log(getProperty(foo, 'could.keep.going'))
// Logs: 'but will stop'
console.log(getProperty(foo, ['could', 'keep', 'going']))
// Logs: 'but will stop'
console.log(getProperty(foo, ['broken', 'not', 'happening']))
// Logs: undefined
};
*
Get a nested property of an object in a safe way
Returns: *
- The value of the last nested property referenced in properties
arg that has a defined value
| Param | Type | Description |
|---|---|---|
| root | Object |
The root object |
| properties | Array.<String> | String |
Either an array of properties or a dot-delimited string of properties |
Example
const foo = {
could: {
keep: {
going: 'but will stop'
},
shortStop: 'ride ends here'
};
console.log(getLastDefined(foo, 'could.keep.going'))
// Logs: 'but will stop'
console.log(getLastDefined(foo, ['shortStop', 'stops', 'short']))
// Logs: 'ride ends here'
};
boolean
Determine whether an object (or array) is “empty”
Returns: boolean
- true
if object has no keys or array no elements
| Param | Type | Description |
|---|---|---|
| obj | object | array |
The object to test |
Object
Set a nested property of an object in a safe way
Returns: Object
- The modified root object
| Param | Type | Description |
|---|---|---|
| root | Object |
The root object |
| properties | Array.<String> | String |
Either an array of properties or a dot-delimited string of properties |
| value | any |
The value to set for the nested property |
void
Loop through an object, calling a function for each element (like forEach, but for an object)
| Param | Type | Description |
|---|---|---|
| obj | Object |
The object to iterate over |
| fn | function |
A function to be called for each member of the object. The function takes two parameters: the member’s value and the member’s key, respectively |
INTERNAL: Return either the same object passed in first parameter or a deep copy of the object, depending on the deep option.
| Param | Type | Description |
|---|---|---|
| obj | Object |
The object to return |
| options | Object |
Options object |
| options.deep | boolean |
Whether to deep-clone the object or not before returning it |
Object
Return a new object containing only the properties included in the props array.
Returns: Object
- A copy of the object, containing only the props
properties
| Param | Type | Default | Description |
|---|---|---|---|
| obj | Object |
The object from which to get properties | |
| props | array.<string> |
Properties to get from the object | |
| [options] | Object |
Options object | |
| [options.deep] | boolean |
true |
Whether to deep-clone the object before assigning its properties to the new object |
Object
Return a new object, excluding the properties in the props array.
Returns: Object
- A modified copy of the object
| Param | Type | Default | Description |
|---|---|---|---|
| obj | Object |
The object from which to get properties | |
| props | array |
Properties to exclude from the object | |
| [options] | Object |
Options object | |
| [options.deep] | boolean |
true |
Whether to deep-clone the object before assigning its properties to the new object |
ESM Import Example:
import {peach} from 'ksjs';
// or:
import {peach} from 'ksjs/promise.mjs';
// or:
import {peach} from 'ksjs/promise.js';
CommonJS Require Example:
import {peach} from 'ksjs/promise.cjs';
// or:
const {peach} = require('ksjs/cjs/promise.js');
Array.<Promise>
Promise
Promise
Promise
Array.<Promise>
“Promised each()
” for iterating over an array of items, calling a function that returns a promise for each one. So, each one waits for the previous one to resolve before being called
Returns: Array.<Promise>
- Array of promises
| Param | Type | Description |
|---|---|---|
| arr | array |
Array to iterate over |
| fn | ArrayCallback |
Function that is called for each element in the array, each returning a promise |
Promise
“Promised map()
” for iterating over an array of items sequentially (or in parallel), calling a function that returns either the Promise of a modified item or the modified item itself, ultimately returning a single resolved Promise containing the modified array.
Returns: Promise
- A resolved Promise, fulfilled with an array containing the mapped items of arr
| Param | Type | Default | Description |
|---|---|---|---|
| arr | array |
Array to iterate over | |
| fn | ArrayCallback |
Function that is called for each element in the array, each returning a modified result | |
| [order] | string |
"sequence" |
Whether to call the callback for each item sequentially ('sequence' , default) or at the same time ('parallel' ). |
Example
import {pmap} from 'ksjs/promise.js';
const fruits = ['apple', 'banana', 'pear'];
const indexedFruits = pmap(fruits, (fruit, i) => {
});
Promise
“Promised filter()
” to iterate over an array of items sequentially (or in parallel), which acts just like Array.prototype.filter()
but allows the callback function to return either a Promise containing a truthy/falsy value or the truthy/falsy value itself. Returns a single resolved Promise containing the filtered array.
Returns: Promise
- A resolved Promise, fulfilled with an array containing the mapped items of arr
| Param | Type | Default | Description |
|---|---|---|---|
| arr | array |
Array to iterate over | |
| fn(item,index,array) | ArrayCallback |
Function that is called for each element in the array, each returning a modified result | |
| [order] | string |
"sequence" |
Whether to call the callback for each item sequentially ('sequence' , default) or at the same time ('parallel' ). |
Example
import {pmap} from 'ksjs/promise.js';
const fruits = ['apple', 'banana', 'pear'];
const indexedFruits = pmap(fruits, (fruit, i) => {
});
Promise
| Param | Type |
|---|---|
| item | any |
| [index] | number |
| [array] | array |
ESM Import Example:
import {getSelection} from 'ksjs';
// or:
import {getSelection} from 'ksjs/selection.mjs';
// or:
import {getSelection} from 'ksjs/selection.js';
Object
Replace the selected text in a given element with the provided text
Returns: Object
- Selection object containing the following properties: {start, end, length, text}
| Param | Type | Description |
|---|---|---|
| elem | Element |
Element containing the selected text |
| replaceString | string |
String to replace the selected text |
Set the selection of an element’s contents. NOTE: If startPos and/or endPos are used on a non-input element, only the first text node within the element will be used for selection
| Param | Type | Default | Description |
|---|---|---|---|
| elem | Element |
The element for which to set the selection | |
| [startPos] | number |
0 |
The start position of the selection. Default is 0. |
| [endPos] | number |
The end position of the selection. Default is the last index of the element’s contents. |
Sets the selection of all of the element’s contents (including all of its children)
| Param | Type | Description |
|---|---|---|
| el | Element |
The element for which to select all content |
Return an object with the following properties related to the selected text within the element:
start
: 0-based index of the start of the selectionend
: 0-based index of the end of the selectionlength
: the length of the selectiontext
: the selected text within the element| Param | Type | Description |
|---|---|---|
| el | Element |
An element with selected text |
ESM Import Example:
import {Storage} from 'ksjs';
// or:
import {Storage} from 'ksjs/storage.mjs';
// or:
import {Storage} from 'ksjs/storage.js';
number
any
string
Object
array
number
Get the number of items in the storage
Returns: number
- The number of items
any
Get and JSON.parse the value of the storage item identified by key
Returns: any
- The JSON.parsed value of the storage item
| Param | Type | Description |
|---|---|---|
| key | string |
The key of the storage item |
string
Set the JSON.stringified value of the storage item identified by key
Returns: string
- The stringified value that is set
| Param | Type | Description |
|---|---|---|
| key | string |
The key of the storage item |
| value | any |
The value to be set for key |
Remove the storage item identified by key
| Param | Type | Description |
|---|---|---|
| key | string |
The key of the storage item to remove |
Remove all storage items
Object
Get an object of key/value pairs of all storage items
Returns: Object
- All storage items
array
Loop through all storage items and return an array of their keys
Returns: array
- Array of the keys of all storage items
Constructor for storage functions.
Returns: this
| Param | Type | Default | Description |
|---|---|---|---|
| [type] | string |
"local" |
Type of storage: either ‘local’ or ‘session’ |
| [ns] | string |
"bamf" |
Namespace for keys to prevent potenial collisions with storage items used by libraries, etc. |
ESM Import Example:
import {slugify} from 'ksjs';
// or:
import {slugify} from 'ksjs/string.mjs';
// or:
import {slugify} from 'ksjs/string.js';
CommonJS Require Example:
const {slugify} require('ksjs/string.cjs');
// or:
const {slugify} = require('ksjs/cjs/string.js');
string
string
string
string
string
number
| string
string
string
string
string
Boolean
| Number
| Array
string
string
Converts a singular word to a plural
Returns: string
- Pluralized string
| Param | Type | Default | Description |
|---|---|---|---|
| str | string |
Word to pluralize | |
| num | number |
Number of items | |
| [ending] | string |
"s" |
Optional ending of the pluralized word |
string
Changes the case of the provided words according to the type
.
Returns: string
- Converted string
| Param | Type | Description |
|---|---|---|
| str | string |
String that will be cased as determined by type |
| type | string |
One of 'title |
| [options] | object |
Optional options object. Its use depends on the type of case change |
Example
const oldMan = 'the old man and the sea';
console.log(changeCase(oldMan, 'title'));
// Logs: 'The Old Man and the Sea'
console.log(changeCase(oldMan, 'sentence'));
// Logs: 'The old man and the sea'
console.log(changeCase('the-old-man-and-the-sea', 'sentence', {unslugify: true}));
// Logs: 'The old man and the sea'
console.log(changeCase(oldMan, 'camel'));
// Logs: 'theOldManAndTheSea'
string
Slugify a string by lowercasing it and replacing white spaces and non-alphanumerics with dashes.
Returns: string
- “Slugified” string
| Param | Type | Description |
|---|---|---|
| str | string |
String to be converted to a slug |
Example
console.log(slugify('Hello there, how are you?'));
// Logs: 'hello-there-how-are-you'
console.log(slugify(' You? & Me<3* '));
// Logs: 'you-me-3'
string
Returns: string
- The truncated string, or the full string if it’s shorter than the total amount to truncate
| Param | Type | Default | Description |
|---|---|---|---|
| string | str |
The string to be truncated | |
| options | object |
Options object. | |
| [options.start] | int |
The number of characters to keep at the start of the string. If falsy, no truncation will occur at the start. | |
| [options.end] | int |
The number of characters to keep at the end of the string. If falsy, no truncation will occur at the end. | |
| [options.separator] | string |
"'…'" |
The separator to use when truncating the string. Defaults to ‘…’ |
Example
const str = 'Collaboratively administrate empowered markets';
console.log(truncate(str, {start: 10}));
// Logs: 'Collaborat...'
console.log(truncate(str, {start: 10, separator: ''}));
// Logs: 'Collaborat'
console.log(truncate(str, {end: 10}));
// Logs: '...ed markets'
console.log(truncate(str, {start: 10, end: 10}));
// Logs: 'Collaborat...ed markets'
console.log(truncate(str, {start: 50, end: 50}));
// Logs: 'Collaboratively administrate empowered markets'
string
ROT13 encode/decode a string
Returns: string
- The encoded (or decoded) string
| Param | Type | Description |
|---|---|---|
| string | string |
String to be converted to or from ROT13 |
number
| string
Convert a string to Java-like numeric hash code
Returns: number
| string
- The converted hash code as numeral (or string, if prefix is provided)
See: http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
| Param | Type | Description |
|---|---|---|
| str | string |
String to be converted |
| [prefix] | string |
Optional prefix to the hash |
string
Return a base64-encoded string based on the provided string. If the browser does not support this type of encoding, returns the string unchanged.
Returns: string
- base64-encoded string
| Param | Type | Description |
|---|---|---|
| str | string |
String to be base4 encoded |
string
Return a decoded string based on the provided base64-encoded string. If the browser does not support this type of encoding, returns the string unchanged.
Returns: string
- decoded string
| Param | Type | Description |
|---|---|---|
| str | string |
base4-encoded string |
string
Return a pseudo-random string consisting of two base-36 strings, separated by the optional provided sep
argument.
The first number is derived from a random 11-digit number
The second number is derived from the current date, including milliseconds
The string can begin with an optional prefix
| Param | Type | Default | Description |
|---|---|---|---|
| [sep] | string |
"." |
Optional separator for the two base-36 strings, Default is “.” |
| [prefix] | string |
"''" |
Optional prefix for the string |
string
Returns: string
- String with tokens replaced with values
See: https://stackoverflow.com/a/59084440
| Param | Type | Description |
|---|---|---|
| str | string |
String with tokens ( ${example} ) to parse |
| obj | object |
Object of properties with values to be used when replacing tokens |
Boolean
| Number
| Array
Casts a value to the specified type
or to best guess at a type if none given
| Param | Type | Description |
|---|---|---|
| value | string |
Value to cast |
| [type] | function |
(Boolean |
| [options] | object |
string
Strip tags from a string
Returns: string
- Stripped string
| Param | Type | Description |
|---|---|---|
| str | string |
String to be stripped of tags |
Example
console.log(stripTags('<p>Hello</p>'));
// Logs: 'Hello'
console.log(stripTags('<p>Hello</p><p>World</p>'));
// Logs: 'HelloWorld'
ESM Import Example:
import {debounce} from 'ksjs';
// or:
import {debounce} from 'ksjs/timer.mjs';
// or:
import {debounce} from 'ksjs/timer.js';
CommonJS Require Example:
import {debounce} from 'ksjs/timer.cjs';
// or:
const {debounce} = require('ksjs/cjs/timer.js');
number
Constant representing the number of milliseconds in an hour
number
Constant representing the number of milliseconds in a day
number
Constant representing the number of milliseconds in a year
Set up a function to be called once at the end of repeated potential calls within a given delay
| Param | Type | Default | Description |
|---|---|---|---|
| fn | function |
The function to trigger once at the end of a series of potential calls within delay |
|
| [timerDelay] | number |
200 |
Number of milliseconds to delay before firing once at the end |
| [ctx] | Element |
this |
The context in which to call fn |
Example
const scrollLog = function(event) {
console.log('Started resizing the window!');
};
window.addEventListener('resize', debounce(scrollLog));
Set up a function to be called once at the end of repeated potential calls within a given delay
| Param | Type | Default | Description |
|---|---|---|---|
| fn | function |
The function to trigger once at the beginning of a series of potential calls within delay |
|
| [timerDelay] | number |
200 |
Number of milliseconds within which to avoid calling the same function |
| [ctx] | Element |
this |
The context in which to call fn |
Example
const scrollLog = function(event) {
console.log('Started resizing the window!');
};
window.addEventListener('resize', debounce(scrollLog));
Set up a function to be called no more than once every timerDelay
milliseconds
| Param | Type | Default | Description |
|---|---|---|---|
| fn | function |
The function to throttle | |
| [timerDelay] | number |
200 |
Number of milliseconds to throttle the function calls |
| [context] | Element |
this |
The context in which to call fn |
Set up a function to be called immediately before the next repaint using requestAnimationFrame()
| Param | Type | Default | Description |
|---|---|---|---|
| fn | function |
The function to call | |
| [context] | Element |
this |
The context in which to call fn |
Set up a function to be called when the UI thread is idle by using requestIdleCallback()
.
Falls back to using requestAnimationFrame (or an rAF polyfill) if
requestIdleCallback()` is not supported.
| Param | Type | Default | Description |
|---|---|---|---|
| fn | function |
The function to call | |
| [context] | Element |
this |
The context in which to call fn |
any
Returns: any
- The result of the promise if it is resolved or the exception if it is rejected
| Param | Type | Description |
|---|---|---|
| promise | Promise |
A promise to be resolved |
| ms | number |
The number of milliseconds to wait for the promise to be resolved before rejecting |
| exception | any |
An optional exception to be thrown if the promise is rejected |
Like setTimeout, but with a promise that resolves when the timeout has expired.
| Param | Type | Description |
|---|---|---|
| timeout | number |
The number of ms to wait before resolving the promise |
ESM Import Example:
import {serialize} from 'ksjs';
// or:
import {serialize} from 'ksjs/url.mjs';
// or:
import {serialize} from 'ksjs/url.js';
CommonJS Require Example:
import {serialize} from 'ksjs/url.cjs';
// or:
const {serialize} = require('ksjs/cjs/url.js');
string
string
array
array
string
Object
string
Return a normalized pathname
(old IE doesn’t include initial “/” for this.pathname
) of a passed object if it has an href
property, or return the derived path name from string representing a URL
Returns: string
- pathname
| Param | Type | Default | Description |
|---|---|---|---|
| [obj] | Object | Location | string |
window.location |
An object with a pathname propety or a string representing a URL |
string
Return the basename of an object with pathname
property or a string. Similar to node.js path.basename()
Returns: string
- basename
| Param | Type | Default | Description |
|---|---|---|---|
| [obj] | Object | string |
window.location |
An object with a pathname property, or a string representing a URL |
| [ext] | string |
Extension (e.g. ‘.html’) to remove from the end of the basename) |
array
Return an array consisting of each segment of a URL path
Returns: array
- Array of segments
| Param | Type | Default | Description |
|---|---|---|---|
| [obj] | Object | string |
window.location |
An object with a pathname property, or a string representing a URL |
array
Return the index
th segment of a URL path
Returns: array
- A segment of the path derived from obj
at index
| Param | Type | Default | Description |
|---|---|---|---|
| index | number |
Index of the segment to return. If < 0, works like [].slice(-n) |
|
| [obj] | Object | string |
window.location |
An object with a pathname property, or a string representing a URL |
string
Convert an object to a serialized string
Returns: string
- A query string
| Param | Type | Description |
|---|---|---|
| data | Object |
Plain object to be serialized |
| [options] | Object |
Optional settings |
| [options.raw] | boolean |
If true , property values are NOT url-decoded |
| [options.prefix] | string |
If set, and data is an array, sets as if prefix were the name of the array |
| [options.arrayToString] | boolean |
If true , calls .toString() on arrays. So {foo: ['won', 'too']} becomes foo=won%2Ctoo . Used in conjunction with {raw: true} , the same object becomes foo=won,too |
| [options.indexed] | boolean |
If true (and options.arrayToString is NOT true ), arrays take the form of foo[0]=won&foo[1]=too ; otherwise, foo[]=won&foo[]=too |
Example
console.log(serialize({foo: 'yes', bar: 'again}));
// Logs: 'foo=yes&bar=again'
Example
console.log(serialize({foo: ['yes', 'again']}, {arrayToString: true}));
// Logs: 'foo=yes,again'
console.log(serialize({foo: ['yes', 'again']}));
// Logs: 'foo[]=yes&foo[]=again'
console.log(serialize({foo: ['yes', 'again']}, {indexed: true}));
// Logs: 'foo[0]=yes&foo[1]=again'
console.log(serialize(['yes', 'again'], {prefix: 'foo'}));
// Logs: 'foo[0]=yes&foo[1]=again'
console.log(serialize(['yes', 'again'], {prefix: 'foo', indexed: false}));
// Logs: 'foo[]=yes&foo[]=again'
Object
Convert a serialized string to an object
Returns: Object
- An object of key/value pairs representing the query string parameters
| Param | Type | Default | Description |
|---|---|---|---|
| [string] | string |
"location.search" |
Query string |
| [options] | Object |
Optional options | |
| [options.raw] | boolean |
false |
If true , param values will NOT be url-decoded |
| [options.empty] | any |
true |
The returned value of a param with no value (e.g. ?foo&bar&baz ). Typically, this would be either true or '' |
| [options.splitValues] | Boolean | RegExp | String |
false |
If NOT false , splits converts to an array all values with one or more matches of the splitValues option. If true , splits on commas (/,/ ). So, ?foo=bar,baz becomes {foo: ['bar', 'baz']} |
| [options.shallow] | boolean |
false |
If true , does NOT attempt to build nested object |


When you work with us, you are a part of a team of committed collaborators. All aspects of our software development process are integrated, interactive and agile
Our approach unifies design, development and product management to create exceptional products.
We start each project by understanding your business goals, the user's needs
and the product requirements.
Then we help them translate into effective
and elegant solutions.
DESIGN
Our design practice offers a full range of services including brand strategy, interaction and visual design and user experience testing. Throughout your project, our designers create and implement visual design and workflows, solicit user feedback and work with you to make sure what gets built is what is needed.
DEVELOPMENT
All engineers are fluent in the latest enterprise, mobile and web development technologies. They collaborate with your team to write, and improve code on a daily basis, using proven practices such as test-driven development and pair programming.
PRODUCT MANAGEMENT
Planning and development is iterative. Because we are constantly coding and testing, the products we build are always ready to go live. This iterative process allows for changes as business requirements evolve.
Delani Portfolio
Ontario Security
Delani Portfolio
Delani Portfolio
Delani Portfolio
Delani Portfolio
Mock-up burned logo
Giraffe restaurant


The Filter Plugin has been updated to allow multiple filters at the same time. The filter-text
and
filter-keys
properties have been replaced by a filters
property.
The new filters
property expects an array of objects as the following:
filters = [
{value: '', keys: ['name', 'address.state']},
{value: '', keys: ['eyeColor']},
];
The value
property represents the filter value, normally you would bind it to a text input or a select, but you can
handle it anyway you want. You can also set a default value for it and your data will be filtered on load.
The keys
property is an array if the fields you want to filter by. Aurelia Table will filter your data matching the
value
with the keys
you provide.
Note how you can use nested paths such as address.state
for your key values.
| Name | State | Eye Color | |
|---|---|---|---|
| ${user.name} | ${user.address.state} | ${user.email} | ${user.eyeColor} |

<input type="text" value.bind="filters[0].value" placeholder="Enter filter text" class="form-control"/>

Eye Color
<select id="eyeColor" class="form-control" value.bind="filters[1].value">
<option repeat.for="color of eyeColors" model.bind="color">${open}color}</option>
</select>

Name
State
E-mail
Eye Color

${open}user.name}
${open}user.address.state}
${open}user.email}
${open}user.eyeColor}

import {HttpClient} from "aurelia-fetch-client";
export class Example {
users = [];
eyeColors = [];
filters = [
{value: '', keys: ['name', 'address.state']},
{value: '', keys: ['eyeColor']},
];
bind(){
let client = new HttpClient();
return client.fetch('data.json')
.then(response => response.json())
.then(users => this.users = users);
.then(() => this.populateColors())
}
populateColors(){
this.eyeColors.push('');
for(let next of this.users){
let nextColor = next.eyeColor;
if(this.eyeColors.indexOf(nextColor) === -1){
this.eyeColors.push(nextColor);
}
}
}
}
Note how the text input is binding to the filter value with: value.bind="filters[0].value"
. And the Select is doing the
same thing: value.bind="filters[1].value"
. With this approach you can add many filters very easily, just make sure
you keep track of the filters index.


DANDDSCREENWRITING
pre-production
production
post-production
distribution
welcome to danddscreenwriting
wordswordswordswords
wordswordswordswords
wordswordswordswords


Working to make world a better place.
Hi Welcome to my portfolio, I am Mayukh Pankaj. I am passionate about computer science and love development. I like to solve real world problems, solutions that can create impact, help people.
Birla Institute of Technology Mesra
2020 - 2024
Indian Institute of Information Technology Tiruchirappalli
2019 - 2020
Jawahar Vidya Mandir Shyamali Ranchi
2010 - 2019
a webapp that shows covid detail's of user's geolocation. 1 Million + page visits till now.
VisitIIIT's library management system written in PHP mySQLi integrated with PayTM SDK for late fee payment
Repository


|
Chatbot
|
Public Member Functions | |
| <<<<<<< HEAD | ScriptParser (const String &sourcePath) | Script (const String &sourcePath) | >>>>>>> 056baa0fb044b08367838e6f863d4f9fa4907370
| String | pre_translate (String) |
| String | post_translate (String) |
| Key * | getKey (String word) |
| Public Member Functions inherited from Parser | |
| Parser (String sourcePath) | |
Public Attributes | |
| String | initial |
| String | final |
| Mapper | pre |
| Mapper | post |
| vector< Key * > | keys |
| vector< String > | quit |
| Thesaurus | thes |
| Public Attributes inherited from Parser | |
| String | sourcePath |
Private Member Functions | |
| void | parse () |
| String | extractPattern (String line, String key) |
| Key * | newKey (String scriptLine) |
Friends | |
| ostream & | operator<< (ostream &os, const Script &parser) |
Additional Inherited Members |
|
privatevirtual |


{% if request.user.is_staff %}
You are viewing the site as it will appear on {{ request.session.preview_at }} Reset this
{% else %} {% if object.is_public %}You are currently viewing the live version of this page.
{% if object.draft.is_scheduled_in_future %} View draft version of page which will be automatically published on {{ object.draft.publish_at }} {% else %} View pending draft version of page {% endif %}
{% else %}{% if object.is_scheduled_in_future %} You are currently viewing the draft version of this page, which will be automatically published on {{ object.publish_at }}. {% else %} You are currently viewing the draft version of this page, {% endif %}
{% if object.public %} View live version of page {% else %} There is currently no live version of this page. {% endif %}
{% endif %} {% endif %}


Research Scientist
Adobe Research
One Broadway, Cambridge MA 02142
vshin [at] adobe [dot] com
I am currently a senior research scientist at
Adobe Research.
My research develops novel algorithms, interactions, and interfaces for authoring, editing and consuming audio visual media effectively.
I received my PhD in Computer Science from MIT, where I was advised by Fredo Durand in the Computer Graphics Lab.
Before joining MIT, I completed my B.S. in Computer Science at Princeton University.
Publications
|
Beyond Subtitles Captioning and Visualizing Non-Speech Sounds in User Generated Videos.
ASSETS 2022
|
|
CatchLive: Real-time Summarization of Live Streams with Stream Content and Interaction Data
CHI 2022
|
|
Multi-level Correspondence via Graph Kernels for Editing Vector Graphics Designs
|
|
Beyond Show of Hands: Engaging Viewers via Expressive and Scalable Visual Communication in Live Streaming
[paper]
CHI 2021
|
|
Snapstream: Snapshot-based Interactions in Live Streaming for Visual Art
Proceedings of the 2020 CHI Conference on Human Factors in Computing Systems (CHI 2020)
|
|
Temporal Segmentation of Creative Live Streams
[pdf]
Proceedings of the 2020 CHI Conference on Human Factors in Computing Systems (CHI 2020)
|
|
Generating Audio-Visual Slideshows from Text Articles Using Word Concreteness
Proceedings of the 2020 CHI Conference on Human Factors in Computing Systems (CHI 2020)
|
|
Pose2Pose: Pose Selection and Transfer for 2D Character Animation
|
|
B-Script: Transcript-based B-roll Video Editing with Recommendations
Proceedings of the 2019 CHI Conference on Human Factors in Computing Systems (CHI 2019)
|
|
DynamicSlide: Exploring the Design Space of Reference-based Interaction Techniques for Slide-based Lecture Videos
Proceedings of the 2018 Workshop on Multimedia for Accessible Human Computer Interface
|
|
On Learning Associations of Faces and Voices
[pdf]
In Proceedings of Asian Conference on Computer Vision (ACCV 2018)
|
|
Designing effective interfaces for audiovisual media
[pdf]
Ph.D Thesis, Massachusetts Institute of Technology
|
|
VoiceScript: Dynamic Authoring of Audio with Linked Scripts
Proceedings of the 29th Annual Symposium on User Interface Software and Technology, of UIST '16, pages 509–516, New York, NY, USA, 2016. ACM
|
|
Reconciling Elastic and Equilibrium Methods for Static Analysis
ACM Transactions on Graphics (TOG) Volume 35 Issue 2, May 2016 (Presented at SIGGRAPH 2016)
|
|
VisualTranscripts: Lecture Notes from Blackboard Style Lecture Videos
ACM Trans. Graph., 34(6): 240:1–240:10. October 2015
|
|
Structural Optimization of 3D Masonry Buildings
ACM Transactions on Graphics, Proceedings of SIGGRAPH Asia 2012
|
|
Analyzing and Simulating Fracture Patterns of Theran Wall Paintings
ACM Journal of Computing and Cultural Heritage, 5(3), October 2012
|
|
Learning How to Match Fresco Fragments
ACM Journal of Computing and Cultural Heritage, 4(2), November 2011.
(Original version appeared as an area paper at Eurographics, April 2011)
|


I write my thoughts and experiences here.
Let me explain you what my project is all about!
National Resource for Network Biology (NRNB) is an organisation which aims to advance the new science of Biological Networks through analytic tools, visualizations, databases and computing resources. In an easier words NRNB builds the technology required to assemble and analyze all kinds of protein and drug interaction, gene, cell-cell communications and similar sci-fi things you can think of. 😸
See the image above. That’s structure is built on an webapp called Newt. So what Newt basically does it helps you build, visualize and edit such patway models. All you have to do is drag and drop those boxes, connect them using arrow and name them. It’s as easy as that 😌. Cool isn’t it?
So what’s bothering Newt right now is that it doesn’t have a database of its own. User can still make those beautiful maps like the one you see above but saving those maps online isn’t one of Newt speciality. The only way you could save it is by downloading it in a format that Newt understand.
So the aim of the project is to add database support to Newt which would make it a really happy webapp.
Well there are 2 things we plan to do.
Earlier I mentioned that you would deposit the Pathway to an online database. But the thing is some part of the pathway might be already present in the database so instead of just pushing everything to the database we have to make sure that everything fits like a puzzle in the database and there’s no duplicated node/entity which is quite challenging to do as there are many rules which govern whether two nodes are different or not.
Let’s get started then 🔥🔥
Go Back to HomePage


Credulous is a command-line tool to manage your AWS credentials. In order to get the proper functionality, please add the following text to your $HOME/.bashrc
:
if [ -f /etc/profile.d/credulous.sh ]; then . /etc/profile.d/credulous.sh fi
... and then restart your Terminal sessions.
To keep up with credulous development and status, check out http://credulous.io and https://github.com/realestate-com-au/credulous


“ {{ self.quote }}”
{% include "torchbox/includes/breadcrumb.html" %}
{% if self.quote %}
{% endif %}
{% include "torchbox/includes/streamfield.html" with content=page.body %}


Hi, I'm Lauren.
A little bit about me...
- WordPress developer since 2008
- Director of Technology at Subject Matter
- Teacher at General Assembly
- Cat mom, fitness enthusiast, coffee addict
Did I mention I love cat gifs?
How many of you have experienced...
- "Do it the fastest way - we can refactor later"
- "Don't worry about the documentation"
- "The only one who can change this code is Will"
- "Can we save time by copy and pasting?"
- "We can just QA that after it goes live"
Congratulations!
You may have encountered technical debt
Today we'll cover:
- What is technical debt?
- Capacity and Constraints
- Standardization
- Plenty of cat gifs
Strategic decisions to take shortcuts for short term gain or choosing a short-sighted solution instead of investing in long term benefits.
It's more than bad code! Technical debt is STRATEGIC.
Like financial debt, debt that is not paid down will grow compounding interest over time.
*NOTE* Not all technical debt is bad.
This is often seen in practice as:
- Old versions of WordPress and plugins
- Dated technology or infrastructure
- Overly complicated code
- Insecure code
- Lack of validation
- No documentation
- Lack of or incomplete coding standards
Imagine your team has...
- Timeline bottlenecks
- Bloated codebases
- Projects over budget
- Fragile applications
So, how do we tackle this?
Note: these are my personal experiences and recommendations of those much smarter
Identify the capacity
You need a clear understanding of the capacity, including both work in progress (WIP) and active commitments.
Account for all the work you do:
- Business projects
- Internal projects
- Deployments/change management
- Unplanned work
Technical debt's interest comes in unplanned work
Align priorities
- Have conversations with stakeholders
- Invest in projects with high business priority
Make an inventory
Identify...
- Project
- Resource(s)
- Business priority
- Deadline
- Look for patterns and conflicts
Get organized, plan ahead
- Kanban board
- Gant chart
- Shared calendar
Don't Jeopardize Commitments
Look at the existing WIP before saying yes
Why this matters...
- Less developers scrambling
- Less shortcuts
- Less fragile applications
- Higher quality and due date performance
Make time for priority debt
- You will never eleminate it all
- Justify the cost to pay it
- Prioritize your debt
Identify and control the contstraints
What is a constraint?
A chain management term for something that limits a person, or an organization, in achieving a goal.
Constraints can look like...
- Role limitations
- Infrastructure limitations
- Time limitations
- Process limitations
Constraint example:
FRAGILE INFRASTRUCTURE MANAGED BY ONE PERSON
- Unpredictable crashes
- Bottlenecks other projects
- Limited support coverage
Why this matters...
- Impacts work pace
- Contributes to capacity overage
- Creating technical debt
After identifying...
- Make quick improvements
- Account for limitations
- How can you eliminate it?
Constraint solution example:
FRAGILE INFRASTRUCTURE MANAGED BY ONE PERSON
- Document the process
- Train up team members
- Upgrade infrastructure
What's the impact?
- Improved capacity
- Reduced task lead time
- Increased project speed
Without standards, it's the wild west.
A few things to avoid
Handling special cases
if ($status == "awake"){
$activity = "Writing spaghetti code";
} elseif($healthstatus == "OK"){
$activity = "More spaghetti code";
}else{
print "Refactor this code";
}
A few things to avoid
Use of Important in CSS/SASS/LESS
header {
color: #e74c3c;
}
header.intro {
color: #3498db !important;
font-size: 20px;
}
A few things to avoid
No or useless comments
# Monkeys and bananas
foreach(banana b in bunch) {
monkey.eat(b);
}
Standardize so you dont end up with monkeys and bananas
Standardization means:
- Version control... you better be using it!
- Clear release cycles or continuous integration
- Coding standards and code review
- Commenting and code documentation
- Process documentation of common tasks
- Testing
Why this matters...
- Control your constraints
- Replicate tasks
- Consistancy and quality
Release Cycle Management
- Still bugs after it's "done"
- Use gitFlow - always ready to ship
- Plan releases in advance
Code Standards
- Document methods
- Baseline on industry standard features
- Use WordPress' Theme and Plugin Developer Handbooks
- Plan for security and compliance
Code Documentation
- Document what it does and why
- Keep it updated!
- Include in code review
- Does NOT mean commenting out legacy code
Process Documentation
- Scale work across people
- Document recent requests
- Cut down on onboarding time for new hires.
Testing
- QA testing is critical
- Incorporate automated testing
- Tests look at the functionality, not the implementation
Standardize Mainenance
Building preventative maintenance into your workflow helps ensure availability and security.
To sum it up...
- Identify top debt
- Decrease unplanned work
- Evaluate for continuous improvement


{{ACTIVITY_DESCRIPTION}}
Method: {{REQUEST_METHOD}}
URL: {{REQUEST_URL}}
Click Done to complete configuration.


Top awards for South Kildare Photography Club
Competition: Seven clubs took part
by Leader ReporterSouth Kildare Photography Club (SKPC) are celebrating success at the Midlands Photographic Group (MPG) Challenge Shield photography competition.
Seven photography clubs from across the midlands took part in the competition which was held in the Tullamore Court Hotel on Sunday, November 10.

Scoring was carried out by two independent judges who could assign a maximum of 180 points to each image, totalling a maximum of 2880 points across the two panels. In addition, they could allocate up to 200 points for panel layout and
presentation.
SKPC submitted eight black and white and eight colour images from sixteen different club members for their two panels.
SKPC scored 2473 collective points across the 16 images (154.56 average) and a further 189 points for panel layout, totaling 2662 points out of a possible 3080.
SKPC won the overall title of Midlands Photography Group (MPG) Club of the Year award.
Club member Billy Nicholls was awarded Best Color – image for I'm Freezing, while Vincent Brady was awarded Best B/W – image for his image of Men Walking through the Mist in the SKPC panels.
Billy’s image scored 172 points out of a possible 180, winning him the overall title of Photographer of the Year 2019.


Projects
You know how it is, there is always a bunch of things you want to learn. This may be better described as a bunch things you wish you knew. You may put it in a list. You may even start it. My favorite part is buying books, because even with Amazon Prime, it takes 2 days to get delivered. That’s about when my attention has moved on to something else.  Maybe you don’t feel this way (I hope you don’t), but I usually do. So here is my To Do list (for now).
I’ll describe what I’m planning to work on here and why. This post may be a bit long. I’ll put a table up to track projects on the blog as well. It will live here in the Projects tab.
A little background
A year and a half ago, I started playing around with Ruby. It is Ruby’s philosophy to be fun and it was. It dethroned Perl as my go-to language pretty quickly. This isn’t to say I know what I’m doing, just that I can get some things done with it.
A few months ago, I started playing with Python. This is because Python has been more adopted into the scientific community. I’m not sure why, but it may be because it interacts we with C. One thing I do know is that some folks I like on the Internet like Macdrifter, Dr. Drang, and Brett Terpstra use Python (although Brett is a solid Ruby guy).
Python is supposed to have the advantage that it is easier to read. I think this is generally true compared to Perl. It may be as well versus Ruby but I tend to be poor at commenting my code, so nothing is easy to read. I’m really working on improving the commenting. Part of the commenting problem is that I never wrote code expecting others to read it. This isn’t the only reason to comment because I usually can’t figure out my own code. Recently, I worked with coworker on a project and I put effort into commenting. It definitely made a difference for me.
So what’s the plan?
Programming Web Apps
I’d like to learn Ruby on Rails. All of my Ruby has been used in command line scripts. Rails would make applications accessible via a web browser, provide a graphical interface, but still allow access to underlying hooks into the system, if necessary (admittedly, I may have a naive understanding of how it works).
After getting a basic understanding of Rails, I’d like to try a little Django. Since I’ve been trying Python, if I switch to it from Ruby, it may be easier to use Django than Rails in the long run.
HTML
Saying HTML above is not really right. Yes, HTML is on the list. I’m still using HTML from the 90′s. Is that HTML1? We’re only on 5 now. But I really mean all the other stuff that goes to making a good (good may be too strong a word) website.
CSS: I don’t know what it is but it seems important. No, just kidding. I learned a little about Style Sheets when through the tutorials on Codecademy last spring. At the time, it made sense but without following up with practice, it wasn’t going to stick.
Javascript and JQuery: I don’t know how much I’ll need them but I’m going to put them on the list. Are they even different things? So much to learn, Grasshopper.
Responsive Design: What little I know seems to indicate that this is not mutually exclusive to the previous items. I don’t know if there are different the ways of implementing it, but I’d like the web pages/apps that I put together to be usable on different platforms.
Design
Man, I just don’t get Design. I’ve never paid attention to style, fashion, or trends. If it wasn’t for my wife, I’d still be wearing just black and gray because I couldn’t get anything else match. As I’m getting older, I’m trying not to rush through things as much, to stop and smell the roses a bit.
On the more practical side, I do appreciate the utility of making things easier to understand and use. For example, I’m quite good at writing scripts that take a bunch of arguments to run. Those scripts are only usable while the arguments needed are still in short term memory. Two days later and I have to rewrite the script because I can’t get it to work again (please note the poor commenting mentioned above).
All and all, it’s not about making something that will work. It’s about making something that is useful. Making a helicopter that no one can fly is not more useful than making a can opener that everyone can use.
In Summary (let’s wrap it up already)
All together, these all have to goal of allowing me to build tools that can be controlled by a web interface. I see this as being useful for geeking out at work as well as the potential for uses at home (e.g. one of the first projects I’d like to build is a basic Grocery List).
P.S.
I’d like to learn Objective-C. My goal is not to write the next Angry Birds. My wife will attest to the fact that I’m probably allergic to money. This is also evident from my being in school until my 30′s, making below minimum wage, and following that up with even more training as a Postdoc.
I see learning Objective-C as similar to learning to build web-based applications. It just makes it easier to interact with the underlying code, making it more usable and possibly more portable.


jQuery.atomfeed
A lightweight atom feed parser based on jQuery.
Features
jQuery.atomfeed provides the following:
- Read atom feeds and display easily.
- Support template, that you can customize a more readable format.
Getting Started
Here is a demo.
Options
- url (required)
- Specify the url for the feed.
- max (optional)
- Specify the maximum number of feed items to display. The default value is 10.
- template (optional)
-
- Specify the template. The default value is following:
'
{updated}

{title}
'
Template syntax
- {TagName} will substitute the combined text contents of the element.
- {TagName.AttributeName} will subsitute the attribute value for the element.
Basic usage
The following example shows how to use atomfeed()
.


This tests that we can successfully profile a wasm application and view the accumulated time as well as the call tree.
Steps
- Open DevTools
- Open the Performance Tab
- Click the record button
- Reload the page and wait for application to finish (console output appears)
- Stop the recording
- Check if the performance tab reflects the correct info:
Check "Summary" tab:
- Search for "addMultiply" (CMD/CTRL-F)
- The "Summary" tab shows a non-zero total time for "addMultiply
- Clicking on the function link should redirect to the "stepping-with-state.wasm" file in the Sources tab
Check "Bottom Up" tab:
- Search for "addMultiply" (CMD/CTRL-F)
- Click on the "Bottom Up" Tab
- Expand the tree; it should show: "addMultiply", "js-to-wasm:.*", "(anonymous)", "Run Microtasks
- Clear the profile


|
geopm
|
#include <PlatformIOImp.hpp>
Public Member Functions | |
| PlatformIOImp () | |
| PlatformIOImp (std::list< std::shared_ptr< IOGroup > > iogroup_list, const PlatformTopo &topo) | |
| PlatformIOImp (const PlatformIOImp &other)=delete | |
| PlatformIOImp & | operator= (const PlatformIOImp &)=delete |
| virtual | ~PlatformIOImp ()=default |
| void | register_iogroup (std::shared_ptr< IOGroup > iogroup) override |
| Registers an IOGroup with the PlatformIO so that its signals and controls are available through the PlatformIO interface. More... | |
| std::set< std::string > | signal_names (void) const override |
| Returns the names of all available signals. This includes all signals and aliases provided by IOGroups as well as signals provided by PlatformIO itself. More... | |
| std::set< std::string > | control_names (void) const override |
| Returns the names of all available controls. This includes all controls and aliases provided by IOGroups as well as controls provided by PlatformIO itself. More... | |
| int | signal_domain_type (const std::string &signal_name) const override |
| Query the domain for a named signal. More... | |
| int | control_domain_type (const std::string &control_name) const override |
| Query the domain for a named control. More... | |
| int | push_signal (const std::string &signal_name, int domain_type, int domain_idx) override |
| Push a signal onto the end of the vector that can be sampled. More... | |
| int | push_control (const std::string &control_name, int domain_type, int domain_idx) override |
| Push a control onto the end of the vector that can be adjusted. More... | |
| double | sample (int signal_idx) override |
| Sample a single signal that has been pushed on to the signal stack. Must be called after a call to read_batch(void) method which updates the state of all signals. More... | |
| void | adjust (int control_idx, double setting) override |
| Adjust a single control that has been pushed on to the control stack. This control will not take effect until the next call to write_batch(void). More... | |
| void | read_batch (void) override |
| Read all pushed signals so that the next call to sample() will reflect the updated data. More... | |
| void | write_batch (void) override |
| Write all of the pushed controls so that values previously given to adjust() are written to the platform. More... | |
| double | read_signal (const std::string &signal_name, int domain_type, int domain_idx) override |
| Read from platform and interpret into SI units a signal given its name and domain. Does not modify the values stored by calling read_batch(). More... | |
| void | write_control (const std::string &control_name, int domain_type, int domain_idx, double setting) override |
| Interpret the setting and write setting to the platform. Does not modify the values stored by calling adjust(). More... | |
| void | save_control (void) override |
| Save the state of all controls so that any subsequent changes made through PlatformIO can be undone with a call to the restore_control() method. More... | |
| void | restore_control (void) override |
| Restore all controls to values recorded in previous call to the save_control() method. More... | |
| std::function< double(const std::vector< double > &)> | agg_function (const std::string &signal_name) const override |
| Returns a function appropriate for aggregating multiple values of the given signal into a single value. More... | |
| std::function< std::string(double)> | format_function (const std::string &signal_name) const override |
| Returns a function that can be used to convert a signal of the given name into a printable string. More... | |
| std::string | signal_description (const std::string &signal_name) const override |
| Returns a description of the signal. This string can be used by tools to generate help text for users of PlatformIO. More... | |
| std::string | control_description (const std::string &control_name) const override |
| Returns a description of the control. This string can be used by tools to generate help text for users of PlatformIO. More... | |
| int | signal_behavior (const std::string &signal_name) const override |
| Returns a hint about how a signal will change as a function of time. More... | |
| int | num_signal_pushed (void) const |
| int | num_control_pushed (void) const |
| Public Member Functions inherited from geopm::PlatformIO | |
| PlatformIO ()=default | |
| virtual | ~PlatformIO ()=default |
| geopm::PlatformIOImp::PlatformIOImp | ( | ) |
| geopm::PlatformIOImp::PlatformIOImp | ( | std::list< std::shared_ptr< IOGroup > > | iogroup_list, |
| const PlatformTopo & | topo | ||
| ) |
|
delete |
|
virtualdefault |
|
overridevirtual |
Adjust a single control that has been pushed on to the control stack. This control will not take effect until the next call to write_batch(void).
| [in] | control_idx | Index of control to be adjusted returned by a previous call to the push_control() method. |
| [in] | setting | Value of control parameter in SI units. |
Implements geopm::PlatformIO.
|
overridevirtual |
Returns a function appropriate for aggregating multiple values of the given signal into a single value.
| [in] | signal_name | Name of the signal. |
Implements geopm::PlatformIO.
|
overridevirtual |
Returns a description of the control. This string can be used by tools to generate help text for users of PlatformIO.
Implements geopm::PlatformIO.
|
overridevirtual |
Query the domain for a named control.
| [in] | control_name | The name of the control. |
Implements geopm::PlatformIO.
|
overridevirtual |
Returns the names of all available controls. This includes all controls and aliases provided by IOGroups as well as controls provided by PlatformIO itself.
Implements geopm::PlatformIO.
|
overridevirtual |
Returns a function that can be used to convert a signal of the given name into a printable string.
| [in] | signal_name | Name of the signal. |
Implements geopm::PlatformIO.
| int geopm::PlatformIOImp::num_control_pushed | ( | void | ) | const |
| int geopm::PlatformIOImp::num_signal_pushed | ( | void | ) | const |
|
delete |
|
overridevirtual |
Push a control onto the end of the vector that can be adjusted.
| [in] | control_name | Name of the control requested. |
| [in] | domain_type | One of the values from the m_domain_e enum described in PlatformTopo.hpp. |
| [in] | domain_idx | The index of the domain within the set of domains of the same type on the platform. |
Implements geopm::PlatformIO.
|
overridevirtual |
Push a signal onto the end of the vector that can be sampled.
| [in] | signal_name | Name of the signal requested. |
| [in] | domain_type | One of the values from the m_domain_e enum described in PlatformTopo.hpp. |
| [in] | domain_idx | The index of the domain within the set of domains of the same type on the platform. |
Implements geopm::PlatformIO.
|
overridevirtual |
Read all pushed signals so that the next call to sample() will reflect the updated data.
Implements geopm::PlatformIO.
|
overridevirtual |
Read from platform and interpret into SI units a signal given its name and domain. Does not modify the values stored by calling read_batch().
| [in] | signal_name | Name of the signal requested. |
| [in] | domain_type | One of the values from the PlatformTopo::m_domain_e enum described in PlatformTopo.hpp. |
| [in] | domain_idx | The index of the domain within the set of domains of the same type on the platform. |
Implements geopm::PlatformIO.
|
overridevirtual |
Registers an IOGroup with the PlatformIO so that its signals and controls are available through the PlatformIO interface.
| [in] | iogroup | Shared pointer to the IOGroup object. |
Implements geopm::PlatformIO.
|
overridevirtual |
Restore all controls to values recorded in previous call to the save_control() method.
Implements geopm::PlatformIO.
|
overridevirtual |
Sample a single signal that has been pushed on to the signal stack. Must be called after a call to read_batch(void) method which updates the state of all signals.
| [in] | signal_idx | index returned by a previous call to the push_signal() method. |
Implements geopm::PlatformIO.
|
overridevirtual |
Save the state of all controls so that any subsequent changes made through PlatformIO can be undone with a call to the restore_control() method.
Implements geopm::PlatformIO.
|
overridevirtual |
Returns a hint about how a signal will change as a function of time.
This can be used when generating reports to decide how to summarize a signal's value for the entire application run.
| [in] | signal_name | Name of the signal. |
Implements geopm::PlatformIO.
|
overridevirtual |
Returns a description of the signal. This string can be used by tools to generate help text for users of PlatformIO.
Implements geopm::PlatformIO.
|
overridevirtual |
Query the domain for a named signal.
| [in] | signal_name | The name of the signal. |
Implements geopm::PlatformIO.
|
overridevirtual |
Returns the names of all available signals. This includes all signals and aliases provided by IOGroups as well as signals provided by PlatformIO itself.
Implements geopm::PlatformIO.
|
overridevirtual |
Write all of the pushed controls so that values previously given to adjust() are written to the platform.
Implements geopm::PlatformIO.
|
overridevirtual |
Interpret the setting and write setting to the platform. Does not modify the values stored by calling adjust().
| [in] | control_name | Name of the control requested. |
| [in] | domain_type | One of the values from the PlatformTopo::m_domain_e enum described in PlatformTopo.hpp. |
| [in] | domain_idx | The index of the domain within the set of domains of the same type on the platform. |
| [in] | setting | Value in SI units of the setting for the control. |
Implements geopm::PlatformIO.


AWS Glue Classifier JsonClassifier
The
JsonClassifier
property type specifies an AWS Glue classifier for JSON content.
JsonClassifier
is a property of the AWS::Glue::Classifier resource
type.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
Properties
JsonPath
-
A JsonPath string defining the JSON data for the classifier to classify. AWS Glue supports a subset of JsonPath, as described in Writing JsonPath Custom Classifiers.
Required: Yes
Type: String
Update requires: No Interruption
Name
-
The name of the classifier.
Required: Yes
Type: String
Update requires: Replacement
See Also
-
JsonClassifier Structure in the AWS Glue Developer Guide


Box
This works like the physical box. The code is at the bottom. You scroll through your friends list then press "Ping" on the one you want to ping.
This works like the physical box. The code is at the bottom. You scroll through your friends list then press "Ping" on the one you want to ping.


We got services!
- envisioneer impactful networks
- innovate world-class channels
- disintermediate impactful methodologies
- productize turn-key platforms
- morph rich convergence
- generate magnetic paradigms
- envisioneer global e-tailers
- enable leading-edge e-tailers
- reinvent leading-edge channels
- empower front-end deliverables
- integrate web-enabled e-markets
- architect clicks-and-mortar convergence
- target real-time functionalities
- expedite B2B web services


This is a test website. Nothing is charged.
Enroll Credential - would happen after a successful authentication and/or purchase.
Please enter below the SMS that was sent to your phone number: ***-***-5555.
Verify purchase:


Using mobile phones accelerometer for this observation is one of the cheapest and most convenient method. Activity recognition is specially gaining attention in care facilities for remote monitoring of daily activities for elders living alone and automatic record creation for nurses in hospitals with a goal of providing better care to patients. One challenge for these applications is bridging the gap between models created within the lab and models for real life. In this challenge, participants will create methods for recognizing 12 activities conducted by nurses in both lab and in real-life settings. In real world, there is high chance of getting missing labels during experiments since users are busy at work. The main challenge is leveraging laboratory data to improve models in real-life. Training data consists of data collected in both settings but test data consists of data only from the real field (same users as training data). Download the data from IEEE Dataport here The evaluation of submissions will be done solely based on the accuracy.


'The Moral Landscape': How Science Can Determine Human Values
Sam Harris' first book, The End of Faith, ignited a worldwide debate about the validity of religion. In the aftermath, Harris discovered that most people - from religious fundamentalists to non-believing scientists - agree on one point: science has nothing to say on the subject of human values. Indeed, our failure to address questions of meaning and morality through science has now become the most common justification for religious faith. It is also the primary reason why so many secularists and religious moderates feel obligated to "respect" the hardened superstitions of their more devout neighbors. In this explosive new book, Sam Harris tears down the wall between scientific facts and human values, arguing that most people are simply mistaken about the relationship between morality and the rest of human knowledge. Harris urges us to think about morality in terms of human and animal well-being, viewing the experiences of conscious creatures as peaks and valleys on a "moral landscape." Because there are definite facts to be known about where we fall on this landscape, Harris foresees a time when science will no longer limit itself to merely describing what people do in the name of "morality"; in principle, science should be able to tell us what we ought to do to live the best lives possible. Bringing a fresh perspective to age-old questions of right and wrong and good and evil, Harris demonstrates that we already know enough about the human brain and its relationship to events in the world to say that there are right and wrong answers to the most pressing questions of human life. Because such answers exist, moral relativism is simply false - and comes at increasing cost to humanity. And the intrusions of religion into the sphere of human values can be finally repelled: for just as there is no such thing as Christian physics or Muslim algebra, there can be no Christian or Muslim morality. Using his expertise in philosophy and neuroscience, along with his experience on the front lines of our "culture wars," Harris delivers a game-changing book about the future of science and about the real basis of human cooperation.
goodreads.com


Did I have to create this series of workshop, including this website and hundreds of words of content on it?
Well, yes, cause we really need people like you!
But also no, because much of what I'm doing here is done with pleasure on my part. I like teaching and writing, sometimes I like to be funny.
If you are like me and have some free time, then help us!
We need people like you.
...also, graphic designers, we need graphic designers.


Nyakuri:
Everyone seems to come down with a stomachache when they see that Lizardman. Either something is going around or I am surrounded by cowards!


The tabs component is to provide a tabs functionality.
selectedIndex
(?number=0
) - Index of the active/selected tab.class
(?string=''
) - To set custom class on md2-tabs
element.label
(?string=''
) - Optional attribute to specify a simple string as the tab label.active
(?boolean='false'
) - To set as an active a tab.disabled
(?boolean='false'
) - To set as an disabled a tab.class
(?string=''
) - To set custom class on md2-tab
element.change
- it fires after a tab has been changes; returns object of selected tab.


Combines either p-values or modified effect sizes from different studies to find differentially expressed genes
| Version: | 3.1.2 |
| Depends: | R (≥ 3.1.2) |
| Imports: | limma, SMVar |
| Suggests: | GEOquery, org.Hs.eg.db, VennDiagram, annaffy, hgu133plus2.db, hgu133a.db, hgu95av2.db |
| Published: | 2015-01-28 |
| Author: | Guillemette Marot |
| Maintainer: | Guillemette Marot <guillemette.marot at inria.fr> |
| License: | GPL-2 | GPL-3 [expanded from: GPL] |
| NeedsCompilation: | no |
| Citation: | metaMA citation info |
| Materials: | NEWS |
| In views: | MetaAnalysis |
| CRAN checks: | metaMA results |
| Reference manual: | metaMA.pdf |
| Vignettes: |
metaMA Vignette |
| Package source: | metaMA_3.1.2.tar.gz |
| Windows binaries: | r-devel: metaMA_3.1.2.zip, r-release: metaMA_3.1.2.zip, r-oldrel: metaMA_3.1.2.zip |
| OS X binaries: | r-release: metaMA_3.1.2.tgz, r-oldrel: metaMA_3.1.2.tgz |
| Old sources: | metaMA archive |
Please use the canonical form https://CRAN.R-project.org/package=metaMA to link to this page.