");
+ }
+});
+$.ajax({
+ url: "me.json",
+ success: function(data) {
+ // Before using a JSON object, you need to parse it.
+ // Here we parse it and assign it to a variable:
+ var me = JSON.parse(data);
+ // Here we access the properties of the JSON object:
+ $("#content").html(me.firstName + " " + me.lastName);
+ },
+ error: function(data) {
+ $('#content').html("
';
+// Pass in the array of persons:
+$.template.repeater($('#objectArrayList'), repeaterTmplate2, luminaries.persons);
+
+// Pub/Sub:
+var arraySubscriber = function(topic: string, data: any) {
+ $('.list').append('
' + topic + '
' + data + '
');
+ var newsSubscription = $.subscribe('news/update', arraySubscriber);
+};
+$.publish('news/update', 'The New York Stock Exchange rose an unprecedented 1000 points in just three minutes. Analysts and investors are confused and uncertain how to respond.');
+$.unsubscribe('news/update');
+// Due to being unsubscribed above, this does nothing:
+$.publish('news/update', 'We have nothing further to comment at this time.');
+
diff --git a/chocolatechipjs/chocolatechipjs.d.ts b/chocolatechipjs/chocolatechipjs.d.ts
new file mode 100644
index 000000000..269cb6790
--- /dev/null
+++ b/chocolatechipjs/chocolatechipjs.d.ts
@@ -0,0 +1,1387 @@
+// Type definitions for chocolatechip v3.8.11
+// Project: https://github.com/chocolatechipui/ChocolateChipJS
+// Definitions by: Robert Biggs
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+/**
+ * Defines the base object namespace for ChocolateChipJS.
+ */
+declare var $chocolatechipjs: ChocolateChipStatic;
+declare var $: ChocolateChipStatic;
+
+/**
+ * Static members of ChocolateChip (those on $ and ChocolateChipJS themselves)
+ */
+interface ChocolateChipStatic {
+
+ /**
+ * Contains the version of ChocolateChipJS in use.
+ */
+ version: string;
+
+ /**
+ * Contains the name of the library (ChocolateChip).
+ */
+ libraryName: string;
+
+ /*
+ * This method takes an array-like object and returns its members as an array.
+ *
+ * @param arrayLikeObject Either the arguents object or an node collection.
+ */
+ slice(arrayLikeObject: any): Array;
+
+ /**
+ * Merge the contents of one object into the first object. If only one argument is provided, it is merged into ChocolateChipStatic.
+ *
+ * @param target An object that will receive the new properties if additional objects are passed in or that will extend the ChocolateChipStatic namespace if there is a single argument.
+ * @param object An object containing additional properties to merge in.
+ */
+ extend(target: any, object?: any): any;
+
+ /**
+ * Create a ChocolateChip collection object by creating elements from an HTML string.
+ *
+ * @param selector
+ * @return any
+ */
+ make(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Create a ChocolateChip collection object by creating elements from an HTML string. This is an alias for $.make.
+ *
+ * @param selector
+ * @return any
+ */
+ html(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Replace one element with another.
+ *
+ * @param new HTMLElement
+ * @param old HTMLElement
+ * @return HTMLElement[]
+ */
+ replace(newElement: ChocolateChipElementArray, oldElement: ChocolateChipElementArray): void;
+
+ /**
+ * Load a JavaScript file from a url, then execute it.
+ *
+ * @param url A string containing the URL where the script resides.
+ * @param callback A callback function that is executed after the script loads.
+ * @return void
+ */
+ require(url: string, callback: Function): Function;
+
+ /**
+ * Process JavaScript returned by Ajax request. An optional name can be used to create a custom variable name by which the data is exposed, otherwise it is exposed with the variable "data".
+ *
+ * @param url A string containing the URL where the script resides.
+ * @param callback A callback function that is executed after the script loads.
+ * @return Function
+ */
+ processJSON(json: string, name?: string): any;
+
+ /**
+ * This method will defer the execution of a function until the call stack is clear.
+ *
+ * @param callback A function to execute.
+ * @param duration The number of milliseconds to delay execution.
+ * @return any
+ */
+ delay(callback: Function, duration?: number): any;
+
+ /**
+ * The method will defer the execution of its callback until the call stack is clear.
+ *
+ * @param callback A callback to execute after a delay.
+ * @return Function.
+ */
+ defer(callback: Function): Function;
+
+ /**
+ * An empty function.
+ *
+ * @return any
+ */
+ noop(): void;
+
+ /**
+ * This method will concatenate strings or values as a cleaner alternative to using the '+' operator.
+ *
+ * @param string or number A comma separated series of strings to concatenate.
+ * @return string
+ */
+ concat(...string: string[]): string;
+
+ /**
+ * This method takes a space-delimited string of words and returns it as an array where the individual words are indices.
+ *
+ * @param string Any string with values separated by spaces.
+ * @return string[]
+ */
+ w(string: string): string[];
+
+ /**
+ * Determine whether the argument is a string.
+ *
+ * @param obj Object to test whether or not it is a string.
+ * @return boolean
+ */
+ isString(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is an array.
+ *
+ * @param obj Object to test whether or not it is an array.
+ * @return boolean
+ */
+ isArray(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is a function.
+ *
+ * @param obj Object to test whether or not it is an function.
+ * @return boolean
+ */
+ isFunction(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is an object.
+ *
+ * @param obj Object to test whether or not it is an object.
+ * @return boolean
+ */
+ isObject(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is an empty object.
+ *
+ * @param obj Object to test whether or not it is an empty object.
+ * @return boolean
+ */
+ isEmptyObject(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is an empty object.
+ *
+ * @param obj Object to test whether or not it is an empty object.
+ * @return boolean
+ */
+ isEmptyObject(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is a number.
+ *
+ * @param obj Object to test whether or not it is a number.
+ * @return boolean
+ */
+ isNumber(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is an integer.
+ *
+ * @param obj Object to test whether or not it is an integer.
+ * @return boolean
+ */
+ isInteger(obj: any): boolean;
+
+ /**
+ * Determine whether the argument is a float.
+ *
+ * @param obj Object to test whether or not it is a float.
+ * @return boolean
+ */
+ isFloat(obj: any): boolean;
+
+ /**
+ * Creates a Uuid and returns it as a string with the prefix: "chch_".
+ */
+ makeUuid(): string;
+
+ /**
+ * A generic iterator function, which can be used to seamlessly iterate over arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1.
+ *
+ * @param collection The object or array to iterate over.
+ * @param callback The function that will be executed on every object.
+ * @return any
+ */
+ each(
+ collection: any,
+ callback: (valueOfElement: any, indexInArray: number) => any
+ ): any;
+
+
+ /**
+ * This method converts a string of hyphenated tokens into a camel cased string.
+ *
+ * @param string A string of hyphenated tokens.
+ * @return string
+ */
+ camelize(string: string): string;
+
+ /**
+ * This method converts a camel case string into lowercase with hyphens.
+ *
+ * @param string A camel case string.
+ * @return string
+ */
+ deCamelize(string: string): string;
+
+ /**
+ * This method capitalizes the first letter of a string.
+ *
+ * @param string A string.
+ * @param boolean A boolean value.
+ * @return string
+ */
+ capitalize(string: string, boolean?: boolean): string;
+
+ /**
+ * Object used to store string templates and parsed templates.
+ *
+ * @param string A string defining the template.
+ * @param string A label used to access an object's properties in the template. If none is provided it defaults to "data": [[= data.name]].
+ * @return void
+ */
+ templates: Object;
+
+ /**
+ * This method returns a parsed template.
+ *
+ */
+ template: ChocolateChipTemplate;
+
+
+ /**
+ * This is the base for the plugin "extend" interface, which allows you to add methods that can iterate over element collections.
+ */
+ fn: ChocolateChipPlugin;
+
+ /**
+ * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.
+ *
+ * param newContent The content to insert. May be an HTML string, DOM element, or an array of DOM elements.
+ * @return void
+ */
+ replace(newELement: HTMLElement, oldElement: HTMLElement): void;
+
+ /**
+ * Perform an asynchronous HTTP (Ajax) request.
+ */
+ ajax(settings: ChocolateChipAjaxSettings): Promise;
+
+ /**
+ * Load data from the server using a HTTP GET request.
+ *
+ * @param url A string containing the URL to which the request is sent.
+ * @param success A callback function that is executed if the request succeeds.
+ * @param dataType The type of data expected from the server. Default: Intelligent Guess (json, or html).
+ * @return Promise
+ */
+ get(url: string, data?: any, success?: (data: any) => any, dataType?: string): Promise;
+
+ /**
+ * Load data from the server using a HTTP POST request.
+ *
+ * @param url A string containing the URL to which the request is sent.
+ * @param data A plain object or string that is sent to the server with the request.
+ * @param success A callback function that is executed if the request succeeds.
+ * @param dataType The type of data expected from the server.
+ * @return Promise
+ */
+ post(url: string, data?: any, success?: () => any, dataType?: string): Promise;
+
+ /**
+ * Load JSON-encoded data from the server using a GET HTTP request.
+ *
+ * @param url A string containing the URL to which the request is sent.
+ * @param data A plain object or string that is sent to the server with the request.
+ * @param success A callback function that is executed if the request succeeds.
+ * @return Promise
+ */
+ //each(func: (ctx: any, idx: number) => any): void;
+ getJSON(url: string, data?: any, success?: (data: any) => any): Promise;
+
+ /**
+ * Load JSON from a remote server using the JSONP technique.
+ *
+ * @param url A string
+ * @return Promise
+ */
+ JSONP(options: ChocolateChipJSONP): Promise;
+ //JSONP({url: string, success?: (data: any), callbackType?: string, timeout?: number}): Promise;
+
+
+
+ /**
+ * Specify a function to execute when the DOM is fully loaded.
+ *
+ * @param handler A function to execute after the DOM is ready.
+ * @return any
+ */
+ ready(handler: () => any): void;
+
+ /**
+ * Accepts a string containing a CSS selector which is then used to match a set of elements.
+ *
+ * @param selector A string containing a selector expression
+ * @param context A DOM HTMLElement to use as context
+ * @return HTMLElement[]
+ */
+ (selector: string, context?: HTMLElement|ChocolateChipElementArray): ChocolateChipElementArray;
+
+ /**
+ * Binds a function to be executed when the DOM has finished loading.
+ *
+ * @param callback A function to execute after the DOM is ready.
+ * @return void
+ */
+ (callback: () => any): void;
+
+
+ /**
+ * Accepts a string containing a CSS selector which is then used to match a set of elements.
+ *
+ * @param element A DOM element to wrap in an array.
+ * @return HTMLElement[]
+ */
+ (element: HTMLElement): ChocolateChipElementArray;
+
+ /**
+ * Accepts a string containing a CSS selector which is then used to match a set of elements.
+ *
+ * @param elementArray An array of DOM elements to convert into a ChocolateChip Collection.
+ * @return HTMLElement[]
+ */
+ (elementArray: ChocolateChipElementArray): ChocolateChipElementArray;
+
+ /**
+ * If no argument is provided, return the document as a ChocolateChipElementArray.
+ * @return Document[]
+ */
+ (): Document[];
+
+ /**
+ * Subscribe to a publication. You provide the topic you want to subscribe to, as well as a callback to execute when a publication occurs.
+ * Any data passed by the publisher is exposed to the callback as its second parameter. The callback's first parameter is the published topic.
+ *
+ * @param topic string A topic to subscribe to. This can be a single term, or any type of namespaced term with delimiters.
+ * @data any You can receive any type: string, number, array, object, etc.
+ * @return any
+ */
+ subscribe(topic: string, callback: (topic: string, data: any) => any):any;
+
+ /**
+ * Unsubscribe from a topic. Pass this the topic you wish to unsubscribe from. The subscription will be terminated immediately.
+ *
+ * @param topic string The name of the topic to unsubscribe from.
+ * @return void
+ */
+ unsubscribe(topic: string): void;
+
+ /**
+ * Publish a topic with data for the topic's subscribers to receive.
+ *
+ * @param topic string The topic you wish to publish.
+ * @param data The data to send with the publication. This can be of any type: string, number, array, object, etc.
+ * @return void
+ */
+ publish(topic: string, data: any): void;
+
+ /**
+ * Whether device is iPhone.
+ */
+ isiPhone: boolean;
+
+ /**
+ * Whether device is iPad.
+ */
+ isiPad: boolean;
+
+ /**
+ * Whether device is iPod.
+ */
+ isiPod: boolean;
+
+ /**
+ * Whether OS is iOS.
+ */
+ isiOS: boolean;
+
+ /**
+ * Whether OS is Android
+ */
+ isAndroid: boolean;
+
+ /**
+ * Whether OS is WebOS.
+ */
+ isWebOS: boolean;
+
+ /**
+ * Whether OS is Blackberry.
+ */
+ isBlackberry: boolean;
+
+ /**
+ * Whether OS supports touch events.
+ */
+ isTouchEnabled: boolean;
+
+ /**
+ * Whether there is a network connection.
+ */
+ isOnline: boolean;
+
+ /**
+ * Whether app is running in stanalone mode.
+ */
+ isStandalone: boolean;
+
+ /**
+ * Whether OS is iOS 6.
+ */
+ isiOS6: boolean;
+
+ /**
+ * Whether OS i iOS 7.
+ */
+ isiOS7: boolean;
+
+ /**
+ * Whether OS is Windows.
+ */
+ isWin: boolean;
+
+ /**
+ * Whether device is Windows Phone.
+ */
+ isWinPhone: boolean;
+
+ /**
+ * Whether browser is IE10.
+ */
+ isIE10: boolean;
+
+ /**
+ * Whether browser is IE11.
+ */
+ isIE11: boolean;
+
+ /**
+ * Whether browser is Webkit based.
+ */
+ isWebkit: boolean;
+
+ /**
+ * Whether browser is running on mobile device.
+ */
+ isMobile: boolean;
+
+ /**
+ * Whether browser is running on desktop.
+ */
+ isDesktop: boolean;
+
+ /**
+ * Whether browser is Safari.
+ */
+ isSafari: boolean;
+
+ /**
+ * Whether browser is Chrome.
+ */
+ isChrome: boolean;
+
+ /**
+ * Is native Android browser (not mobile Chrome).
+ */
+ isNativeAndroid: boolean;
+
+ /**
+ * Grabs values from a form and converts them into a JSON object.
+ *
+ * @param rootNode: string|HTMLElement A form whose values you want to convert to JSON.
+ * @param delimiter string A delimiter to namespace your form values. The default is "."
+ * You use the form input's name to set up the namespace structure for your JSON, e.g. name="newUser.name.first".
+ */
+ form2JSON(rootNode: string | HTMLElement, delimiter: string): Object;
+}
+
+interface ChocolateChipPlugin {
+ /**
+ * This method extends ChocolateChipElementArray, enabling iteration over collection items.
+ *
+ * @param object Object literal of properties and values. Value can be strings, number, array, objects or functions.
+ * @return HTMLElement[]
+ */
+ extend: (object: any) => ChocolateChipElementArray;
+}
+
+interface ChocolateChipTemplate {
+ /**
+ * This method parses a string and an optoinal variable name and returns a parsed template in the form of a function. You can then pass this function data to get rendered nodes.
+ *
+ * @param template A string of markup to use as a template.
+ * @param variable An option name to use in the template. If it were "myData": [[= myData.name]]. Otherwise it defaults to "data": [[= data.name]].
+ * @return A function.
+ */
+ (template: string, variable?: string): Function;
+
+ /**
+ * A method to repeated output a template.
+ *
+ * @param element The target container into which the content will be inserted.
+ * @param template A string of markup.
+ * @param data The iterable data the template will consume.
+ * @return void.
+ */
+ repeater: (element: ChocolateChipElementArray, template: string, data: any) => void;
+}
+
+/**
+ * Represents the completion of an asynchronous operation
+ */
+interface Promise {
+ /**
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
+ *
+ * @param onfulfilled The callback to execute when the Promise is resolved.
+ * @param onrejected The callback to execute when the Promise is rejected.
+ * @return Promise A Promise for the completion of which ever callback is executed.
+ * @return Promise A new Promise
+ */
+ then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise;
+
+ /**
+ * Attaches a callback for only the rejection of the Promise.
+ *
+ * @param onrejected The callback to execute when the Promise is rejected.
+ * @return Promise A Promise for the completion of the callback.
+ * @return Promise A new Promise
+ */
+ catch(onrejected?: (reason: any) => T | Promise): Promise;
+}
+
+interface PromiseConstructor {
+ /**
+ * A reference to the prototype.
+ */
+ prototype: Promise;
+
+ /**
+ * Creates a new Promise.
+ *
+ * @param init A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.
+ * @return Promise A new Proimise
+ */
+ new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise;
+
+ (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise;
+
+ /**
+ * Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
+ *
+ * @param values An array of Promises.
+ * @return Promise A new Promise.
+ */
+ all(values: (T | Promise)[]): Promise;
+
+ /**
+ * Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
+ *
+ * @param values An array of values.
+ * @returns A new Promise.
+ */
+ all(values: Promise[]): Promise;
+
+ /**
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
+ *
+ * @param values An array of Promises.
+ * @return Promise A new Promise.
+ */
+ race(values: (T | Promise)[]): Promise;
+
+ /**
+ * Creates a new rejected promise for the provided reason.
+ *
+ * @param reason The reason the promise was rejected.
+ * @return Promise A new rejected Promise.
+ */
+ reject(reason: any): Promise;
+
+ /**
+ * Creates a new rejected promise for the provided reason.
+ *
+ * @param reason The reason the promise was rejected.
+ * @return void A Promise is rejected.
+ */
+ reject(reason: any): Promise;
+
+ /**
+ * Creates a new resolved promise for the provided value.
+ *
+ * @param value A promise.
+ * @return Promise A promise whose internal state matches the provided promise.
+ */
+ resolve(value: T | Promise): Promise;
+
+ /**
+ * Creates a new resolved promise.
+ *
+ * @return Promise A resolved promise.
+ */
+ resolve(): Promise;
+}
+
+declare var Promise: PromiseConstructor;
+
+
+/**
+ * Interface for the Ajax setting that will configure the Ajax request.
+ */
+interface ChocolateChipAjaxSettings {
+ /**
+ * A string containing the URL to which the request is sent.
+ */
+ url?: string;
+
+ /**
+ * A username to be used with XMLHttpRequest in response to an HTTP access authentication request.
+ */
+ user?: string;
+
+ /**
+ * A password to be used with XMLHttpRequest in response to an HTTP access authentication request.
+ */
+ password?: string;
+
+ /**
+ * The type of data that you're expecting back from the server. If none is specified, ChocolateChipJS will
+ * infer it based on the MIME type of the response.
+ */
+ dataType?: string;
+
+ /**
+ * The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods,
+ * such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
+ */
+ type?: string;
+
+ /**
+ * A pre-request callback function that can be used to modify the XMLHTTPRequest object before it is sent.
+ * Use this to set custom headers, etc. This is an Ajax Event. Returning false in the beforeSend function will cancel the request.
+ * @return void
+ */
+ beforeSend?: (xhr: XMLHttpRequest, settings: ChocolateChipAjaxSettings) => void;
+
+ /**
+ * A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server,
+ * formatted according to the dataType parameter; a string describing the status; and the XMLHttpRequest object. This is an Ajax Event.
+ * @return void
+ */
+ success?: (data: any) => void;
+
+ /**
+ * A function to be called if the request fails. The function receives three arguments: The XMLHttpRequest object, a string describing
+ * the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null)
+ * are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status,
+ * such as "Not Found" or "Internal Server Error." This is an Ajax Event.
+ */
+ error?: (error: Error) => void;
+
+ /**
+ * This object will be made the context of all Ajax-related callbacks. By default, the context is null.
+ */
+ context?: any;
+
+ /**
+ * By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false.
+ * Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the
+ * browser, disabling any actions while the request is active.
+ */
+ async?: boolean;
+
+ /**
+ * Set a timeout (in milliseconds) for the request. The timeout period starts at the point the $.ajax call is made; if several other requests are in progress
+ * and the browser has no connections available, it is possible for a request to time out before it can be sent.
+ */
+ timeout?: number;
+
+ /**
+ * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added,
+ * but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function.
+ */
+ headers?: Object;
+
+ /**
+ * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. Object must be Key/Value pairs.
+ */
+ data?: any;
+}
+
+interface ChocolateChipXHR {
+ ajax: (settings: ChocolateChipAjaxSettings) => PromiseConstructor;
+}
+
+interface ChocolateChipJSONP {
+ url: string;
+ success?: (data: any) => Promise;
+ callbackType?: string;
+ timeout?: number;
+}
+
+interface ChocolateChipElementArray extends Array {
+ /**
+ * Iterate over an Array object, executing a function for each matched element.
+ *
+ * @param Function
+ * @return void
+ */
+ each(func: (ctx: any, idx: number) => any): void;
+
+ /**
+ * Sorts an array and removes duplicates before returning it.
+ *
+ * @return Array
+ */
+ unique(): T[];
+
+ /**
+ * This method returns the element at the position in the array indicated by the argument. This is a zero-based number.
+ * When dealing with document nodes, this allows you to cherry pick a node from its collection based on its
+ * position amongst its siblings.
+ *
+ * @param number Index value indicating the node you wish to access from a collection. This is zero-based.
+ * @return HTMLElement
+ */
+ eq(index: number): ChocolateChipElementArray;
+
+ /**
+ * Search for a given element from among the matched elements on a collection.
+ * This method returns the index value as an integer.
+ *
+ * @return number
+ */
+ index(): number;
+
+ /**
+ * Search for a given element from among the matched elements on a collection.
+ * This method returns the index value as an integer.
+ *
+ * @param selector A selector representing an element to look for in a collection of elements.
+ * @return number
+ */
+ index(selector: string | HTMLElement[]): number;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it matches the given arguments.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @return HTMLElement[]
+ */
+ is(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it matches the given arguments.
+ *
+ * @param elements One or more elements to match the current set of elements against.
+ * @ return HTMLElement[]
+ */
+ is(element: any): ChocolateChipElementArray;
+
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it does not match the given arguments.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @ return HTMLElement[]
+ */
+ isnt(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it does not match the given arguments.
+ *
+ * @param elements One or more elements to match the current set of elements against.
+ * @ return HTMLElement[]
+ */
+ isnt(element: any): ChocolateChipElementArray;
+
+ /**
+ * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @ return HTMLElement[]
+ */
+ has(selector: string): ChocolateChipElementArray;
+ /**
+ * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+ *
+ * @param contained A DOM element to match elements against.
+ * @ return HTMLElement[]
+ */
+ has(contained: HTMLElement): ChocolateChipElementArray;
+
+ /**
+ * Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @ return HTMLElement[]
+ */
+ hasnt(selector: string): ChocolateChipElementArray;
+ /**
+ * Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
+ *
+ * @param contained A DOM element to match elements against.
+ * @ return HTMLElement[]
+ */
+ hasnt(contained: HTMLElement): ChocolateChipElementArray;
+
+ /**
+ * Get the descendants of each element in the current set of matched elements, filtered by a selector or element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @ return HTMLElement[]
+ */
+ find(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Get the descendants of each element in the current set of matched elements, filtered by a selector or element.
+ *
+ * @param element An element to match elements against.
+ * @ return HTMLElement[]
+ */
+ find(element: HTMLElement): ChocolateChipElementArray;
+
+ /**
+ * Get the immediately preceding sibling of each element in the set of matched elements.
+ *
+ * @ return HTMLElement[]
+ */
+ prev(): ChocolateChipElementArray;
+
+ /**
+ * Get the immediately following sibling of each element in the set of matched elements.
+ *
+ * @ return HTMLElement[]
+ */
+ next(): ChocolateChipElementArray;
+
+ /**
+ * Reduce the set of matched elements to the first in the set.
+ */
+ first(): ChocolateChipElementArray;
+
+ /**
+ * Reduce the set of matched elements to the last in the set.
+ *
+ * @return HTMLElement[]
+ */
+ last(): ChocolateChipElementArray;
+
+ /**
+ * Get the children of each element in the set of matched elements, optionally filtered by a selector.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @return HTMLElement[]
+ */
+ children(selector?: string): ChocolateChipElementArray;
+
+ /**
+ * Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
+ * If multiple elements have the same parent, only one instance of the parent is returned.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @return HTMLElement[]
+ */
+ parent(selector?: string): ChocolateChipElementArray;
+
+ /**
+ * For each element in the set, get the first element that matches the selector by testing the element
+ * itself and traversing up through its ancestors in the DOM tree, or, if a number is provided,
+ * retrieving that ancestor based on its distance from the element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @return HTMLElement[]
+ */
+ ancestor(selector: string | number): ChocolateChipElementArray;
+
+ /**
+ * For each element in the set, get the first element that matches the selector by testing the element
+ * itself and traversing up through its ancestors in the DOM tree.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @return HTMLElement[]
+ */
+ closest(selector: string | number): ChocolateChipElementArray;
+
+
+ /**
+ * Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ * @return HTMLElement[]
+ */
+ siblings(selector?: string): ChocolateChipElementArray;
+
+ /**
+ * Get the HTML contents of the first element in the set of matched elements.
+ *
+ * @return HTMLElement[]
+ */
+ html(): ChocolateChipElementArray;
+
+ /**
+ * Set the HTML contents of each element in the set of matched elements.
+ *
+ * @param htmlString A string of HTML to set as the content of each matched element.
+ * @return HTMLElement[]
+ */
+ html(htmlString: string): ChocolateChipElementArray;
+
+
+ /**
+ * Get the value of style properties for the first element in the set of matched elements.
+ *
+ * @param propertyName A CSS property.
+ * @return string
+ */
+ css(propertyName: string): string;
+
+ /**
+ * Set one or more CSS properties for the set of matched elements using a quoted string.
+ *
+ * @param propertyName A CSS property name.
+ * @param value A value to set for the property.
+ * @return HTMLElement[]
+ */
+ css(propertyName: string, value: string): ChocolateChipElementArray;
+
+ /**
+ * Set one or more CSS properties for the set of matched elements.
+ *
+ * @param properties An object of property-value pairs to set.
+ * @return HTMLElement[]
+ */
+ css(properties: Object): ChocolateChipElementArray;
+
+ /**
+ * Get the value of an attribute for the first element in the set of matched elements.
+ *
+ * @param attributeName The name of the attribute to get.
+ * @return string
+ */
+ attr(attributeName: string): string;
+
+ /**
+ * Set an attribute for the set of matched elements.
+ *
+ * @param attributeName A string indicating the attribute to set.
+ * @param value A string indicating the value to set the attribute to.
+ * @return HTMLElement[]
+ */
+ attr(attributeName: string, value: string): ChocolateChipElementArray;
+
+ /**
+ * Remove an attribute from a node.
+ *
+ * @param attributeName A string indicating the attribute to remove.
+ * @return HTMLElement[]
+ */
+ removeAttr(attributeName: string): ChocolateChipElementArray;
+
+ /**
+ * Return any of the matched elements that have the given attribute.
+ *
+ * @param className The class name to search for.
+ * @return HTMLElement[]
+ */
+ hasAttr(attributeName: string): ChocolateChipElementArray;
+
+
+ /**
+ * Get the value of an attribute for the first element in the set of matched elements.
+ *
+ * @param attributeName The name of the attribute to get.
+ * @return string
+ */
+ prop(attributeName: string): string;
+
+ /**
+ * Set an property for the set of matched elements.
+ *
+ * @param propertyName A string indicating the property to set.
+ * @param value A string indicating the value to set the property to.
+ * @return HTMLElement[]
+ */
+ prop(propertyName: string, value: string): ChocolateChipElementArray;
+
+ /**
+ * Adds the specified class(es) to each of the set of matched elements.
+ *
+ * @param className One or more space-separated classes to be added to the class attribute of each matched element.
+ * @return HTMLElement[]
+ */
+ addClass(className: string): ChocolateChipElementArray;
+
+ /**
+ * Remove a single class or multiple classes from each element in the set of matched elements.
+ *
+ * @param className One or more space-separated classes to be removed from the class attribute of each matched element.
+ * @return HTMLElement[]
+ */
+ removeClass(className?: string): ChocolateChipElementArray;
+
+ /**
+ * Add or remove a classe from each element in the set of matched elements, depending on whether the class is present or not.
+ *
+ * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set.
+ * @return HTMLElement[]
+ */
+ toggleClass(className: string, swtch?: boolean): ChocolateChipElementArray;
+
+ /**
+ * Return any of the matched elements that have the given class.
+ *
+ * @param className The class name to search for.
+ * @return HTMLElement[]
+ */
+ hasClass(className: string): ChocolateChipElementArray;
+
+ /**
+ * Store arbitrary data associated with the matched elements.
+ *
+ * @param key A string naming the piece of data to set.
+ * @param value The new data value; it can be any Javascript type including Array or Object.
+ * @return HTMLElement[]
+ */
+ data(key: string, value: any): ChocolateChipElementArray;
+
+ /**
+ * Return the value at the named data store for the first element in the element collection, as set by
+ * data(name).
+ *
+ * @param key Name of the data stored.
+ * @return any
+ */
+ data(key: string): any;
+
+ /**
+ * Remove the value at the named data store for the first element in the element collection, as set by data(name, value).
+ *
+ * @param key Name of the data stored.
+ * @return any
+ */
+ removeData(key: string): any;
+
+ /**
+ * Store string data associated with the matched elements.
+ *
+ * @param key A string naming the piece of data to set.
+ * @param value The new data value; it must be a string. You can convert JSON into a string to use with this.
+ * @return HTMLElement[]
+ */
+ dataset(key: string, value: any): ChocolateChipElementArray;
+
+ /**
+ * Retrieve a dataset key's value for the first element in the element collection.
+ *
+ * @param key A string naming the piece of data to set.
+ * @return HTMLElement[]
+ */
+ dataset(key: string): ChocolateChipElementArray;
+
+ /**
+ * Return the value at the named data store for the first element in the element collection, as set by data(name, value).
+ *
+ * @param key Name of the data stored.
+ * @return any
+ */
+ data(key: string): any;
+
+ /**
+ * Store arbitrary data associated with the matched element.
+ *
+ * @param key A string naming the piece of data to set.
+ * @param value The new data value; it can be any Javascript type including Array or Object.
+ * @return HTMLElement[]
+ */
+ data(key: string, value?: any): ChocolateChipElementArray;
+
+ /**
+ * Get the current value of the first element in the set of matched elements.
+ */
+ val(): any;
+
+ /**
+ * Set the value of each element in the set of matched elements.
+ *
+ * @param value A string of text or an array of strings corresponding to the value of each matched element
+ * to set as selected/checked.
+ * @return any
+ */
+ val(value: string): ChocolateChipElementArray;
+
+ /**
+ * Set the property of an element to enabled by removing the "disabled" attribute.
+ *
+ * @return HTMLElement[]
+ */
+ enable(): ChocolateChipElementArray;
+
+ /**
+ * Set the property of an element to "disabled".
+ *
+ * @return HTMLElement[]
+ */
+ disable(): ChocolateChipElementArray;
+
+ /**
+ * Display the matched elements.
+ *
+ * @param speed A string or number determining how long the animation will run.
+ * @param callback A function to call once the animation is complete.
+ * @return HTMLElement[]
+ */
+ show(duration?: number | string, callback?: Function): ChocolateChipElementArray;
+
+ /**
+ * Hide the matched elements.
+ *
+ * @param duration A string or number determining how long the animation will run.
+ * @param callback A function to call once the animation is complete.
+ * @return HTMLElement[]
+ */
+ hide(duration?: number | string, callback?: Function): ChocolateChipElementArray;
+
+ /**
+ * Insert content, specified by the parameter, before each element in the set of matched elements.
+ *
+ * @param content HTML string, DOM element, array of elements to insert before each element in the set of matched elements.
+ * @return HTMLElement[]
+ */
+ before(content: ChocolateChipElementArray | HTMLElement | string): ChocolateChipElementArray;
+
+ /**
+ * Insert content, specified by the parameter, after each element in the set of matched elements.
+ *
+ * @param content HTML string, DOM element, array of elements to insert after each element in the set of matched elements.
+ * @return HTMLElement[]
+ */
+ after(content: ChocolateChipElementArray | HTMLElement | string): ChocolateChipElementArray;
+
+ /**
+ * Insert content, specified by the parameter, to the end of each element in the set of matched elements.
+ *
+ * @param content DOM element, array of elements, or HTML string to insert at the end of each element in the set
+ * of matched elements.
+ * @return HTMLElement[]
+ */
+ append(content: ChocolateChipElementArray|HTMLElement|Text|string): ChocolateChipElementArray;
+
+ /**
+ * Insert content, specified by the parameter, at the beginning of each element in the set of matched elements.
+ *
+ * @param content DOM element, array of elements, or HTML string to insert at the beginning of each element in the set of matched elements.
+ * @return HTMLElement[]
+ */
+ prepend(content: ChocolateChipElementArray|HTMLElement|Text|string): ChocolateChipElementArray;
+
+ /**
+ * Insert every element in the set of matched elements to the beginning of the target.
+ *
+ * @param target A selector, element, or HTML string. The matched set of elements will be inserted at the beginning of the element specified by this parameter.
+ * @return HTMLElement[]
+ */
+ prependTo(target: any[]|HTMLElement|string): ChocolateChipElementArray;
+
+ /**
+ * Insert every element in the set of matched elements to the end of the target.
+ *
+ * @param target A selector, element, or HTML string. The matched set of elements will be inserted at the end of the element specified by this parameter.
+ * If no position value is provided it will simply append the content to the target.
+ * @return HTMLElement[]
+ */
+ appendTo(target: any[]|HTMLElement|string): ChocolateChipElementArray;
+
+ /**
+ * Insert element(s) into the target element.
+ *
+ * @return HTMLElement[]
+ */
+ insert(content: string, position?: number | string): ChocolateChipElementArray;
+
+ /**
+ * Create a copy of the set of matched elements.
+ *
+ * @param value A Boolean indicating whether to copy the element(s) with their children. A true value copies the children.
+ * @return HTMLElement[]
+ */
+ clone(value?: boolean): ChocolateChipElementArray;
+
+ /**
+ * Wrap an HTML structure around each element in the set of matched elements.
+ *
+ * @param wrappingElement A selector or HTML string specifying the structure to wrap around the matched elements.
+ * @return HTMLElement[]
+ */
+ wrap(wrappingElement: string): ChocolateChipElementArray;
+
+ /**
+ * Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
+ *
+ * @return HTMLElement[]
+ */
+ unwrap(): ChocolateChipElementArray;
+
+ /**
+ * Remove the set of matched elements from the DOM. If there are any attached events, this will remove them to prevent memory leaks.
+ *
+ * @param selector A selector expression that filters the set of matched elements to be removed.
+ * @return HTMLElement[]
+ */
+ remove(selector?: string): ChocolateChipElementArray;
+
+ /**
+ * Remove all child nodes of the set of matched elements from the DOM.
+ *
+ * @return HTMLElement[]
+ */
+ empty(): ChocolateChipElementArray;
+
+ /**
+ * Get an object of the current coordinates of the first element in the set of matched elements, relative to the document.
+ * These are: top, left, bottom and right. The values are numbers representing pixel values.
+ * @return Object
+ */
+ offset(): ChocolateChipOffsetObject;
+
+ /**
+ * Get the current computed width for the first element in the set of matched elements,
+ * including padding but excluding borders.
+ *
+ * @return number
+ */
+ width(): number;
+
+ /**
+ * Get the current computed height for the first element in the set of matched elements,
+ * including padding but excluding borders.
+ *
+ * @return number
+ */
+ height(): number;
+
+ /**
+ * Get the combined text contents of each element in the set of matched elements, including their descendants.
+ *
+ * @return string
+ */
+ text(): string;
+
+ /**
+ * Set the content of each element in the set of matched elements to the specified text.
+ *
+ * @param text The text to set as the content of each matched element. When Number is supplied, it will be converted to a String representation. To delete text, use ChocolateChipElementArray.empty() or ChocolateChipElementArray.remove().
+ * @return HTMLElement
+ */
+ text(text: string | number): HTMLElement;
+
+ /**
+ * Attach a handler to an event for the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ * @return ChocolateChipStatic
+ */
+ bind(eventType: string, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Remove a handler for an event from the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ * @return ChocolateChipStatic
+ */
+ unbind(eventType: string, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Add a delegated event to listen for the provided event on the descendant elements.
+ *
+ * @param selector A string defining the descendant elements to listen on for the designated event.
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered. The keyword "this" will refer
+ * to the element receiving the event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ * @return ChocolateChipStatic
+ */
+ delegate(selector: any, eventType: string, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Add a delegated event to listen for the provided event on the descendant elements.
+ *
+ * @param selector A string defining the descendant elements are listening for the event.
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function handler assigned to this event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ * @return ChocolateChipStatic
+ */
+ undelegate(selector: any, eventType: string, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Add a handler to an event for elements. If a selector is provided as the second argument, this implements a delegated event.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param selector A string defining the descendant elements are listening for the event.
+ * @param handler A function handler assigned to this event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ * @return ChocolateChipStatic
+ */
+ on( eventType: string, selector: any, handler?: (eventObject: Event) => any, capturePhase?: boolean): ChocolateChipStatic;
+
+ /**
+ * Remove a handler for an event from the elements. If the second argument is a selector, it tries to undelegate the event.
+ * If no arugments are provided, it removes all events from the element(s).
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param selector A string defining the descendant elements are listening for the event.
+ * @param handler A function handler assigned to this event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ * @return ChocolateChipStatic
+ */
+ off( eventType?: string, selector?: any, handler?: (eventObject: Event) => any, capturePhase?: boolean): ChocolateChipStatic;
+
+ /**
+ *
+ */
+ trigger(eventType: string): void;
+
+ /**
+ * A method to animate DOM nodes using CSS. This uses CSS transitions.
+ *
+ * @param options And object of key value pairs define the CSS properties and values to animate.
+ * @param duration A string representing the time. Should have a time identifier: "200s", "200ms", etc.
+ * @param easing A string indicating the easing for the animation, such as "ease-out", "ease-in", "ease-in-out".
+ * @return void
+ */
+ animate(options: Object, duration?: string, easing?: string ): void;
+}
+
+/**
+ * Interface for offset object.
+ */
+interface ChocolateChipOffsetObject {
+ top: number;
+ left: number;
+ bottom: number;
+ right: number;
+}
diff --git a/chui/chui-tests.ts b/chui/chui-tests.ts
new file mode 100644
index 000000000..60cbe5afd
--- /dev/null
+++ b/chui/chui-tests.ts
@@ -0,0 +1,97 @@
+///
+///
+
+$(function() {
+
+ /**
+ * Test static methods:
+ */
+ var concatenatedText = $.concat("This", "is", "text", "to", "contatenate.");
+ $.forEach([1,2,3], function(ctx) {
+ return ctx;
+ });
+ $.forEach([1,2,3], function(ctx, idx) {
+ return idx;
+ });
+
+ var isiPhone = $.isiPhone;
+ var isAndroid = $.isAndroid;
+ var isWinPhone = $.isWinPhone;
+
+ $('li').on($.eventStart, function(){
+ return;
+ });
+ $('li').on($.eventEnd, function(){
+ return;
+ });
+ $('li').on($.eventMove, function(){
+ return;
+ });
+ $('li').on($.eventCancel, function(){
+ return;
+ });
+
+ var browserVersion = $.browserVersion();
+ $.UIHideNavBar();
+ $.UIShowNavBar();
+ $.UIGoToArticle("#main");
+ $.UIGoBack();
+ $.UIGoBackToArticle("#main");
+ $.UIBlock();
+ $.UIBlock(.5);
+ $.UIUnblock();
+ $.UIPopup({id: "myPopup", message: 'Hello!!!'});
+ $.UIPopup({message: 'Hello!!!', title: "Whatever", callback: $.noop});
+ $.UIPopup({message: 'Hello!!!', cancleButton: "Forget It!", continueButton: "OK"});
+ $.UIPopover({id: "myPopover"});
+ $.UIPopover({callback: function() {}});
+ $.UIPopover({title: "Whatever"});
+ $.UIPopover({id: "myPopover", callback: function() {}, title: "Whatever"});
+ $.UIPopoverClose();
+ $.UICreateSegmented({id: "mySegmentedControl", labels : ['first','second','third'], selected: 0, className: "special"});
+ $.UIPaging();
+ $.UISheet({id: "mySheet", listClass: "specialList", background: 'red', handle: false});
+ $.UIShowSheet("#mySheet");
+ $.UIHideSheet();
+ $.UISlideout({position: "right", dynamic: false, callback: $.noop});
+ var myStepper = $('#myStepper');
+ $.UIResetStepper(myStepper);
+ $.UICreateSwitch({id: "mySwitch", value: 5, checked: "true", callback: $.noop});
+ $.UITabbar({tabs: 3, labels: ["one", "two", "three"], selected: 2});
+ $.UISearch({articleId: "#main", placehold: "Looking?", results: 10});
+ var carouselPanels = $('li');
+ $.UISetupCarousel({target: "#carousel", panels: carouselPanels});
+ $.UIBindData();
+ $.UIBindData("#myBoundData");
+ $.UIUnBindData();
+ $.UIUnBindData("#myBoundData");
+
+ /**
+ * Test plugin methods:
+ */
+ $("li").forEach(function(ctx, idx) {
+ console.log(ctx.nodeName + ": " + idx);
+ });
+ $('li').iz(".selected").hide();
+ $('li').iznt(".selected").show();
+ $('li').haz("span").hide();
+ $('li').haznt("span").show();
+ $('li').hazClass(".selected").hide();
+ $('li').hazntClass(".selected").show();
+ $('li').hazAttr("disabled").hide();
+ $('li').hazntAttr("disabled").show();
+ $('#main').bind("singletap", function() {
+ return;
+ });
+ $('#main').UICenter();
+ $('#main').UIBusy({size: "120px", color: "red", duration: "5000ms"});
+ $('#myPopup').UIPopupClose();
+ $('#mySegementedControl').UISegmented({selected: 2, callback: $.noop});
+ $("#panelToggler").UIPanelToggle("#togglePanels", $.noop);
+ $('#editList').UIEditList({callback: $.noop, deletable: false, movable: true});
+ $('#mySelectList').UISelectList();
+ $('#myStepper').UIStepper({start: 1, end: 10, defautValue: 5});
+ $('#mySwitch').UISwitch();
+ $('#myRangeControl').UIRange();
+
+});
\ No newline at end of file
diff --git a/chui/chui.d.ts b/chui/chui.d.ts
new file mode 100644
index 000000000..614b9bb8b
--- /dev/null
+++ b/chui/chui.d.ts
@@ -0,0 +1,1261 @@
+// Type definitions for chui v3.8.10
+// Project: https://github.com/chocolatechipui/chocolatechip-ui
+// Definitions by: Robert Biggs
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+/**
+ These TypeScript delcarations for ChocolateChip-UI contain interfaces for both jQuery and ChocolateChipJS. Depending on which library you are using, you will get the type interfaces appropriate for it.
+*/
+/**
+ * Interface for ChocolateChipJS.
+ */
+interface ChocolateChipStatic extends ChuiDetectors {
+ /**
+ * This method will concatenate strings or values as a cleaner alternative to using the '+' operator.
+ *
+ * @param string or number A comma separated series of strings to concatenate.
+ * @return string
+ */
+ concat(...string: string[]): string;
+
+
+ /**
+ * This function replicates normal array iteration with the context first, followed by the index.
+ * Usage: $.forEach([1,2,3], function(ctx, idx) { console.log(ctx + "is: " + (idx + 1)) });
+ *
+ * @param obj An array-like object. This will usually be an array of HTML elements.
+ * @param callback A callback to execute with each iteration of the object.
+ * @param args Any extra arguments you wish to pass.
+ * @return void
+ */
+ forEach(obj: T[], callback: (ctx: T, idx?: number) => any, args?: any): any;
+
+ /**
+ * Alias for cross-platform events: pointerdown, MSPointerDown, touchstart and mousedown.
+ */
+ eventStart: ChUIEventInterface;
+
+ /**
+ * Alias for cross-platform events: pointerup, MSPointerUp, touchend and mouseup.
+ */
+ eventEnd: ChUIEventInterface;
+
+ /**
+ * Alias for cross-platform events: pointermove, MSPointerMove, touchmove and mousemove.
+ */
+ eventMove: ChUIEventInterface;
+
+ /**
+ * Alias for cross-platform events: pointercancel, MSPointerCancel, touchcancel and mouseout.
+ */
+ eventCancel: ChUIEventInterface;
+
+
+ /**
+ * Return the version of the current browser.
+ *
+ * @return string The current browser version.
+ */
+ browserVersion(): number;
+
+ /**
+ * Hide the navigation bar, raising up the content below it.
+ */
+ UIHideNavBar(): void;
+
+ /**
+ * If the navigation bar is hidden, show it, pushing down the content to make room.
+ */
+ UIShowNavBar(): void;
+
+ /**
+ * Determine whether navigation is in progress or not.
+ */
+ isNavigating: boolean;
+
+ /**
+ * Navigate to the article indicated by the provided destination ID. This enters the destination into the navigation history array.
+ *
+ * param destination An id for the article to navigate to.
+ */
+ UIGoToArticle(destination: string): void;
+
+ /**
+ * Go back to the previous article from whence you came. This resets the navigation history array.
+ */
+ UIGoBack(): void;
+
+ /**
+ * Go back to the article indicated by the provided ID. This is for non-linear back navigation. This will reset the navigation history array to match the current state.
+ */
+ UIGoBackToArticle(articleID: string): void;
+
+ /**
+ * Display a transparent screen over the UI. This takes an optional, decimal-based number for opacity: .5 for 50%.
+ *
+ * @param opacity The percentage of opacity for the screen.
+ */
+ UIBlock(opacity?: number): void;
+
+ /**
+ * Remove the transparent screen covering the UI.
+ */
+ UIUnblock(): void;
+
+ /**
+ * Create and show a Popup with title and message. Possible options: {id: "#myPopup", title: "My Popup",
+ * message: "Woohoo!", cancelButton: "Forget It!", contiueButton: "Whatever", callback: function() {console.log('Blah!');}, empty: false }.
+ *
+ * param options UIPopupOptions
+ */
+ UIPopup(options: UIPopupOptions): void;
+
+ /**
+ * Create and show a Popover. Options: {id: "#myPopover", title: "Whatever", callback: function() {console.log('Blah!');}}.
+ *
+ * param options UIPopoverOptions
+ */
+ UIPopover(options: UIPopoverOptions): void;
+
+ /**
+ * Close any currently visible popovers.
+ */
+ UIPopoverClose(): void;
+
+ /**
+ * Create a segmented control: {id: "mySegments", className: "seggie", labels: ["one", "two","three"], selected: 1}
+ *
+ * param: options UICreateSegmentedOptions
+ */
+ UICreateSegmented(options: UICreateSegmentedOptions): ChocolateChipElementArray;
+
+ /**
+ * Initialize a horiontal or vertical paging control. This uses a segmented control in the navigation bar with a class
+ * like "segmented paging horizontal" or "segmented paging vertical". It uses a single article with multiple sections to paginate.
+ */
+ UIPaging(): void;
+
+ /**
+ * Creates a sheet. Minimum option is an id: {id : 'starTrek', listClass :'enterprise', background: 'transparent', handle: false }
+ */
+ UISheet(options: UISheetOptions): void;
+
+ /**
+ * Show a sheet by passing this its ID.
+ */
+ UIShowSheet(id?: string): void;
+
+ /**
+ * Hide any currently displayed sheets.
+ */
+ UIHideSheet(): void;
+
+ /**
+ * The body tag wrapped and ready to use: $.body.css('background-color','orange')
+ */
+ body: ChocolateChipElementArray;
+
+ /**
+ * An array of the navigation history. Do not manipulate this. For examination only. This is used by navigation lists, etc.
+ */
+ UINavigationHistory: string[];
+
+ /**
+ * Creates and initializes a slide out menu. Possible options: {dynamic: true, callback: function() { alert("Woohoo!");}}
+ */
+ UISlideout: UISlideoutInterface;
+
+ /**
+ * Reset the value of the stepper to its defaults at initialization. Pass it a reference to the stepper to reset. It takes a stepper element: $("#myStepper").
+ *
+ * @param stepper A stepper to reset.
+ */
+ UIResetStepper(stepper: ChocolateChipElementArray): void;
+
+ /**
+ * Create a switch control. Possible options: { id: '#myId', name: 'fruit.mango', state: 'on', value: 'Mango', checked: 'on', style: 'traditional', callback: function() { alert('hi');}}
+ */
+ UICreateSwitch(options: UICreateSwitchOptions): void;
+
+ /**
+ * Creates a tabbar. On iOS this is at the bottom of the screen. On Android and Windows, it is at the top.
+ * Options: {id: 'mySpecialTabbar', tabs: 4, labels: ["Refresh", "Add", "Info", "Downloads", "Favorite"], icons: ["refresh", "add", "info", "downloads", "favorite"], selected: 2 }
+ */
+ UITabbar(options: UITabbarOptions): void;
+
+ /**
+ * Create a search bar for an article. Options: { articleId: '#products', id: 'productSearch', placeholder: 'Find a product', results: 5 }
+ */
+ UISearch(options: UISearchOptions): void;
+
+ /**
+ * Create and initialize a swipable carousel. Options: {target : '#myCarousel', panels: ['
stuff
','
more
'], loop: true, pagination: true }
+ */
+ UISetupCarousel(options: UISetupCarouselOptions): void;
+
+ /**
+ * Bind the values of data-models to elements with data-controllers: .
+ * You can bind a single model to its controller by providing its name as the argument: $.UIBindData('input-value');
+ *
+ * @param controller A string indicating the controller whose value a model is bound to.
+ */
+ UIBindData(controller?: string): void;
+
+ /**
+ * Unbind the values of data-models from their data-controllers.
+ * If you provide a controller name as the argument, only that controller will be unbound.
+ *
+ * @param controller A controller to unbind.
+ */
+ UIUnBindData(controller?: string): void;
+
+}
+
+/**
+ * Interface for ChocolateChipJS Element Array.
+ */
+interface ChocolateChipElementArray {
+
+ /**
+ * Iterate over an Array object, executing a function for each matched element.
+ */
+
+ forEach(func: (ctx: any, idx: number) => void): void;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it matches the given arguments.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ iz(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it matches the given arguments.
+ *
+ * @param elements One or more elements to match the current set of elements against.
+ */
+ iz(element: any): ChocolateChipElementArray;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it does not match the given arguments.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ iznt(selector: string): ChocolateChipElementArray;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it does not match the given arguments.
+ *
+ * @param elements One or more elements to match the current set of elements against.
+ */
+ iznt(element: any): ChocolateChipElementArray;
+
+ /**
+ * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ haz(selector: string): ChocolateChipElementArray;
+ /**
+ * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+ *
+ * @param element A DOM element to match elements against.
+ */
+ haz(element: Element): ChocolateChipElementArray;
+
+ /**
+ * Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ haznt(selector: string): ChocolateChipElementArray;
+ /**
+ * Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
+ *
+ * @param element A DOM element to match elements against.
+ */
+ haznt(element: Element): ChocolateChipElementArray;
+
+ /**
+ * Return any of the matched elements that have the given class.
+ *
+ * @param className The class name to search for.
+ */
+ hazClass(className: string): ChocolateChipElementArray;
+
+ /**
+ * Return any of the matched elements that do not have the given class.
+ *
+ * @param className The class name to search for.
+ */
+ hazntClass(className: string): ChocolateChipElementArray;
+
+
+ /**
+ * Return any of the matched elements that have the given attribute.
+ *
+ * @param className The class name to search for.
+ */
+ hazAttr(attributeName: string): ChocolateChipElementArray;
+
+ /**
+ * Return any of the matched elements that do not have the given attribute.
+ *
+ * @param className The class name to search for.
+ */
+ hazntAttr(attributeName: string): ChocolateChipElementArray;
+
+ /**
+ * Attach a handler to an event for the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ */
+ bind(eventType: string | ChUIEventInterface, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Remove a handler for an event from the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ */
+ unbind(eventType: string | ChUIEventInterface, handler?: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Add a delegated event to listen for the provided event on the descendant elements.
+ *
+ * @param selector A string defining the descendant elements to listen on for the designated event.
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered. The keyword "this" will refer
+ * to the element receiving the event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ */
+ delegate(selector: any, eventType: string | ChUIEventInterface, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Add a delegated event to listen for the provided event on the descendant elements.
+ *
+ * @param selector A string defining the descendant elements are listening for the event.
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function handler assigned to this event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ */
+ undelegate(selector: any, eventType: string | ChUIEventInterface, handler: (eventObject: Event) => any, useCapture?: boolean): ChocolateChipStatic;
+
+ /**
+ * Add a handler to an event for elements. If a selector is provided as the second argument, this implements a delegated event.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param selector A string defining the descendant elements are listening for the event.
+ * @param handler A function handler assigned to this event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ */
+ on( eventType: string | ChUIEventInterface, selector: any, handler?: (eventObject: Event) => any, capturePhase?: boolean): ChocolateChipStatic;
+
+ /**
+ * Remove a handler for an event from the elements. If the second argument is a selector, it tries to undelegate the event.
+ * If no arugments are provided, it removes all events from the element(s).
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param selector A string defining the descendant elements are listening for the event.
+ * @param handler A function handler assigned to this event.
+ * @param useCapture Setting the third argument to true will trigger event bubbling. The default is false.
+ */
+ off( eventType?: string | ChUIEventInterface, selector?: any, handler?: (eventObject: Event) => any, capturePhase?: boolean): ChocolateChipStatic;
+
+ /**
+ *
+ */
+ trigger(eventType: string | ChUIEventInterface): void;
+
+ /**
+ * Center an element to the screen.
+ */
+ UICenter(): void;
+
+ /**
+ * Display a busy indicator. Posible options: {size: "100px", color: "#ff0000", position: "align-flush", duration: "2s"}.
+ *
+ * @param size The size as a string with length identifier: "40px".
+ * @param color The color for the busy indicator: "#ff0000".
+ * @param position Optional positioning, such as "align-flush".
+ * @param duration The time for the busy indicator to display: "500ms".
+ */
+ UIBusy(options: UIBusyOptions): void;
+
+ /**
+ * Close the currently displayed Popup. This is executed on the popup: $('#myPopup').UIPopupClose().
+ */
+ UIPopupClose(): void;
+
+ /**
+ * Initialize a segmented control. Options: {selected: 2, callback: function() {console.log('Blah');}}
+ */
+ UISegmented(options: UISegmentedOptions): void;
+
+ /**
+ * This method allows the user to use a segmented control to toggle a set of panels. It is executed on the segmented control.
+ * The options id is the contain of the panels. The options callback is to execute when the user toggles a panel.
+ */
+ UIPanelToggle(panelsContainer: string, callback: () => any): void;
+
+ /**
+ * Make a list editable. This can be enabling changing the order of list items, or deleting them, or both. Options: {editLabel: "Edit", doneLabel: "Done",
+ * deleteLabel: "Delete", callback: function() {alert('Bye bye!');}, deletable: true, movable: true}.
+ */
+ UIEditList(options: UIEditListOptions): void;
+
+ /**
+ * Convert a simple list into a selection list. This converts the list into a radio button group, meaning only one can be selected at any time.
+ * You can name the radios buttons using the options name. Options: {name: "selectedNamesGroup", selected: 2, callback: function() {alert('hi');}}
+ */
+ UISelectList(): void;
+
+ /**
+ * Create a stepper control by executing it on a span with the class "stepper". Possible options: {start: 0, end: 10, defaultValue: 3}.
+ */
+ UIStepper(options: UIStepperOptions): void;
+
+ /**
+ * Initialize any existing switch controls: $('.switch').UISwitch();
+ */
+ UISwitch(): void;
+
+ /**
+ * Execute this on a range control to initialize it.
+ */
+ UIRange(): void;
+}
+
+/**
+ * Interface for jQuery
+ */
+
+interface JQueryStatic extends ChuiDetectors {
+ /**
+ * This method will concatenate strings or values as a cleaner alternative to using the '+' operator.
+ *
+ * @param string or number A comma separated series of strings to concatenate.
+ * @return string
+ */
+ concat(...string: string[]): string;
+
+ /**
+ * This function replicates normal array iteration with the context first, followed by the index.
+ * Usage: $.forEach([1,2,3], function(ctx, idx) { console.log(ctx + "is: " + (idx + 1)) });
+ *
+ * @param obj An array-like object. This will usually be an array of HTML elements.
+ * @param callback A callback to execute with each iteration of the object.
+ * @param args Any extra arguments you wish to pass.
+ * @return void
+ */
+ forEach(obj: T[], callback: (ctx: T, idx?: number) => any, args?: any): any;
+
+ /**
+ * Alias for cross-platform events: pointerdown, MSPointerDown, touchstart and mousedown.
+ */
+ eventStart: ChUIEventInterface;
+
+ /**
+ * Alias for cross-platform events: pointerup, MSPointerUp, touchend and mouseup.
+ */
+ eventEnd: ChUIEventInterface;
+
+ /**
+ * Alias for cross-platform events: pointermove, MSPointerMove, touchmove and mousemove.
+ */
+ eventMove: ChUIEventInterface;
+
+ /**
+ * Alias for cross-platform events: pointercancel, MSPointerCancel, touchcancel and mouseout.
+ */
+ eventCancel: ChUIEventInterface;
+
+ /**
+ * Return the version of the current browser.
+ */
+ browserVersion(): number;
+
+ /**
+ * Hide the navigation bar, raising up the content below it.
+ */
+ UIHideNavBar(): void;
+
+ /**
+ * If the navigation bar is hidden, show it, pushing down the content to make room.
+ */
+ UIShowNavBar(): void;
+
+ /**
+ * Determine whether navigation is in progress or not.
+ */
+ isNavigating: boolean;
+
+ /**
+ * Navigate to the article indicated by the provided destination ID. This enters the destination into the navigation history array.
+ *
+ * param destination An id for the article to navigate to.
+ */
+ UIGoToArticle(destination: string): void;
+
+ /**
+ * Go back to the previous article from whence you came. This resets the navigation history array.
+ */
+ UIGoBack(): void;
+
+ /**
+ * Go back to the article indicated by the provided ID. This is for non-linear back navigation. This will reset the navigation history array to match the current state.
+ */
+ UIGoBackToArticle(articleID: string): void;
+
+ /**
+ * Display a transparent screen over the UI. This takes an optional, decimal-based number for opacity: .5 for 50%.
+ *
+ * @param opacity The percentage of opacity for the screen.
+ */
+ UIBlock(opacity?: number): void;
+
+ /**
+ * Remove the transparent screen covering the UI.
+ */
+ UIUnblock(): void;
+
+ /**
+ * Create and show a Popup with title and message. Possible options: {id: "#myPopup", title: "My Popup",
+ * message: "Woohoo!", cancelButton: "Forget It!", contiueButton: "Whatever", callback: function() {console.log('Blah!');}, empty: false }.
+ *
+ * param options UIPopupOptions
+ */
+ UIPopup(options: UIPopupOptions): void;
+
+ /**
+ * Create and show a Popover. Options: {id: "#myPopover", title: "Whatever", callback: function() {console.log('Blah!');}}.
+ *
+ * param options UIPopoverOptions
+ */
+ UIPopover(options: UIPopoverOptions): void;
+
+ /**
+ * Close any currently visible popovers.
+ */
+ UIPopoverClose(): void;
+
+ /**
+ * Create a segmented control: {id: "mySegments", className: "seggie", labels: ["one", "two","three"], selected: 1}
+ *
+ * param: options UICreateSegmentedOptions
+ */
+ UICreateSegmented(options: UICreateSegmentedOptions): JQuery;
+
+ /**
+ * Initialize a horiontal or vertical paging control. This uses a segmented control in the navigation bar with a class
+ * like "segmented paging horizontal" or "segmented paging vertical". It uses a single article with multiple sections to paginate.
+ */
+ UIPaging(): void;
+
+ /**
+ * Creates a sheet. Minimum option is an id: {id : 'starTrek', listClass :'enterprise', background: 'transparent', handle: false }
+ */
+ UISheet(options: UISheetOptions): void;
+
+ /**
+ * Show a sheet by passing this its ID.
+ */
+ UIShowSheet(id: string): void;
+
+ /**
+ * Hide any currently displayed sheets.
+ */
+ UIHideSheet(): void;
+
+ /**
+ * The body tag wrapped and ready to use: $.body.css('background-color','orange')
+ */
+ body: JQuery;
+
+ /**
+ * An array of the navigation history. Do not manipulate this. For examination only. This is used by navigation lists, etc.
+ */
+ UINavigationHistory: string[];
+
+ /**
+ * Creates and initializes a slide out menu. Possible options: {dynamic: true, callback: function() { alert("Woohoo!");}}
+ */
+ UISlideout: UISlideoutInterface;
+
+ /**
+ * Reset the value of the stepper to its defaults at initialization. Pass it a reference to the stepper to reset.
+ */
+ UIResetStepper(stepper: JQuery): void;
+
+ /**
+ * Create a switch control. Possible options: { id: '#myId', name: 'fruit.mango', state: 'on', value: 'Mango', checked: 'on', style: 'traditional', callback: function() { alert('hi');}}
+ */
+ UICreateSwitch(options: UICreateSwitchOptions): void;
+
+ /**
+ * Creates a tabbar. On iOS this is at the bottom of the screen. On Android and Windows, it is at the top.
+ * Options: {id: 'mySpecialTabbar', tabs: 4, labels: ["Refresh", "Add", "Info", "Downloads", "Favorite"], icons: ["refresh", "add", "info", "downloads", "favorite"], selected: 2 }
+ */
+ UITabbar(options: UITabbarOptions): void;
+
+ /**
+ * Create a search bar for an article. Options: { articleId: '#products', id: 'productSearch', placeholder: 'Find a product', results: 5 }
+ */
+ UISearch(options: UISearchOptions): void;
+
+ /**
+ * Create and initialize a swipable carousel. Options: {target : '#myCarousel', panels: ['
stuff
','
more
'], loop: true, pagination: true }
+ */
+ UISetupCarousel(options: UISetupCarouselOptions): void;
+
+ /**
+ * Bind the values of data-models to elements with data-controllers: .
+ * You can bind a single model to its controller by providing its name as the argument: $.UIBindData('input-value');
+ *
+ * @param controller A string indicating the controller whose value a model is bound to.
+ */
+ UIBindData(controller?: string): void;
+
+ /**
+ * Unbind the values of data-models from their data-controllers.
+ * If you provide a controller name as the argument, only that controller will be unbound.
+ *
+ * @param controller A controller to unbind.
+ */
+ UIUnBindData(controller?: string): void;
+
+}
+
+/**
+ * Interface for jQuery
+ */
+interface JQuery {
+
+ /**
+ * Iterate over an Array object, executing a function for each matched element.
+ */
+ //forEach(func: (ctx: any, idx: number) => void, JQuery: any): void;
+ forEach(callback: (ctx: Element, idx: number) => any): JQuery;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it matches the given arguments.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ iz(selector: string): JQuery;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it matches the given arguments.
+ *
+ * @param elements One or more elements to match the current set of elements against.
+ */
+ iz(element: any): JQuery;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it does not match the given arguments.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ iznt(selector: string): JQuery;
+
+ /**
+ * Check the current matched set of elements against a selector or element and return it
+ * if it does not match the given arguments.
+ *
+ * @param elements One or more elements to match the current set of elements against.
+ */
+ iznt(element: any): JQuery;
+
+ /**
+ * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ haz(selector: string): JQuery;
+ /**
+ * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
+ *
+ * @param contained A DOM element to match elements against.
+ */
+ haz(contained: Element): JQuery;
+
+ /**
+ * Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
+ *
+ * @param selector A string containing a selector expression to match elements against.
+ */
+ haznt(selector: string): JQuery;
+ /**
+ * Reduce the set of matched elements to those that have a descendant that does not match the selector or DOM element.
+ *
+ * @param contained A DOM element to match elements against.
+ */
+ haznt(contained: Element): JQuery;
+
+ /**
+ * Return any of the matched elements that have the given class.
+ *
+ * @param className The class name to search for.
+ */
+ hazClass(className: string): JQuery;
+
+ /**
+ * Return any of the matched elements that do not have the given class.
+ *
+ * @param className The class name to search for.
+ */
+ hazntClass(className: string): JQuery;
+
+
+ /**
+ * Return any of the matched elements that have the given attribute.
+ *
+ * @param className The class name to search for.
+ */
+ hazAttr(attributeName: string): JQuery;
+
+ /**
+ * Return any of the matched elements that do not have the given attribute.
+ *
+ * @param className The class name to search for.
+ */
+ hazntAttr(attributeName: string): JQuery;
+
+ /**
+ * Center an element to the screen.
+ */
+ UICenter(): void;
+
+ /**
+ * Display a busy indicator. Posible options: {size: "100px", color: "#ff0000", position: "align-flush", duration: "2s"}.
+ *
+ * @param size The size as a string with length identifier: "40px".
+ * @param color The color for the busy indicator: "#ff0000".
+ * @param position Optional positioning, such as "align-flush".
+ * @param duration The time for the busy indicator to display: "500ms".
+ */
+ UIBusy(options: UIBusyOptions): void;
+
+ /**
+ * Close the currently displayed Popup. This is executed on the popup: $('#myPopup').UIPopupClose().
+ */
+ UIPopupClose(): void;
+
+ /**
+ * Initialize a segmented control. Options: {selected: 2, callback: function() {console.log('Blah');}}
+ */
+ UISegmented(options: UISegmentedOptions): void;
+
+ /**
+ * This method allows the user to use a segmented control to toggle a set of panels. It is executed on the segmented control.
+ * The options id is the contain of the panels. The options callback is to execute when the user toggles a panel.
+ */
+ UIPanelToggle(panelsContainer: string, callback: () => any): void;
+
+ /**
+ * Make a list editable. This can be enabling changing the order of list items, or deleting them, or both. Options: {editLabel: "Edit", doneLabel: "Done",
+ * deleteLabel: "Delete", callback: function() {alert('Bye bye!');}, deletable: true, movable: true}.
+ */
+ UIEditList(options: UIEditListOptions): void;
+
+ /**
+ * Convert a simple list into a selection list. This converts the list into a radio button group, meaning only one can be selected at any time.
+ * You can name the radios buttons using the options name. Options: {name: "selectedNamesGroup", selected: 2, callback: function() {alert('hi');}}
+ */
+ UISelectList(): void;
+
+ /**
+ * Create a stepper control by executing it on a span with the class "stepper". Possible options: {start: 0, end: 10, defaultValue: 3}.
+ */
+ UIStepper(options: UIStepperOptions): void;
+
+ /**
+ * Initialize any existing switch controls: $('.switch').UISwitch();
+ */
+ UISwitch(): void;
+
+ /**
+ * Execute this on a range control to initialize it.
+ */
+ UIRange(): void;
+
+
+ /**
+ * Attach a handler to an event for the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param eventData An object containing data that will be passed to the event handler.
+ * @param handler A function to execute each time the event is triggered.
+ */
+ bind(eventType: string | ChUIEventInterface, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Attach a handler to an event for the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute each time the event is triggered.
+ */
+ bind(eventType: string | ChUIEventInterface, handler: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Attach a handler to an event for the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param eventData An object containing data that will be passed to the event handler.
+ * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true.
+ */
+ bind(eventType: string | ChUIEventInterface, eventData: any, preventBubble: boolean): JQuery;
+ /**
+ * Attach a handler to an event for the elements.
+ *
+ * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
+ * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true.
+ */
+ bind(eventType: string | ChUIEventInterface, preventBubble: boolean): JQuery;
+
+
+ delegate(selector: any, eventType: string | ChUIEventInterface, handler: (eventObject: JQueryEventObject) => any): JQuery;
+ delegate(selector: any, eventType: string | ChUIEventInterface, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+ /**
+ * Remove an event handler.
+ *
+ * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin".
+ * @param selector A selector which should match the one originally passed to .on() when attaching event handlers.
+ * @param handler A handler function previously attached for the event(s), or the special value false.
+ */
+ off(events: string | ChUIEventInterface, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Remove an event handler.
+ *
+ * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin".
+ * @param handler A handler function previously attached for the event(s), or the special value false.
+ */
+ off(events: string | ChUIEventInterface, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+ /**
+ * Attach an event handler function for one or more events to the selected elements.
+ *
+ * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+ * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
+ */
+ on(events: string | ChUIEventInterface, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
+ /**
+ * Attach an event handler function for one or more events to the selected elements.
+ *
+ * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+ * @param data Data to be passed to the handler in event.data when an event is triggered.
+ * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+ */
+ on(events: string | ChUIEventInterface, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
+ /**
+ * Attach an event handler function for one or more events to the selected elements.
+ *
+ * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+ * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+ * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+ */
+ on(events: string | ChUIEventInterface, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
+ /**
+ * Attach an event handler function for one or more events to the selected elements.
+ *
+ * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+ * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+ * @param data Data to be passed to the handler in event.data when an event is triggered.
+ * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+ */
+ on(events: string | ChUIEventInterface, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
+
+ /**
+ * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+ *
+ * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
+ * @param handler A function to execute at the time the event is triggered.
+ */
+ one(events: string | ChUIEventInterface, handler: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+ *
+ * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
+ * @param data An object containing data that will be passed to the event handler.
+ * @param handler A function to execute at the time the event is triggered.
+ */
+ one(events: string | ChUIEventInterface, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+ /**
+ * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+ *
+ * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+ * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+ * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+ */
+ one(events: string | ChUIEventInterface, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
+ *
+ * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
+ * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
+ * @param data Data to be passed to the handler in event.data when an event is triggered.
+ * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
+ */
+ one(events: string | ChUIEventInterface, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
+
+ /**
+ * Execute all handlers and behaviors attached to the matched elements for the given event type.
+ *
+ * @param eventType A string containing a JavaScript event type, such as click or submit.
+ * @param extraParameters Additional parameters to pass along to the event handler.
+ */
+ trigger(eventType: string | ChUIEventInterface, extraParameters?: any[]|Object): JQuery;
+
+ /**
+ * Execute all handlers attached to an element for an event.
+ *
+ * @param eventType A string containing a JavaScript event type, such as click or submit.
+ * @param extraParameters An array of additional parameters to pass along to the event handler.
+ */
+ triggerHandler(eventType: string | ChUIEventInterface, ...extraParameters: any[]): Object;
+
+ /**
+ * Remove a previously-attached event handler from the elements.
+ *
+ * @param eventType A string containing a JavaScript event type, such as click or submit.
+ * @param handler The function that is to be no longer executed.
+ */
+ unbind(eventType?: string | ChUIEventInterface, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Remove a previously-attached event handler from the elements.
+ *
+ * @param eventType A string containing a JavaScript event type, such as click or submit.
+ * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ).
+ */
+ unbind(eventType: string | ChUIEventInterface, fls: boolean): JQuery;
+
+ /**
+ * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
+ *
+ * @param selector A selector which will be used to filter the event results.
+ * @param eventType A string containing a JavaScript event type, such as "click" or "keydown"
+ * @param handler A function to execute at the time the event is triggered.
+ */
+ undelegate(selector: string | ChUIEventInterface, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
+ /**
+ * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
+ *
+ * @param selector A selector which will be used to filter the event results.
+ * @param events An object of one or more event types and previously bound functions to unbind from them.
+ */
+ undelegate(selector: string | ChUIEventInterface, events: Object): JQuery;
+}
+
+interface UISetupCarouselOptions {
+ target: string;
+ panels: HTMLElement[] | JQuery;
+ loop?: boolean;
+ pagination?: boolean;
+}
+
+interface UISearchOptions {
+ articleId?: string;
+ id?: string;
+ placeholder?: string;
+ results?: number;
+}
+
+interface UITabbarOptions {
+ id?: string;
+ tabs: number;
+ labels: string[];
+ icons?: string[];
+ selected?: number;
+}
+
+interface UICreateSwitchOptions {
+ id?: string;
+ name?: string;
+ state?: string;
+ value?: string | number;
+ checked?: string;
+ style?: string;
+ callback?: () => any;
+}
+
+/**
+ * Interface for UISlideout.
+ */
+interface UISlideoutInterface {
+ /**
+ * Creates and initializes a slide out menu. Possible options: {dynamic: true, callback: function() { alert("Woohoo!");}}
+ */
+ (options: UISlideoutOptions): void;
+
+ /**
+ * Populates a slideout menu.
+ */
+ populate(array: Object[]): void;
+}
+
+interface UIStepperOptions {
+ start: number;
+ end: number;
+ defaultValue?: number;
+}
+
+interface ChUIEventInterface {
+ eventStart: string;
+ eventEnd: string;
+ eventMove: string;
+ eventCancel: string;
+}
+
+interface UIBusyOptions {
+ size?: string;
+ color?: string;
+ position?: string | boolean;
+ duration?: string;
+}
+
+interface UIPopupOptions {
+ id?: string;
+ title?: string;
+ message?: string;
+ cancelButton?: string;
+ continueButton?: string;
+ callback?: Function;
+ empty?: boolean;
+}
+
+interface UIPopoverOptions {
+ id?: string;
+ callback?: Function;
+ title?: string;
+}
+
+interface UICreateSegmentedOptions {
+ id?: string;
+ className?: string;
+ labels?: string[];
+ selected?: number
+}
+
+interface UISegmentedOptions {
+ selected?: number;
+ callback?: Function;
+}
+
+interface UIEditListOptions {
+ editLabel?: string;
+ doneLabel?: string;
+ deleteLabel?: string;
+ callback?: Function;
+ deletable?: boolean;
+ movable?: boolean;
+}
+
+interface UISelectListOptions {
+ name?: string;
+ selected?: number;
+ callback?: Function;
+}
+
+interface UISheetOptions {
+ id?: string;
+ listClass?: string;
+ background?: string;
+ handle?: boolean;
+}
+
+interface UISlideoutOptions {
+ dynamic?: boolean;
+ callback?: Function;
+ position?: string;
+}
+
+
+/**
+ * The interface used to construct jQuery events (with $.Event). It is
+ * defined separately instead of inline in JQueryStatic to allow
+ * overriding the construction function with specific strings
+ * returning specific event objects.
+ */
+interface JQueryEventConstructor {
+ (name: string, eventProperties?: any): JQueryEventObject;
+ new (name: string, eventProperties?: any): JQueryEventObject;
+}
+
+interface JQueryEventInterface {
+ Event: JQueryEventConstructor;
+}
+
+/**
+ * Interface of the JQuery extension of the W3C event object
+ */
+interface BaseJQueryEventObject extends Event {
+
+}
+interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject {
+}
+
+/**
+ * Interface of the JQuery extension of the W3C event object
+ */
+interface BaseJQueryEventObject extends Event {
+
+}
+
+interface JQueryInputEventObject extends BaseJQueryEventObject {
+
+}
+
+interface JQueryMouseEventObject extends JQueryInputEventObject {
+
+}
+
+interface JQueryKeyEventObject extends JQueryInputEventObject {
+
+}
+
+interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject {
+}
+
+/**
+ * Interface for detectors.
+ */
+ interface ChuiDetectors {
+
+ /**
+ * Whether device is iPhone.
+ */
+ isiPhone: boolean;
+
+ /**
+ * Whether device is iPad.
+ */
+ isiPad: boolean;
+
+ /**
+ * Whether device is iPod.
+ */
+ isiPod: boolean;
+
+ /**
+ * Whether OS is iOS.
+ */
+ isiOS: boolean;
+
+ /**
+ * Whether OS is Android
+ */
+ isAndroid: boolean;
+
+ /**
+ * Whether OS is WebOS.
+ */
+ isWebOS: boolean;
+
+ /**
+ * Whether OS is Blackberry.
+ */
+ isBlackberry: boolean;
+
+ /**
+ * Whether OS supports touch events.
+ */
+ isTouchEnabled: boolean;
+
+ /**
+ * Whether there is a network connection.
+ */
+ isOnline: boolean;
+
+ /**
+ * Whether app is running in stanalone mode.
+ */
+ isStandalone: boolean;
+
+ /**
+ * Whether OS i iOS 7.
+ */
+ isiOS7: boolean;
+
+ /**
+ * Whether OS i iOS 7.
+ */
+ isiOS8: boolean;
+
+ /**
+ * Whether OS i iOS 7.
+ */
+ isiOS9: boolean;
+
+ /**
+ * Whether OS is Windows.
+ */
+ isWin: boolean;
+
+ /**
+ * Whether device is Windows Phone.
+ */
+ isWinPhone: boolean;
+
+ /**
+ * Whether browser is IE10.
+ */
+ isIE10: boolean;
+
+ /**
+ * Whether browser is IE11.
+ */
+ isIE11: boolean;
+ /**
+ * Whether browser is Microsoft Edge or not.
+ */
+ isIEEdge: boolean;
+
+ /**
+ * Whether browser is Webkit based.
+ */
+ isWebkit: boolean;
+
+ /**
+ * Whether browser is running on mobile device.
+ */
+ isMobile: boolean;
+
+ /**
+ * Whether browser is running on desktop.
+ */
+ isDesktop: boolean;
+
+ /**
+ * Whether browser is Safari.
+ */
+ isSafari: boolean;
+
+ /**
+ * Whether browser is Chrome.
+ */
+ isChrome: boolean;
+
+ /**
+ * Is native Android browser (not mobile Chrome).
+ */
+ isNativeAndroid: boolean;
+
+ /**
+ * Whether screen is at least 960 pixels wide.
+ */
+ isWideScreen: boolean;
+
+ /**
+ * Whether screen is at least 960 pixels wide and in portrait orientation.
+ */
+ isWideScreenPortrait: boolean;
+ }
\ No newline at end of file
diff --git a/dcjs/dc.d.ts b/dcjs/dc.d.ts
index 9a7cda23a..850d1abec 100644
--- a/dcjs/dc.d.ts
+++ b/dcjs/dc.d.ts
@@ -263,7 +263,7 @@ declare module DC {
radius: number;
}
- export interface LineChart extends StackMixin, CoordinateGridMixin {
+ export interface LineChart extends StackMixin, CoordinateGridMixin {
interpolate: IGetSet;
tension: IGetSet;
defined: IGetSet, LineChart>;
diff --git a/decimal.js/decimal.js.d.ts b/decimal.js/decimal.js.d.ts
index da2489a5f..74910614e 100644
--- a/decimal.js/decimal.js.d.ts
+++ b/decimal.js/decimal.js.d.ts
@@ -6,7 +6,7 @@
declare var Decimal: decimal.IDecimalStatic;
// Support AMD require
-declare module 'decimal' {
+declare module 'decimal.js' {
export = Decimal;
}
diff --git a/documentdb/documentdb-tests.ts b/documentdb/documentdb-tests.ts
index 13927cd93..ae0c66b89 100644
--- a/documentdb/documentdb-tests.ts
+++ b/documentdb/documentdb-tests.ts
@@ -13,6 +13,22 @@ docDBClient.createDatabase({ id: 'foo' }, undefined, (error, result) => {
}
});
+var dbQuerySpec: docDB.SqlQuerySpec = {query: 'SELECT * FROM d WHERE d.meta = @meta', parameters: [{name: '@meta', value: {creator: 'John Smith', type: 'documentdb'}}]};
+docDBClient.queryDatabases(dbQuerySpec).toArray((error, result) => {
+
+ if (error) {
+ throw new Error(error.body);
+ }
+ else {
+ if (result.length < 1) {
+ throw new Error('Database foo not found');
+ }
+ else {
+ console.log('Found database: ' + result[0].id);
+ }
+ }
+});
+
docDBClient.createCollection('database', { id: 'foo' }, undefined, (error, result) => {
if (error) {
@@ -40,6 +56,41 @@ docDBClient.createStoredProcedure('collection', procedure, undefined, (error, re
}
});
+var trigger: docDB.Trigger = {
+ id: 'trigger-one',
+ body: function () {
+ console.log('bar');
+ },
+ triggerType: 'pre',
+ triggerOperation: 'all'
+};
+
+docDBClient.createTrigger('collection', trigger, undefined, (error, result) => {
+
+ if (error) {
+ throw new Error(error.body);
+ }
+ else {
+ console.log('Created trigger: ' + result.id);
+ }
+});
+
+var triggerQuerySpec: docDB.SqlQuerySpec = {query: 'SELECT * FROM t WHERE t.id = @id', parameters: [{name: '@id', value: 'trigger-foo'}]};
+docDBClient.queryTriggers('collection', triggerQuerySpec).toArray((error, result) => {
+
+ if (error) {
+ throw new Error(error.body);
+ }
+ else {
+ if (result.length < 1) {
+ throw new Error('Trigger trigger-foo not found');
+ }
+ else {
+ console.log('Found trigger: ' + result[0].id);
+ }
+ }
+});
+
var document: docDB.NewDocument<{ val: string }> = {
id: '10'
};
@@ -51,6 +102,16 @@ docDBClient.createDocument('collection', document, undefined, (error, result) =>
}
else {
console.log('Created document: ' + result.id);
+
+ docDBClient.replaceDocument(result._self, document, undefined, (subError, subResult) => {
+
+ if (subError) {
+ throw new Error(subError.body);
+ }
+ else {
+ console.log('Replaced document: ' + subResult.id);
+ }
+ })
}
});
@@ -62,5 +123,4 @@ docDBClient.executeStoredProcedure('procedure', [10, 'foo'], (error, result) =>
else {
console.log('Procedure result: ' + result);
}
-});
-
+});
\ No newline at end of file
diff --git a/documentdb/documentdb.d.ts b/documentdb/documentdb.d.ts
index 581543508..01cc49342 100644
--- a/documentdb/documentdb.d.ts
+++ b/documentdb/documentdb.d.ts
@@ -1,6 +1,6 @@
// Type definitions for DocumentDB
// Project: https://github.com/Azure/azure-documentdb-node
-// Definitions by: Noel Abrahams
+// Definitions by: Noel Abrahams , Brett Gutstein
// Definitions: https://github.com/borisyankov/DefinitelyTyped/documentdb
declare module 'documentdb' {
@@ -52,7 +52,25 @@ declare module 'documentdb' {
/** Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned. */
disableAutomaticIdGeneration?: boolean;
}
-
+
+ /** The Sql query parameter. */
+ interface SqlParameter {
+ /** The name of the parameter. */
+ name: string;
+
+ /** The value of the parameter. */
+ value: any;
+ }
+
+ /** The Sql query specification. */
+ interface SqlQuerySpec {
+ /** The body of the query. */
+ query: string;
+
+ /** The array of SqlParameters. */
+ parameters: SqlParameter[];
+ }
+
/** Represents the error object returned from a failed query. */
interface QueryError {
@@ -130,6 +148,13 @@ declare module 'documentdb' {
interface ProcedureMeta extends AbstractMeta {
body: string;
}
+
+ /** Represents the meta data for a trigger. */
+ interface TriggerMeta extends AbstractMeta {
+ body: string;
+ triggerType: string;
+ triggerOperation: string;
+ }
/** An object that is used for authenticating requests and must contains one of the options. */
export interface AuthOptions {
@@ -150,6 +175,18 @@ declare module 'documentdb' {
/** The function representing the stored procedure. */
body(...params: any[]): void;
}
+
+ /** Represents a DocumentDB trigger. */
+ export interface Trigger extends UniqueId {
+ /** The type of the trigger. Should be either 'pre' or 'post'. */
+ triggerType: string;
+
+ /** The trigger operation. Should be one of 'all', 'create', 'update', 'delete', or 'replace'. */
+ triggerOperation: string;
+
+ /** The function representing the trigger. */
+ body(...params: any[]): void;
+ }
/** Represents DocumentDB collection. */
export interface Collection extends UniqueId {
@@ -195,12 +232,9 @@ declare module 'documentdb' {
ExcludedPaths: string[];
}
-
-
/** Provides a client-side logical representation of the Azure DocumentDB database account. This client is used to configure and execute requests against the service.
*/
export class DocumentClient {
-
/**
* Constructs a DocumentClient.
* @param urlConnection - The service endpoint to use to create the client.
@@ -250,6 +284,19 @@ declare module 'documentdb' {
* @param callback - The callback for the request.
*/
public createStoredProcedure(collectionLink: string, procedure: Procedure, options: RequestOptions, callback: RequestCallback): void;
+
+ /**
+ * Create a trigger.
+ *
+ * DocumentDB supports pre and post triggers defined in JavaScript to be executed on creates, updates and deletes.
+ * For additional details, refer to the server-side JavaScript API documentation.
+ *
+ * @param collectionLink - The self-link of the collection.
+ * @param trigger - Represents the body of the trigger.
+ * @param [options] - The request options.
+ * @param callback - The callback for the request.
+ */
+ public createTrigger(collectionLink: string, trigger: Trigger, options: RequestOptions, callback: RequestCallback): void;
/**
* Create a document.
@@ -277,7 +324,7 @@ declare module 'documentdb' {
* @param [options] - The feed options.
* @returns - An instance of QueryIterator to handle reading feed.
*/
- public queryDatabases(query: string): QueryIterator;
+ public queryDatabases(query: string | SqlQuerySpec): QueryIterator;
/**
* Query the collections for the database.
@@ -286,7 +333,7 @@ declare module 'documentdb' {
* @param [options] - Represents the feed options.
* @returns - An instance of queryIterator to handle reading feed.
*/
- public queryCollections(databaseLink: string, query: string): QueryIterator;
+ public queryCollections(databaseLink: string, query: string | SqlQuerySpec): QueryIterator;
/**
* Query the storedProcedures for the collection.
@@ -295,7 +342,7 @@ declare module 'documentdb' {
* @param [options] - Represents the feed options.
* @returns - An instance of queryIterator to handle reading feed.
*/
- public queryStoredProcedures(collectionLink: string, query: string): QueryIterator;
+ public queryStoredProcedures(collectionLink: string, query: string | SqlQuerySpec): QueryIterator;
/**
* Query the documents for the collection.
@@ -304,8 +351,17 @@ declare module 'documentdb' {
* @param [options] - Represents the feed options.
* @returns - An instance of queryIterator to handle reading feed.
*/
- public queryDocuments(collectionLink: string, query: string, options?: FeedOptions): QueryIterator>;
+ public queryDocuments(collectionLink: string, query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator>;
+ /**
+ * Query the triggers for the collection.
+ * @param {string} collectionLink - The self-link of the collection.
+ * @param {SqlQuerySpec | string} query - A SQL query.
+ * @param {FeedOptions} [options] - Represents the feed options.
+ * @returns {QueryIterator} - An instance of queryIterator to handle reading feed.
+ */
+ public queryTriggers(collectionLink: string, query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;
+
/**
* Delete the document object.
* @param documentLink - The self-link of the document.
@@ -337,7 +393,16 @@ declare module 'documentdb' {
* @param callback - The callback for the request.
*/
public deleteStoredProcedure(procedureLink: string, options: RequestOptions, callback: RequestCallback): void;
-
+
+ /**
+ * Replace the document object.
+ * @param {string} documentLink - The self-link of the document.
+ * @param {object} document - Represent the new document body.
+ * @param {RequestOptions} [options] - The request options.
+ * @param {RequestCallback} callback - The callback for the request.
+ */
+ public replaceDocument(documentLink: string, document: NewDocument, options: RequestOptions, callback: RequestCallback>): void;
+
/**
* Replace the StoredProcedure object.
* @param procedureLink - The self-link of the stored procedure.
diff --git a/ember/ember.d.ts b/ember/ember.d.ts
index cd1ef6079..a1b829ddf 100644
--- a/ember/ember.d.ts
+++ b/ember/ember.d.ts
@@ -1420,7 +1420,7 @@ declare module Ember {
Creates an instance of the class.
@param arguments A hash containing values with which to initialize the newly instantiated object.
**/
- static create(args: {}): T;
+ static create(...arguments: CoreObjectArguments[]): T;
detect(obj: any): boolean;
reopen(args?: {}): T;
}
diff --git a/eq.js/eq.js.d.ts b/eq.js/eq.js.d.ts
new file mode 100644
index 000000000..198fee0f9
--- /dev/null
+++ b/eq.js/eq.js.d.ts
@@ -0,0 +1,67 @@
+// Type definitions for eq.js
+// Project: https://github.com/Snugug/eq.js
+// Definitions by: Stephen Lautier
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare var eqjs: eq.EqjsStatic;
+
+// Support AMD require
+declare module 'eqjs' {
+ export = eqjs;
+}
+
+declare module eq {
+ type AvailableElementType = HTMLElement|HTMLElement[]|NodeList|JQuery;
+
+ interface EqjsStatic {
+
+ /**
+ * List of all nodes.
+ */
+ nodes: EqjsNodesTable;
+
+ /**
+ * Number of nodes in eqjs.nodes.
+ */
+ nodesLength: number;
+
+ /**
+ * Runs through all nodes and finds their widths and points
+ * @param nodes
+ * @param callback function to use as a callback once query and nodeWrites have finished
+ */
+ query(nodes: AvailableElementType, callback?: Function): void;
+
+ /**
+ * Refreshes the list of nodes for eqjs to work with
+ */
+ refreshNodes(): void;
+
+ /**
+ * Sorts a simple object (key: value) by value and returns a sorted object.
+ * @param obj e.g. "small: 380, medium: 490, large: 600"
+ * @returns {}
+ */
+ sortObj(obj: string): EqjsKeyValuePair[];
+
+ /**
+ * Runs through all nodes and writes their eq status.
+ * @param nodes An array or NodeList of nodes to query
+ * @returns {}
+ */
+ nodeWrites(nodes?: AvailableElementType): void;
+ }
+
+ interface EqjsKeyValuePair {
+ key: string;
+ value: number;
+ }
+
+ interface EqjsNodesTable {
+ [index: number]: HTMLElement;
+ }
+
+}
+
+// Support jQuery selectors.
+interface JQuery { }
\ No newline at end of file
diff --git a/eq.js/eq.js.tests.ts b/eq.js/eq.js.tests.ts
new file mode 100644
index 000000000..1113604f2
--- /dev/null
+++ b/eq.js/eq.js.tests.ts
@@ -0,0 +1,28 @@
+///
+///
+
+var nodes = document.getElementsByClassName(".test-container");
+var node = document.getElementById("#test-container");
+var $nodes = $(".selector");
+
+eqjs.query(node);
+eqjs.query(node, () => { });
+eqjs.query(nodes);
+eqjs.query($nodes);
+
+var nodesCount: number = eqjs.nodesLength;
+
+eqjs.refreshNodes();
+
+eqjs.nodeWrites();
+eqjs.nodeWrites(node);
+eqjs.nodeWrites(nodes);
+eqjs.nodeWrites($nodes);
+
+var sortMap = eqjs.sortObj("small: 380, medium: 490, large: 600");
+var sortFirstKey = sortMap[0].key;
+var sortFirstValue = sortMap[0].value;
+
+var nodesMap = eqjs.nodes;
+
+var ele: HTMLElement = nodesMap[1];
diff --git a/express/express-tests.ts b/express/express-tests.ts
index 76fa4da0d..22ae73e72 100644
--- a/express/express-tests.ts
+++ b/express/express-tests.ts
@@ -6,6 +6,9 @@ var app = express();
app.engine('jade', require('jade').__express);
app.engine('html', require('ejs').renderFile);
+express.static.mime.define({
+ 'application/fx': ['fx']
+});
app.use('/static', express.static(__dirname + '/public'));
// simple logger
diff --git a/express/express.d.ts b/express/express.d.ts
index 0bd42b82f..f6e692861 100644
--- a/express/express.d.ts
+++ b/express/express.d.ts
@@ -11,6 +11,7 @@
=============================================== */
///
+///
declare module Express {
@@ -24,6 +25,7 @@ declare module Express {
declare module "express" {
import http = require('http');
+ import serveStatic = require('serve-static');
function e(): e.Express;
@@ -1067,31 +1069,7 @@ declare module "express" {
response: Response;
}
- /**
- * Static:
- *
- * Static file server with the given `root` path.
- *
- * Examples:
- *
- * var oneDay = 86400000;
- *
- * connect()
- * .use(connect.static(__dirname + '/public'))
- *
- * connect()
- * .use(connect.static(__dirname + '/public', { maxAge: oneDay }))
- *
- * Options:
- *
- * - `maxAge` Browser cache maxAge in milliseconds. defaults to 0
- * - `hidden` Allow transfer of hidden files. defaults to false
- * - `redirect` Redirect to trailing "/" when the pathname is a dir. defaults to true
- *
- * @param root
- * @param options
- */
- function static(root: string, options?: any): RequestHandler;
+ var static: typeof serveStatic;
}
export = e;
diff --git a/eyes/eyes-tests.ts b/eyes/eyes-tests.ts
index 3182195dd..156054ba1 100644
--- a/eyes/eyes-tests.ts
+++ b/eyes/eyes-tests.ts
@@ -26,4 +26,9 @@ var options = {
hideFunctions: true,
stream: process.stdout,
maxLength: 120
-}
\ No newline at end of file
+}
+
+var result = eyes.inspector(testObj)
+
+
+
diff --git a/eyes/eyes.d.ts b/eyes/eyes.d.ts
index 091916821..8c731513a 100644
--- a/eyes/eyes.d.ts
+++ b/eyes/eyes.d.ts
@@ -13,7 +13,7 @@ declare module "eyes"
export function inspect(thing:any, label?:string): void;
export interface InspectorFunction {
- (thing:any, label?:string): void;
+ (thing:any, label?:string): string;
}
export interface EyesOptions
diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts
index de8dba6b8..8d3da2620 100644
--- a/hapi/hapi.d.ts
+++ b/hapi/hapi.d.ts
@@ -241,10 +241,9 @@ declare module "hapi" {
/** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */
(result: string|number|boolean|Buffer|stream.Stream | Promise | T): Response;
- //////// Returns control back to the framework without setting a response. If called in the handler, the response defaults to an empty payload with status code 200.
- //////
- ////// The data argument is only used for passing back authentication data and is ignored elsewhere.
- ////////continue(credentialData?: any): void;
+ /** Returns control back to the framework without setting a response. If called in the handler, the response defaults to an empty payload with status code 200.
+ * The data argument is only used for passing back authentication data and is ignored elsewhere. */
+ continue(credentialData?: any): void;
/** Transmits a file from the file system. The 'Content-Type' header defaults to the matching mime type based on filename extension. The response flow control rules do not apply. */
file(
diff --git a/jasmine-jquery/jasmine-jquery.d.ts b/jasmine-jquery/jasmine-jquery.d.ts
index dcff2d12c..903e3f7e2 100644
--- a/jasmine-jquery/jasmine-jquery.d.ts
+++ b/jasmine-jquery/jasmine-jquery.d.ts
@@ -9,17 +9,17 @@
declare function sandbox(attributes?: any): string;
declare function readFixtures(...uls: string[]): string;
-declare function preloadFixtures(...uls: string[]);
-declare function loadFixtures(...uls: string[]);
-declare function appendLoadFixtures(...uls: string[]);
+declare function preloadFixtures(...uls: string[]) : void;
+declare function loadFixtures(...uls: string[]): void;
+declare function appendLoadFixtures(...uls: string[]): void;
declare function setFixtures(html: string): string;
-declare function appendSetFixtures(html: string);
+declare function appendSetFixtures(html: string) : void;
-declare function preloadStyleFixtures(...uls: string[]);
-declare function loadStyleFixtures(...uls: string[]);
-declare function appendLoadStyleFixtures(...uls: string[]);
-declare function setStyleFixtures(html: string);
-declare function appendSetStyleFixtures(html: string);
+declare function preloadStyleFixtures(...uls: string[]) : void;
+declare function loadStyleFixtures(...uls: string[]) : void;
+declare function appendLoadStyleFixtures(...uls: string[]) : void;
+declare function setStyleFixtures(html: string) : void;
+declare function appendSetStyleFixtures(html: string) : void;
declare function loadJSONFixtures(...uls: string[]): jasmine.JSONFixtures;
declare function getJSONFixture(url: string): any;
@@ -37,47 +37,47 @@ declare module jasmine {
fixturesPath: string;
containerId: string;
set(html: string): string;
- appendSet(html: string);
- preload(...uls: string[]);
- load(...uls: string[]);
- appendLoad(...uls: string[]);
+ appendSet(html: string): void;
+ preload(...uls: string[]): void;
+ load(...uls: string[]): void;
+ appendLoad(...uls: string[]): void;
read(...uls: string[]): string;
- clearCache();
- cleanUp();
+ clearCache(): void;
+ cleanUp(): void;
sandbox(attributes?: any): string;
- createContainer_(html: string);
- addToContainer_(html: string);
+ createContainer_(html: string) : string;
+ addToContainer_(html: string): void;
getFixtureHtml_(url: string): string;
- loadFixtureIntoCache_(relativeUrl: string);
+ loadFixtureIntoCache_(relativeUrl: string): void;
makeFixtureUrl_(relativeUrl: string): string;
- proxyCallTo_(methodName: string, passedArguments): any;
+ proxyCallTo_(methodName: string, passedArguments: any): any;
}
interface StyleFixtures {
fixturesPath: string;
set(html: string): string;
- appendSet(html: string);
- preload(...uls: string[]);
- load(...uls: string[]);
- appendLoad(...uls: string[]);
+ appendSet(html: string): void;
+ preload(...uls: string[]) : void;
+ load(...uls: string[]) : void;
+ appendLoad(...uls: string[]) : void;
read_(...uls: string[]): string;
- clearCache();
- cleanUp();
- createStyle_(html: string);
+ clearCache() : void;
+ cleanUp() : void;
+ createStyle_(html: string) : void;
getFixtureHtml_(url: string): string;
- loadFixtureIntoCache_(relativeUrl: string);
+ loadFixtureIntoCache_(relativeUrl: string) : void;
makeFixtureUrl_(relativeUrl: string): string;
- proxyCallTo_(methodName: string, passedArguments): any;
+ proxyCallTo_(methodName: string, passedArguments: any): any;
}
interface JSONFixtures {
fixturesPath: string;
- load(...uls: string[]);
+ load(...uls: string[]): void;
read(...uls: string[]): string;
- clearCache();
+ clearCache(): void;
getFixtureData_(url: string): any;
- loadFixtureIntoCache_(relativeUrl: string);
- proxyCallTo_(methodName: string, passedArguments): any;
+ loadFixtureIntoCache_(relativeUrl: string): void;
+ proxyCallTo_(methodName: string, passedArguments: any): any;
}
interface Matchers {
@@ -105,7 +105,7 @@ declare module jasmine {
* // returns true
* expect($('')).toHaveCss({margin: "10px"})
*/
- toHaveCss(css: Object): boolean;
+ toHaveCss(css: any): boolean;
/**
* Checks if DOM element is visible.
@@ -162,7 +162,7 @@ declare module jasmine {
* @param attributeName Name of the attribute to check
* @param expectedAttributeValue Expected attribute value
*/
- toHaveAttr(attributeName: string, expectedAttributeValue?): boolean;
+ toHaveAttr(attributeName: string, expectedAttributeValue? : any): boolean;
/**
* Check if DOM element contains a property and, optionally, if the value of the property is equal to the expected one.
@@ -170,7 +170,7 @@ declare module jasmine {
* @param propertyName Property name to check
* @param expectedPropertyValue Expected property value
*/
- toHaveProp(propertyName: string, expectedPropertyValue?): boolean;
+ toHaveProp(propertyName: string, expectedPropertyValue? : any): boolean;
/**
* Check if DOM element has the given Id
@@ -223,14 +223,14 @@ declare module jasmine {
* // returns true
* expect($('')).toHaveValue('some text')
*/
- toHaveValue(value): boolean;
+ toHaveValue(value : string): boolean;
/**
* Check if DOM element has the given data.
* This can only be applied for element on with jQuery data(key) can be called.
*
*/
- toHaveData(key, expectedValue): boolean;
+ toHaveData(key : string, expectedValue : string): boolean;
toBe(selector: JQuery): boolean;
/**
@@ -295,7 +295,7 @@ declare module jasmine {
* @example
* expect($form).toHandleWith("submit", yourSubmitCallback)
*/
- toHandleWith(eventName: string, eventHandler): boolean;
+ toHandleWith(eventName: string, eventHandler : JQueryCallback): boolean;
/**
* Checks if event was triggered.
@@ -381,7 +381,7 @@ declare module jasmine {
wasTriggeredWith(selector: string, eventName: string, expectedArgs: any, env: jasmine.Env): boolean;
wasPrevented(selector: string, eventName: string): boolean;
wasStopped(selector: string, eventName: string): boolean;
- cleanUp();
+ cleanUp() : void;
}
var JQuery: JasmineJQuery;
diff --git a/joData/joData-tests.ts b/joData/joData-tests.ts
new file mode 100644
index 000000000..62dd1569c
--- /dev/null
+++ b/joData/joData-tests.ts
@@ -0,0 +1,192 @@
+///
+
+var query = new jo('http://test.com');
+
+// Base URI
+query.baseUri;
+
+// To string
+query.toString();
+
+// Order by
+query.orderBy('PropertyName');
+query.orderBy('PropertyName').asc();
+query.orderBy('PropertyName').desc();
+query.orderBy('PropertyName').asc().desc();
+query.resetOrderBy();
+query.setOrderByDefault('PropertyName');
+query.toggleOrderBy('CustomerId'); // TODO Example with callback.
+
+query
+ .setOrderByDefault('p1', 'desc')
+ .orderBy('p2')
+ .asc();
+
+// Top
+query.top(10);
+query.resetTop();
+query.setTopDefault(5);
+query
+ .setTopDefault(5)
+ .top(10);
+
+// Skip
+query.skip(5);
+query.resetSkip();
+query.setSkipDefault(5);
+query
+ .setSkipDefault(5)
+ .skip(10);
+
+// Select
+query.select(['Property1', 'Property2']);
+query.resetSelect();
+query.setSelectDefault(['CustomerId', 'CustomerName']);
+query
+ .setSelectDefault(['CustomerId', 'CustomerName'])
+ .select(['CustomerId', 'CustomerName', 'Address']);
+
+// Expand
+query.expand('Customer');
+query.resetExpand();
+query.setExpandDefault('Customer');
+query
+ .setExpandDefault('Customer')
+ .expand('Product');
+
+// Format
+query.format().atom();
+query.format().xml();
+query.format().json();
+query.format().custom('text/csv');
+
+query.formatDefault().atom();
+
+query
+ .formatDefault()
+ .atom()
+ .format()
+ .json();
+
+query.resetFormat();
+
+// Inlinecount
+query.inlineCount().allPages();
+query.inlineCount().none();
+
+query.inlineCountDefault().allPages();
+
+query
+ .inlineCountDefault()
+ .allPages()
+ .inlineCount()
+ .none();
+
+query.resetInlineCount();
+
+// Filter
+var clause = new jo.FilterClause('PropertyName');
+clause.eq(5);
+query.filter(clause);
+
+query
+ .andFilter(new jo.FilterClause('Property1').eq(5))
+ .andFilter(new jo.FilterClause('Property2').eq(10));
+
+query
+ .orFilter(new jo.FilterClause('Property1').eq(5))
+ .orFilter(new jo.FilterClause('Property2').eq(10));
+
+query
+ .filter(new jo.FilterClause('p1').eq(1))
+ .andFilter(new jo.FilterClause('p2').eq(5))
+ .orFilter(new jo.FilterClause('p3').eq(10));
+
+query.removeFilter('CustomerName');
+
+var clause = new jo.FilterClause('CustomerId');
+clause.isEmpty();
+
+var clause = new jo.FilterClause('CustomerId').eq(1);
+clause.isEmpty();
+
+query.andFilter(new jo.FilterClause('Status').eq('Pending'));
+query.captureFilter();
+query.resetToCapturedFilter();
+query.resetFilter();
+
+// Casts
+query.filter(new jo.FilterClause('DateAdded').eq(jo.datetime('2013-03-01')));
+query.filter(new jo.FilterClause('CustomerId').eq(jo.guid('3F2504E0-4F89-11D3-9A0C-0305E82C3301')));
+query.filter(new jo.FilterClause('Price').eq(jo.decimal(24.97)));
+query.filter(new jo.FilterClause('Price').eq(jo.single(24.97)));
+query.filter(new jo.FilterClause('Price').eq(jo.double(24.97)));
+
+// Logical Operators
+query.filter(new jo.FilterClause('PropertyName').eq('test'));
+query.filter(new jo.FilterClause('PropertyName').eq(10));
+query.filter(new jo.FilterClause('CustomerName').not().eq('bob'));
+query.filter(new jo.FilterClause('CustomerName').not().endswith('bob'));
+
+// Precedence Groups
+var group = new jo.PrecedenceGroup(new jo.FilterClause('Name').eq('Bob'));
+query.filter(group);
+
+var group2 = new jo.PrecedenceGroup(new jo.FilterClause('Name').eq('Bob')).orFilter(new jo.FilterClause('Name').eq('George'));
+query.filter(group2);
+
+query
+ .filter(new jo.FilterClause('Id').eq(1))
+ .andFilter(new jo.PrecedenceGroup(new jo.FilterClause('Name').startswith('a').eq(true))
+ .orFilter(new jo.FilterClause('Name').startswith('b').eq(true)));
+
+// Setting filter defaults
+query.defaultFilter(new jo.FilterClause('Id').eq(1));
+query
+ .defaultFilter(new jo.FilterClause('Id').eq(1))
+ .filter(new jo.FilterClause('Name').eq('bob'));
+query
+ .defaultFilter(new jo.FilterClause('Id').eq(1))
+ .filter(new jo.FilterClause('Name').eq('bob'));
+query.resetFilter();
+
+// Arithmetic Methods
+query.filter(new jo.FilterClause('PropertyName').add(5).eq(10));
+
+// String Functions
+query.filter(new jo.FilterClause('PropertyName').substringof('test').eq(true));
+query.filter(new jo.FilterClause('PropertyName').toLower().substringof('test').eq(true));
+query.filter(new jo.FilterClause('PropertyName').endswith('test').eq(true));
+query.filter(new jo.FilterClause('PropertyName').startswith('test').eq(true));
+query.filter(new jo.FilterClause('PropertyName').length().eq(10));
+query.filter(new jo.FilterClause('PropertyName').indexof('test').eq(1));
+query.filter(new jo.FilterClause('PropertyName').replace('test', 'bob').eq('bob'));
+query.filter(new jo.FilterClause('PropertyName').substring(1).eq('test'));
+query.filter(new jo.FilterClause('PropertyName').substring(1,2).eq('test'));
+query.filter(new jo.FilterClause('PropertyName').toLower().eq('test'));
+query.filter(new jo.FilterClause('PropertyName').toUpper().eq('TEST'));
+query.filter(new jo.FilterClause('PropertyName').trim().eq('test'));
+
+// Concat
+query.filter(new jo.FilterClause().Concat(new jo.Concat('FirstName', 'LastName')).eq('BobSmith'));
+query.filter(new jo.FilterClause().Concat(new jo.Concat(new jo.Concat('City', jo.literal(', ')), 'State')).eq('Birmingham, Alabama'));
+
+// Date Functions
+query.filter(new jo.FilterClause('Birthday').day().eq(2));
+query.filter(new jo.FilterClause('Birthday').hour().eq(2));
+query.filter(new jo.FilterClause('Birthday').minute().eq(2));
+query.filter(new jo.FilterClause('Birthday').month().eq(2));
+query.filter(new jo.FilterClause('Birthday').second().eq(2));
+query.filter(new jo.FilterClause('Birthday').year().eq(2));
+
+// Math Functions
+query.filter(new jo.FilterClause('Price').round().eq(2));
+query.filter(new jo.FilterClause('Price').floor().eq(2));
+query.filter(new jo.FilterClause('Price').ceiling().eq(2));
+
+// Saving Local
+query.saveLocal();
+jo.loadLocal();
+
+query.saveLocal("key");
+jo.loadLocal("key");
\ No newline at end of file
diff --git a/joData/joData.d.ts b/joData/joData.d.ts
new file mode 100644
index 000000000..f2d6ce412
--- /dev/null
+++ b/joData/joData.d.ts
@@ -0,0 +1,229 @@
+// Type definitions for joData v1.1
+// Project: https://github.com/mccow002/joData
+// Definitions by: Chris Wrench
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare class jo
+{
+ constructor(baseUri: string);
+
+ baseUri: string;
+ ExpandSettings: jo.ExpandSettings;
+ FilterSettings: jo.InlineCountSettings;
+ FormatSettings: jo.FormatSettings;
+ InlineCountSettings: jo.InlineCountSettings;
+ OrderBySettings: jo.OrderBySettings;
+ SelectSettings: jo.SelectSettings;
+ SkipSettings: jo.SkipSettings;
+ TopSettings: jo.TopSettings;
+
+ currentHashRoute: string;
+ updateHashRoute: (hashRoute: string) => void;
+
+ // Order by
+ setOrderByDefault(property: string, order?: string): jo;
+ toggleOrderBy(property: string, callback?: Function): jo;
+ orderBy(property: string): jo;
+ desc(): jo;
+ asc(): jo;
+ resetOrderBy(): jo;
+
+ // Top
+ setTopDefault(top: number): jo;
+ top(top: number): jo;
+ resetTop(): jo;
+
+ // Skip
+ setSkipDefault(skip: number): jo;
+ skip(skip: number): jo;
+ resetSkip(): jo;
+
+ // Select
+ setSelectDefault(select: string[]): jo;
+ select(select: string[]): jo;
+ resetSelect(): jo;
+
+ // Expand
+ setExpandDefault(expand: string): jo;
+ expand(expand: string): jo;
+ resetExpand(): jo;
+
+ // Format
+ format(): jo.FormatOptions;
+ formatDefault(): jo.FormatOptions;
+ resetFormat(): void;
+
+ // Inline count
+ inlineCount(): jo.InlineCountOptions;
+ inlineCountDefault(): jo.InlineCountOptions;
+ resetInlineCount(): void;
+
+ // Filter
+ filter(filterClause: jo.FilterClause|jo.PrecedenceGroup): jo;
+ andFilter(filterClause: jo.FilterClause|jo.PrecedenceGroup): jo;
+ orFilter(filterClause: jo.FilterClause|jo.PrecedenceGroup): jo;
+ removeFilter(property: string): jo;
+ captureFilter(): void;
+ resetFilter(): jo;
+ resetToCapturedFilter(): jo;
+ defaultFilter(filterClause: jo.FilterClause): jo;
+ defaultAndFilter(filterClause: jo.FilterClause): jo;
+ defaultOrFilter(filterClause: jo.FilterClause): jo;
+
+ // Casts
+ static literal: (stringLiteral: string) => string;
+ static datetime: (stringLiteral: string) => string;
+ static guid: (stringLiteral: string) => string;
+ static decimal: (stringLiteral: number) => string;
+ static double: (stringLiteral: number) => string;
+ static single: (stringLiteral: number) => string;
+
+ toString: () => string;
+ toJson: () => string;
+ saveLocal: (key?: string) => void;
+
+ static loadLocal: (key?: string) => jo;
+}
+
+declare module jo {
+ interface FormatOptions {
+ atom(): jo;
+ custom(value: string): jo;
+ json(): jo;
+ xml(): jo;
+ }
+
+ interface InlineCountOptions {
+ allPages(): jo;
+ none(): jo;
+ }
+
+ export class FilterClause {
+ constructor();
+ constructor(property: string);
+
+ toString(): string;
+ isEmpty(): Boolean;
+
+ Property: string;
+ Components: string[];
+ IsClauseEmpty: Boolean;
+ PropertyIncluded: Boolean;
+ UsingNot: Boolean;
+ Value: any;
+ FuncReturnType: any;
+ transformFunc: Function;
+
+ // Logical operators
+ eq(value: string|number|boolean): jo.FilterClause;
+ ne(value: string|number|boolean): jo.FilterClause;
+ gt(value: string|number|boolean): jo.FilterClause;
+ ge(value: string|number|boolean): jo.FilterClause;
+ lt(value: string|number|boolean): jo.FilterClause;
+ le(value: string|number|boolean): jo.FilterClause;
+ not(): jo.FilterClause;
+
+ // Arithmetic methods
+ add(amount: number): jo.FilterClause;
+ sub(amount: number): jo.FilterClause;
+ mul(amount: number): jo.FilterClause;
+ div(amount: number): jo.FilterClause;
+ mod(amount: number): jo.FilterClause;
+
+ // String functions
+ substringof(value: string): jo.FilterClause;
+ substring(position: number, length?: number): jo.FilterClause;
+ toLower(): jo.FilterClause;
+ toUpper(): jo.FilterClause;
+ trim(): jo.FilterClause;
+ endswith(value: string): jo.FilterClause;
+ startswith(value: string): jo.FilterClause;
+ length(): jo.FilterClause;
+ indexof(value: string): jo.FilterClause;
+ replace(find: string, replace: string): jo.FilterClause;
+
+ // Concat
+ Concat(concat: jo.Concat): jo.FilterClause;
+
+ // Date functions
+ day(): jo.FilterClause;
+ hour(): jo.FilterClause;
+ minute(): jo.FilterClause;
+ month(): jo.FilterClause;
+ second(): jo.FilterClause;
+ year(): jo.FilterClause;
+
+ // Math functions
+ round(): jo.FilterClause;
+ floor(): jo.FilterClause;
+ ceiling() : jo.FilterClause;
+ }
+
+ // Precedence groups
+ export class PrecedenceGroup {
+ constructor(filterClause: jo.FilterClause)
+ andFilter(filterClause: jo.FilterClause): jo.FilterClause;
+ orFilter(filterClause: jo.FilterClause): jo.FilterClause;
+ }
+
+ // Concat
+ export class Concat {
+ constructor(value1: string|jo.Concat, value2: string|jo.Concat)
+ LeftSide: string|jo.Concat;
+ RightSide: string|jo.Concat;
+ toString(): string;
+ }
+
+ // TODO What is the most appropriate place for these interfaces?
+ // They are only required by the `jo` class.
+ interface ISettings {
+ toString: () => string;
+ reset: () => void;
+ isSet: () => Boolean;
+ }
+
+ interface OrderBySettings extends ISettings {
+ Property: string;
+ Order: string;
+ DefaultProperty:string;
+ DefaultOrder: string;
+ }
+
+ interface TopSettings extends ISettings {
+ Top: number;
+ DefaultTop: number;
+ }
+
+ interface SkipSettings extends ISettings {
+ Skip: number;
+ DefaultSkip: number;
+ }
+
+ interface SelectSettings extends ISettings {
+ Select: string[];
+ DefaultSelect: string[];
+ }
+
+ interface ExpandSettings extends ISettings {
+ Expand: string;
+ DefaultExpand: string;
+ }
+
+ interface FormatSettings extends ISettings {
+ Format: string;
+ DefaultFormat: string;
+ }
+
+ interface InlineCountSettings extends ISettings {
+ InlineCount: string;
+ DefaultInlineCount: string;
+ }
+
+ interface FilterSettings extends ISettings {
+ Filters: FilterClause[];
+ DefaultFilters: FilterClause[];
+ CapturedFilter: FilterClause[];
+ fullReset: () => void;
+ loadFromJson: (filterSettings: any) => void;
+ }
+}
diff --git a/js-cookie/js-cookie-tests.ts b/js-cookie/js-cookie-tests.ts
new file mode 100644
index 000000000..819f42903
--- /dev/null
+++ b/js-cookie/js-cookie-tests.ts
@@ -0,0 +1,68 @@
+///
+
+// Create a cookie, valid across the entire site
+Cookies.set('name', 'value');
+
+// Create a cookie that expires 7 days from now, valid across the entire site
+Cookies.set('name', 'value', { expires: 7 });
+
+// Create an expiring cookie, valid to the path of the current page
+Cookies.set('name', 'value', { expires: 7, path: '' });
+
+// Read cookie
+Cookies.get('name'); // => 'value'
+Cookies.get('nothing'); // => undefined
+
+// Read all available cookies
+Cookies.get(); // => { name: 'value' }
+
+// Delete cookie
+Cookies.remove('name');
+
+// Delete a cookie valid to the path of the current page
+Cookies.set('name', 'value', { path: '' });
+Cookies.remove('name'); // fail!
+Cookies.remove('name', { path: '' }); // removed!
+
+// Assign the js-cookie api to a different variable
+// and restore the original "window.Cookies"
+var Cookies2 = Cookies.noConflict();
+Cookies2.set('name', 'value');
+
+// When creating a cookie you can pass an Array or Object Literal
+// instead of a string in the value. If you do so, js-cookie will
+// store the string representation of the object according to JSON.stringify
+Cookies.set('name', { foo: 'bar' });
+
+// When reading a cookie with the Cookies.getJSON api, you receive
+// the parsed representation of the string stored in the cookie
+// according to JSON.parse
+Cookies.getJSON('name'); // => { foo: 'bar' }
+
+// Define the domain where the cookie is available
+Cookies.set('name', 'value', { domain: 'sub.domain.com' });
+Cookies.get('name'); // => undefined (need to read at 'sub.domain.com')
+
+// Indicate that the cookie transmission requires (https)
+Cookies.set('name', 'value', { secure: true });
+Cookies.get('name'); // => 'value'
+Cookies.remove('name', { secure: true });
+
+document.cookie = 'escaped=%u5317';
+document.cookie = 'default=%E5%8C%97';
+var cookies = Cookies.withConverter(function (value, name) {
+ if ( name === 'escaped' ) {
+ return decodeURIComponent(value);
+ }
+});
+
+cookies.get('escaped'); // 北
+cookies.get('default'); // 北
+cookies.get(); // { escaped: '北', default: '北' }
+
+// To remove, set or declare defaults to the path of the
+// current page, you just need to declare it as empty:
+Cookies.defaults.path = '';
+
+// Deleting the property will fallback to the path: / internally:
+delete Cookies.defaults.path;
diff --git a/js-cookie/js-cookie.d.ts b/js-cookie/js-cookie.d.ts
new file mode 100644
index 000000000..fc3e95c02
--- /dev/null
+++ b/js-cookie/js-cookie.d.ts
@@ -0,0 +1,92 @@
+// Type definitions for js-cookie v2.0
+// Project: https://github.com/js-cookie/js-cookie
+// Definitions by: Theodore Brown
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module Cookies {
+ interface CookieAttributes {
+ /**
+ * Define when the cookie will be removed. Value can be a Number
+ * which will be interpreted as days from time of creation or a
+ * Date instance. If omitted, the cookie becomes a session cookie.
+ */
+ expires?: number | Date;
+
+ /**
+ * Define the path where the cookie is available. Defaults to '/'
+ */
+ path?: string;
+
+ /**
+ * Define the domain where the cookie is available. Defaults to
+ * the domain of the page where the cookie was created.
+ */
+ domain?: string;
+
+ /**
+ * A Boolean indicating if the cookie transmission requires a
+ * secure protocol (https). Defaults to false.
+ */
+ secure?: boolean;
+ }
+
+ interface CookiesStatic {
+ /**
+ * Allows default cookie attributes to be accessed, changed, or reset
+ */
+ defaults: CookieAttributes;
+
+ /**
+ * Create a cookie
+ */
+ set(name: string, value: string | any, options?: CookieAttributes): void;
+
+ /**
+ * Read cookie
+ */
+ get(name: string): string;
+
+ /**
+ * Read all available cookies
+ */
+ get(): {[key: string]: string};
+
+ /**
+ * Returns the parsed representation of the string
+ * stored in the cookie according to JSON.parse
+ */
+ getJSON(name: string): any;
+
+ /**
+ * Returns the parsed representation of
+ * all cookies according to JSON.parse
+ */
+ getJSON(): {[key: string]: any};
+
+ /**
+ * Delete cookie
+ */
+ remove(name: string, options?: CookieAttributes): void;
+
+ /**
+ * If there is any danger of a conflict with the namespace Cookies,
+ * the noConflict method will allow you to define a new namespace
+ * and preserve the original one. This is especially useful when
+ * running the script on third party sites e.g. as part of a widget
+ * or SDK. Note: The noConflict method is not necessary when using
+ * AMD or CommonJS, thus it is not exposed in those environments.
+ */
+ noConflict(): CookiesStatic;
+
+ /**
+ * Create a new instance of the api that overrides the default
+ * decoding implementation. All methods that rely in a proper
+ * decoding to work, such as Cookies.remove() and Cookies.get(),
+ * will run the converter first for each cookie. The returned
+ * string will be used as the cookie value.
+ */
+ withConverter(converter: (value: string, name: string) => string): CookiesStatic;
+ }
+}
+
+declare var Cookies: Cookies.CookiesStatic;
diff --git a/keypress/keypress.d.ts b/keypress/keypress.d.ts
index bd831d5b0..f3eada39d 100644
--- a/keypress/keypress.d.ts
+++ b/keypress/keypress.d.ts
@@ -16,12 +16,12 @@ declare module Keypress {
is_solitary: boolean;
is_sequence: boolean;
}
-
+
interface Combo {
keys: string;
- on_keydown: () => any;
- on_keyup: () => any;
- on_release: () => any;
+ on_keydown: (event?: KeyboardEvent, count?: number) => any;
+ on_keyup: (event?: KeyboardEvent) => any;
+ on_release: (event?: KeyboardEvent) => any;
this: Element;
prevent_default: boolean;
prevent_repeat: boolean;
@@ -31,14 +31,14 @@ declare module Keypress {
is_sequence: boolean;
is_solitary: boolean;
}
-
+
interface Listener {
new(element: Element, defaults: ListenerDefaults): Listener;
new(element: Element): Listener;
new(): Listener;
- simple_combo(keys: string, on_keydown_callback: () => any): void;
- counting_combo(keys: string, on_count_callback: () => any): void;
- sequence_combo(keys: string, callback: () => any): void;
+ simple_combo(keys: string, on_keydown_callback: (event?: KeyboardEvent, count?: number) => any): void;
+ counting_combo(keys: string, on_count_callback: (event?: KeyboardEvent, count?: number) => any): void;
+ sequence_combo(keys: string, callback: (event?: KeyboardEvent, count?: number) => any): void;
register_combo(combo: Combo): void;
unregister_combo(combo: Combo): void;
unregister_combo(keys: string): void;
@@ -50,7 +50,7 @@ declare module Keypress {
listen(): void;
stop_listening(): void;
}
-
+
interface Keypress {
Listener: Listener;
}
diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts
index 6dcd0ce14..7a96392b9 100755
--- a/leaflet/leaflet.d.ts
+++ b/leaflet/leaflet.d.ts
@@ -3448,7 +3448,7 @@ declare module L {
declare module L {
- export interface PolylineOptions {
+ export interface PolylineOptions extends PathOptions {
/**
* How much to simplify the polyline on each zoom level. More means better performance
diff --git a/lockfile/lockfile-tests.ts b/lockfile/lockfile-tests.ts
index 49aa423d9..9ebb956da 100644
--- a/lockfile/lockfile-tests.ts
+++ b/lockfile/lockfile-tests.ts
@@ -9,6 +9,9 @@ var path: string;
var opts: lockfile.Options;
var callback: (err: Error) => {
+};
+var callback2: (err: Error, isLocked: boolean) => {
+
};
opts = {
@@ -25,7 +28,7 @@ lockfile.lockSync(path, opts);
lockfile.unlock(path, callback);;
lockfile.unlockSync(path);
-lockfile.check(path, opts, callback);
-lockfile.check(path, callback);
+lockfile.check(path, opts, callback2);
+lockfile.check(path, callback2);
bool = lockfile.checkSync(path, opts);
diff --git a/lockfile/lockfile.d.ts b/lockfile/lockfile.d.ts
index 99dfbe28d..1f3acdebc 100644
--- a/lockfile/lockfile.d.ts
+++ b/lockfile/lockfile.d.ts
@@ -18,7 +18,7 @@ declare module 'lockfile' {
export function unlock(path: string, callback: (err: Error) => void): void;
export function unlockSync(path: string):void;
- export function check(path: string, opts: Options, callback: (err: Error) => void): void;
- export function check(path: string, callback: (err: Error) => void): void;
+ export function check(path: string, opts: Options, callback: (err: Error, isLocked: boolean) => void): void;
+ export function check(path: string, callback: (err: Error, isLocked: boolean) => void): void;
export function checkSync(path: string, opts: Options): boolean;
}
diff --git a/loglevel/loglevel-tests.ts b/loglevel/loglevel-tests.ts
new file mode 100644
index 000000000..2c4f89733
--- /dev/null
+++ b/loglevel/loglevel-tests.ts
@@ -0,0 +1,21 @@
+///
+
+log.trace("Trace message");
+log.debug("Debug message");
+log.info("Info message");
+log.warn("Warn message");
+log.error("Error message");
+log.debug(["Hello", "world", 42]);
+
+log.setLevel(0);
+log.setLevel(0, false);
+
+log.setLevel("error");
+log.setLevel("error", false);
+
+log.setLevel(log.levels.WARN);
+log.setLevel(log.levels.WARN, false);
+
+var logging = log.noConflict();
+
+logging.error("still pretty easy");
diff --git a/loglevel/loglevel.d.ts b/loglevel/loglevel.d.ts
new file mode 100644
index 000000000..01b80b722
--- /dev/null
+++ b/loglevel/loglevel.d.ts
@@ -0,0 +1,102 @@
+// Type definitions for loglevel 1.3.1
+// Project: https://github.com/pimterry/loglevel
+// Definitions by: Stefan Profanter
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module loglevel {
+
+ /**
+ * Log levels
+ */
+ export enum levels {
+ TRACE = 0,
+ DEBUG = 1,
+ INFO = 2,
+ WARN = 3,
+ ERROR = 4,
+ SILENT = 5
+ }
+
+ /**
+ * Output trace message to console.
+ * This will also include a full stack trace
+ *
+ * @param msg any data to log to the console
+ */
+ export function trace(msg:any):void;
+
+ /**
+ * Output debug message to console including appropriate icons
+ *
+ * @param msg any data to log to the console
+ */
+ export function debug(msg:any):void;
+
+ /**
+ * Output info message to console including appropriate icons
+ *
+ * @param msg any data to log to the console
+ */
+ export function info(msg:any):void;
+
+ /**
+ * Output warn message to console including appropriate icons
+ *
+ * @param msg any data to log to the console
+ */
+ export function warn(msg:any):void;
+
+ /**
+ * Output error message to console including appropriate icons
+ *
+ * @param msg any data to log to the console
+ */
+ export function error(msg:any):void;
+
+
+ /**
+ * This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
+ * or log.error("something") will output messages, but log.info("something") will not.
+ *
+ * @param level 0=trace to 5=silent
+ * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling back
+ * to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
+ * false as the optional 'persist' second argument, persistence will be skipped.
+ */
+ export function setLevel(level:number, persist?:boolean):void;
+
+
+ /**
+ * This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
+ * or log.error("something") will output messages, but log.info("something") will not.
+ *
+ * @param level as a string, like 'error' (case-insensitive)
+ * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling back
+ * to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
+ * false as the optional 'persist' second argument, persistence will be skipped.
+ */
+ export function setLevel(level:string, persist?:boolean):void;
+
+
+ /**
+ * This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
+ * or log.error("something") will output messages, but log.info("something") will not.
+ *
+ * @param level as the value from the enum
+ * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling back
+ * to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
+ * false as the optional 'persist' second argument, persistence will be skipped.
+ */
+ export function setLevel(level:levels, persist?:boolean):void;
+
+ /**
+ * If you're using another JavaScript library that exposes a 'log' global, you can run into conflicts with loglevel.
+ * Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded
+ * onto the page. This resets to 'log' global to its value before loglevel was loaded (typically undefined), and
+ * returns the loglevel object, which you can then bind to another name yourself.
+ */
+ export function noConflict():any;
+}
+
+declare
+var log:typeof loglevel;
diff --git a/long/long-tests.ts b/long/long-tests.ts
index c1a05f576..928cc9453 100644
--- a/long/long-tests.ts
+++ b/long/long-tests.ts
@@ -1,68 +1,117 @@
///
-// --- commonjs ---
import Long = require("long");
-// --- browser ---
-//var Long = dcodeIO.Long;
-var val:dcodeIO.Long;
-var n:number;
-var b:boolean;
-var s:string;
+var val: Long;
+var n: number = 42;
+var b: boolean = true;
+var s: string = "1337";
+val = new Long(0xFFFFFFFF, 0x7FFFFFFF, true);
val = new Long(0xFFFFFFFF, 0x7FFFFFFF);
+val = new Long(0xFFFFFFFF);
-val = Long.from28Bits(0xFFFFFFF, 0xFFFFFFF, 0xFF);
-
-val = Long.fromInt(-1, true);
n = val.low;
n = val.high;
b = val.unsigned;
-s = val.toString();
val = val.add(val);
+val = val.add(n);
+val = val.add(s);
+
val = val.and(val);
-val = val.clone();
+val = val.and(n);
+val = val.and(s);
+
n = val.compare(val);
+n = val.compare(n);
+n = val.compare(s);
+
val = val.div(val);
+val = val.div(n);
+val = val.div(s);
+
b = val.equals(val);
+b = val.equals(n);
+b = val.equals(s);
+
n = val.getHighBits();
n = val.getHighBitsUnsigned();
n = val.getLowBits();
n = val.getLowBitsUnsigned();
n = val.getNumBitsAbs();
+
b = val.greaterThan(val);
+b = val.greaterThan(n);
+b = val.greaterThan(s);
+
b = val.greaterThanOrEqual(val);
+b = val.greaterThanOrEqual(n);
+b = val.greaterThanOrEqual(s);
+
b = val.isEven();
b = val.isNegative();
b = val.isOdd();
+b = val.isPositive();
b = val.isZero();
+
b = val.lessThan(val);
+b = val.lessThan(n);
+b = val.lessThan(s);
+
b = val.lessThanOrEqual(val);
+b = val.lessThanOrEqual(n);
+b = val.lessThanOrEqual(s);
+
val = val.modulo(val);
+val = val.modulo(n);
+val = val.modulo(s);
+
val = val.multiply(val);
+val = val.multiply(n);
+val = val.multiply(s);
+
val = val.negate();
val = val.not();
+
b = val.notEquals(val);
+b = val.notEquals(n);
+b = val.notEquals(s);
+
val = val.or(val);
+val = val.or(n);
+val = val.or(s);
+
val = val.shiftLeft(2);
+val = val.shiftLeft(val);
+
val = val.shiftRight(1);
+val = val.shiftRight(val);
+
val = val.shiftRightUnsigned(1);
+val = val.shiftRightUnsigned(val);
+
val = val.subtract(val);
+val = val.subtract(n);
+val = val.subtract(s);
+
n = val.toInt();
n = val.toNumber();
val = val.toSigned();
-val = val.toUnsigned();
-val = val.xor(val);
-val = Long.MAX_SIGNED_VALUE;
+s = val.toString();
+s = val.toString(n);
+
+val = val.toUnsigned();
+
+val = val.xor(val);
+val = val.xor(n);
+val = val.xor(s);
+
val = Long.MAX_UNSIGNED_VALUE;
val = Long.MAX_VALUE;
-val = Long.MIN_SIGNED_VALUE;
-val = Long.MIN_UNSIGNED_VALUE;
val = Long.MIN_VALUE;
val = Long.NEG_ONE;
val = Long.ONE;
+val = Long.UZERO;
val = Long.ZERO;
-
-
diff --git a/long/long.d.ts b/long/long.d.ts
index 3d6554017..5c3704a81 100644
--- a/long/long.d.ts
+++ b/long/long.d.ts
@@ -1,80 +1,72 @@
-// Type definitions for Long.js 1.1.2
+// Type definitions for Long.js v2.2.5
// Project: https://github.com/dcodeIO/Long.js
-// Definitions by: Toshihide Hara
+// Definitions by: Peter Kooijmans
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare module dcodeIO {
-
- interface LongStatic {
- new(low:number, high:number, unsigned?:boolean):Long;
-
- MAX_SIGNED_VALUE:Long;
- MAX_UNSIGNED_VALUE:Long;
- MAX_VALUE:Long;
- MIN_SIGNED_VALUE:Long;
- MIN_UNSIGNED_VALUE:Long;
- MIN_VALUE:Long;
- NEG_ONE:Long;
- ONE:Long;
- ZERO:Long;
-
- from28Bits(part0:number, part1:number, part2:number, unsigned?:boolean):Long;
- fromBits(lowBits:number, highBits:number, unsigned?:boolean):Long;
- fromInt(value:number, unsigned?:boolean):Long;
- fromNumber(value:number, unsigned?:boolean):Long;
- fromString(str:string, unsigned?:boolean, radix?:number):Long;
- fromString(str:string, unsigned?:number, radix?:number):Long;
- fromString(str:string, unsigned?:any, radix?:number):Long;
- }
-
- interface Long {
- high:number;
- low:number;
- unsigned:boolean;
-
- add(other:Long):Long;
- and(other:Long):Long;
- clone():Long;
- compare(other:Long):number;
- div(other:Long):Long;
- equals(other:Long):boolean;
- getHighBits():number;
- getHighBitsUnsigned():number;
- getLowBits():number;
- getLowBitsUnsigned():number;
- getNumBitsAbs():number;
- greaterThan(other:Long):boolean;
- greaterThanOrEqual(other:Long):boolean;
- isEven():boolean;
- isNegative():boolean;
- isOdd():boolean;
- isZero():boolean;
- lessThan(other:Long):boolean;
- lessThanOrEqual(other:Long):boolean;
- modulo(other:Long):Long;
- multiply(other:Long):Long;
- negate():Long;
- not():Long;
- notEquals(other:Long):boolean;
- or(other:Long):Long;
- shiftLeft(numBits:number):Long;
- shiftRight(numBits:number):Long;
- shiftRightUnsigned(numBits:number):Long;
- subtract(other:Long):Long;
- toInt():number;
- toNumber():number;
- toSigned():Long;
- toString(radix?:number):string;
- toUnsigned():Long;
- xor(other:Long):Long;
- }
-
- // for browser
- export var Long:LongStatic;
-}
-
-// for node, commonjs
declare module "long" {
- var Long:dcodeIO.LongStatic;
- export = Long;
+
+ module Long {
+ export var MAX_UNSIGNED_VALUE: Long;
+ export var MAX_VALUE: Long;
+ export var MIN_VALUE: Long;
+ export var NEG_ONE: Long;
+ export var ONE: Long;
+ export var UONE: Long;
+ export var UZERO: Long;
+ export var ZERO: Long;
+
+ export function fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
+ export function fromInt(value: number, unsigned?: boolean): Long;
+ export function fromNumber(value: number, unsigned?: boolean): Long;
+ export function fromString(str: string, unsigned?: boolean | number, radix?: number): Long;
+ export function fromValue(val: Long | number | string): Long;
+
+ export function isLong(obj: any): boolean;
+ }
+
+ class Long {
+ high: number;
+ low: number;
+ unsigned :boolean;
+
+ constructor(low: number, high?: number, unsigned?:boolean);
+
+ add(other: Long | number | string): Long;
+ and(other: Long | number | string): Long;
+ compare(other: Long | number | string): number;
+ div(divisor: Long | number | string): Long;
+ equals(other: Long | number | string): boolean;
+ getHighBits(): number;
+ getHighBitsUnsigned(): number;
+ getLowBits(): number;
+ getLowBitsUnsigned(): number;
+ getNumBitsAbs(): number;
+ greaterThan(other: Long | number | string): boolean;
+ greaterThanOrEqual(other: Long | number | string): boolean;
+ isEven(): boolean;
+ isNegative(): boolean;
+ isOdd(): boolean;
+ isPositive(): boolean;
+ isZero(): boolean;
+ lessThan(other: Long | number | string): boolean;
+ lessThanOrEqual(other: Long | number | string): boolean;
+ modulo(divisor: Long | number | string): Long;
+ multiply(multiplier: Long | number | string): Long;
+ negate(): Long;
+ not(): Long;
+ notEquals(other: Long | number | string): boolean;
+ or(other: Long | number | string): Long;
+ shiftLeft(numBits: number | Long): Long;
+ shiftRight(numBits: number | Long): Long;
+ shiftRightUnsigned(numBits: number | Long): Long;
+ subtract(other: Long | number | string): Long;
+ toInt(): number;
+ toNumber(): number;
+ toSigned(): Long;
+ toString(radix?: number): string;
+ toUnsigned(): Long;
+ xor(other: Long | number | string): Long;
+ }
+
+ export = Long;
}
diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts
index fefd91946..1d57bc45c 100644
--- a/mocha/mocha.d.ts
+++ b/mocha/mocha.d.ts
@@ -37,11 +37,13 @@ interface MochaDone {
declare var mocha: Mocha;
declare var describe: Mocha.IContextDefinition;
+declare var xdescribe: Mocha.IContextDefinition;
// alias for `describe`
declare var context: Mocha.IContextDefinition;
// alias for `describe`
declare var suite: Mocha.IContextDefinition;
declare var it: Mocha.ITestDefinition;
+declare var xit: Mocha.ITestDefinition;
// alias for `it`
declare var test: Mocha.ITestDefinition;
diff --git a/node/node.d.ts b/node/node.d.ts
index c4f778139..0c6b42740 100644
--- a/node/node.d.ts
+++ b/node/node.d.ts
@@ -127,6 +127,10 @@ declare var Buffer: {
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
concat(list: Buffer[], totalLength?: number): Buffer;
+ /**
+ * The same as buf1.compare(buf2).
+ */
+ compare(buf1: Buffer, buf2: Buffer): number;
};
/************************************************
@@ -327,6 +331,8 @@ interface NodeBuffer {
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): any;
length: number;
+ equals(otherBuffer: Buffer): boolean;
+ compare(otherBuffer: Buffer): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
@@ -1258,6 +1264,19 @@ declare module "fs" {
export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
export function exists(path: string, callback?: (exists: boolean) => void): void;
export function existsSync(path: string): boolean;
+ /** Constant for fs.access(). File is visible to the calling process. */
+ export var F_OK: number;
+ /** Constant for fs.access(). File can be read by the calling process. */
+ export var R_OK: number;
+ /** Constant for fs.access(). File can be written by the calling process. */
+ export var W_OK: number;
+ /** Constant for fs.access(). File can be executed by the calling process. */
+ export var X_OK: number;
+ /** Tests a user's permissions for the file specified by path. */
+ export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void;
+ export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
+ /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */
+ export function accessSync(path: string, mode ?: number): void;
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
@@ -1810,3 +1829,227 @@ declare module "domain" {
export function create(): Domain;
}
+
+declare module "constants" {
+ export var E2BIG: number;
+ export var EACCES: number;
+ export var EADDRINUSE: number;
+ export var EADDRNOTAVAIL: number;
+ export var EAFNOSUPPORT: number;
+ export var EAGAIN: number;
+ export var EALREADY: number;
+ export var EBADF: number;
+ export var EBADMSG: number;
+ export var EBUSY: number;
+ export var ECANCELED: number;
+ export var ECHILD: number;
+ export var ECONNABORTED: number;
+ export var ECONNREFUSED: number;
+ export var ECONNRESET: number;
+ export var EDEADLK: number;
+ export var EDESTADDRREQ: number;
+ export var EDOM: number;
+ export var EEXIST: number;
+ export var EFAULT: number;
+ export var EFBIG: number;
+ export var EHOSTUNREACH: number;
+ export var EIDRM: number;
+ export var EILSEQ: number;
+ export var EINPROGRESS: number;
+ export var EINTR: number;
+ export var EINVAL: number;
+ export var EIO: number;
+ export var EISCONN: number;
+ export var EISDIR: number;
+ export var ELOOP: number;
+ export var EMFILE: number;
+ export var EMLINK: number;
+ export var EMSGSIZE: number;
+ export var ENAMETOOLONG: number;
+ export var ENETDOWN: number;
+ export var ENETRESET: number;
+ export var ENETUNREACH: number;
+ export var ENFILE: number;
+ export var ENOBUFS: number;
+ export var ENODATA: number;
+ export var ENODEV: number;
+ export var ENOENT: number;
+ export var ENOEXEC: number;
+ export var ENOLCK: number;
+ export var ENOLINK: number;
+ export var ENOMEM: number;
+ export var ENOMSG: number;
+ export var ENOPROTOOPT: number;
+ export var ENOSPC: number;
+ export var ENOSR: number;
+ export var ENOSTR: number;
+ export var ENOSYS: number;
+ export var ENOTCONN: number;
+ export var ENOTDIR: number;
+ export var ENOTEMPTY: number;
+ export var ENOTSOCK: number;
+ export var ENOTSUP: number;
+ export var ENOTTY: number;
+ export var ENXIO: number;
+ export var EOPNOTSUPP: number;
+ export var EOVERFLOW: number;
+ export var EPERM: number;
+ export var EPIPE: number;
+ export var EPROTO: number;
+ export var EPROTONOSUPPORT: number;
+ export var EPROTOTYPE: number;
+ export var ERANGE: number;
+ export var EROFS: number;
+ export var ESPIPE: number;
+ export var ESRCH: number;
+ export var ETIME: number;
+ export var ETIMEDOUT: number;
+ export var ETXTBSY: number;
+ export var EWOULDBLOCK: number;
+ export var EXDEV: number;
+ export var WSAEINTR: number;
+ export var WSAEBADF: number;
+ export var WSAEACCES: number;
+ export var WSAEFAULT: number;
+ export var WSAEINVAL: number;
+ export var WSAEMFILE: number;
+ export var WSAEWOULDBLOCK: number;
+ export var WSAEINPROGRESS: number;
+ export var WSAEALREADY: number;
+ export var WSAENOTSOCK: number;
+ export var WSAEDESTADDRREQ: number;
+ export var WSAEMSGSIZE: number;
+ export var WSAEPROTOTYPE: number;
+ export var WSAENOPROTOOPT: number;
+ export var WSAEPROTONOSUPPORT: number;
+ export var WSAESOCKTNOSUPPORT: number;
+ export var WSAEOPNOTSUPP: number;
+ export var WSAEPFNOSUPPORT: number;
+ export var WSAEAFNOSUPPORT: number;
+ export var WSAEADDRINUSE: number;
+ export var WSAEADDRNOTAVAIL: number;
+ export var WSAENETDOWN: number;
+ export var WSAENETUNREACH: number;
+ export var WSAENETRESET: number;
+ export var WSAECONNABORTED: number;
+ export var WSAECONNRESET: number;
+ export var WSAENOBUFS: number;
+ export var WSAEISCONN: number;
+ export var WSAENOTCONN: number;
+ export var WSAESHUTDOWN: number;
+ export var WSAETOOMANYREFS: number;
+ export var WSAETIMEDOUT: number;
+ export var WSAECONNREFUSED: number;
+ export var WSAELOOP: number;
+ export var WSAENAMETOOLONG: number;
+ export var WSAEHOSTDOWN: number;
+ export var WSAEHOSTUNREACH: number;
+ export var WSAENOTEMPTY: number;
+ export var WSAEPROCLIM: number;
+ export var WSAEUSERS: number;
+ export var WSAEDQUOT: number;
+ export var WSAESTALE: number;
+ export var WSAEREMOTE: number;
+ export var WSASYSNOTREADY: number;
+ export var WSAVERNOTSUPPORTED: number;
+ export var WSANOTINITIALISED: number;
+ export var WSAEDISCON: number;
+ export var WSAENOMORE: number;
+ export var WSAECANCELLED: number;
+ export var WSAEINVALIDPROCTABLE: number;
+ export var WSAEINVALIDPROVIDER: number;
+ export var WSAEPROVIDERFAILEDINIT: number;
+ export var WSASYSCALLFAILURE: number;
+ export var WSASERVICE_NOT_FOUND: number;
+ export var WSATYPE_NOT_FOUND: number;
+ export var WSA_E_NO_MORE: number;
+ export var WSA_E_CANCELLED: number;
+ export var WSAEREFUSED: number;
+ export var SIGHUP: number;
+ export var SIGINT: number;
+ export var SIGILL: number;
+ export var SIGABRT: number;
+ export var SIGFPE: number;
+ export var SIGKILL: number;
+ export var SIGSEGV: number;
+ export var SIGTERM: number;
+ export var SIGBREAK: number;
+ export var SIGWINCH: number;
+ export var SSL_OP_ALL: number;
+ export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
+ export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
+ export var SSL_OP_CISCO_ANYCONNECT: number;
+ export var SSL_OP_COOKIE_EXCHANGE: number;
+ export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
+ export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
+ export var SSL_OP_EPHEMERAL_RSA: number;
+ export var SSL_OP_LEGACY_SERVER_CONNECT: number;
+ export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
+ export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
+ export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
+ export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
+ export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
+ export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
+ export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
+ export var SSL_OP_NO_COMPRESSION: number;
+ export var SSL_OP_NO_QUERY_MTU: number;
+ export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
+ export var SSL_OP_NO_SSLv2: number;
+ export var SSL_OP_NO_SSLv3: number;
+ export var SSL_OP_NO_TICKET: number;
+ export var SSL_OP_NO_TLSv1: number;
+ export var SSL_OP_NO_TLSv1_1: number;
+ export var SSL_OP_NO_TLSv1_2: number;
+ export var SSL_OP_PKCS1_CHECK_1: number;
+ export var SSL_OP_PKCS1_CHECK_2: number;
+ export var SSL_OP_SINGLE_DH_USE: number;
+ export var SSL_OP_SINGLE_ECDH_USE: number;
+ export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
+ export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
+ export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
+ export var SSL_OP_TLS_D5_BUG: number;
+ export var SSL_OP_TLS_ROLLBACK_BUG: number;
+ export var ENGINE_METHOD_DSA: number;
+ export var ENGINE_METHOD_DH: number;
+ export var ENGINE_METHOD_RAND: number;
+ export var ENGINE_METHOD_ECDH: number;
+ export var ENGINE_METHOD_ECDSA: number;
+ export var ENGINE_METHOD_CIPHERS: number;
+ export var ENGINE_METHOD_DIGESTS: number;
+ export var ENGINE_METHOD_STORE: number;
+ export var ENGINE_METHOD_PKEY_METHS: number;
+ export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
+ export var ENGINE_METHOD_ALL: number;
+ export var ENGINE_METHOD_NONE: number;
+ export var DH_CHECK_P_NOT_SAFE_PRIME: number;
+ export var DH_CHECK_P_NOT_PRIME: number;
+ export var DH_UNABLE_TO_CHECK_GENERATOR: number;
+ export var DH_NOT_SUITABLE_GENERATOR: number;
+ export var NPN_ENABLED: number;
+ export var RSA_PKCS1_PADDING: number;
+ export var RSA_SSLV23_PADDING: number;
+ export var RSA_NO_PADDING: number;
+ export var RSA_PKCS1_OAEP_PADDING: number;
+ export var RSA_X931_PADDING: number;
+ export var RSA_PKCS1_PSS_PADDING: number;
+ export var POINT_CONVERSION_COMPRESSED: number;
+ export var POINT_CONVERSION_UNCOMPRESSED: number;
+ export var POINT_CONVERSION_HYBRID: number;
+ export var O_RDONLY: number;
+ export var O_WRONLY: number;
+ export var O_RDWR: number;
+ export var S_IFMT: number;
+ export var S_IFREG: number;
+ export var S_IFDIR: number;
+ export var S_IFCHR: number;
+ export var S_IFLNK: number;
+ export var O_CREAT: number;
+ export var O_EXCL: number;
+ export var O_TRUNC: number;
+ export var O_APPEND: number;
+ export var F_OK: number;
+ export var R_OK: number;
+ export var W_OK: number;
+ export var X_OK: number;
+ export var UV_UDP_REUSEADDR: number;
+}
diff --git a/tabtab/tabtab-tests.ts b/tabtab/tabtab-tests.ts
new file mode 100644
index 000000000..3204b7a05
--- /dev/null
+++ b/tabtab/tabtab-tests.ts
@@ -0,0 +1,31 @@
+
+///
+///
+
+import tabtab = require('tabtab');
+import child_process = require('child_process');
+import string_decoder = require('string_decoder');
+
+if (process.argv.slice(2)[0] === 'completion') {
+ tabtab.complete('pkgname', function(err, data) {
+ if (err || !data) return;
+ if (/^--\w?/.test(data.last)) return tabtab.log(['help', 'version'], data, '--');
+ if (/^-\w?/.test(data.last)) return tabtab.log(['n', 'o', 'd', 'e'], data, '-');
+ tabtab.log(['list', 'of', 'commands'], data);
+
+ child_process.exec('rake -H', function(err, stdout, stderr) {
+ if (err) return;
+ var decoder = new string_decoder.StringDecoder('utf8');
+ var parsed = tabtab.parseOut(decoder.write(stdout));
+ if (/^--\w?/.test(data.last)) return tabtab.log(parsed.longs, data, '--');
+ if (/^-\w?/.test(data.last)) return tabtab.log(parsed.shorts, data, '-');
+ });
+
+ child_process.exec('cake', function(err, stdout, stderr) {
+ if (err) return;
+ var decoder = new string_decoder.StringDecoder('utf8');
+ var tasks = tabtab.parseTasks(decoder.write(stdout), 'cake');
+ tabtab.log(tasks, data);
+ });
+ });
+}
diff --git a/tabtab/tabtab.d.ts b/tabtab/tabtab.d.ts
new file mode 100644
index 000000000..a744904ac
--- /dev/null
+++ b/tabtab/tabtab.d.ts
@@ -0,0 +1,91 @@
+// Type definitions for tabtab 0.0.4
+// Project: https://github.com/mklabs/node-tabtab
+// Definitions by: Vojtěch Habarta
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module "tabtab" {
+
+ /**
+ * Main completion method, has support for installation and actual completion.
+ * @param name Name of the command to complete.
+ * @param cb Get called when a tab-completion command happens.
+ */
+ export function complete(name: string, cb: CallBack): void;
+
+ /**
+ * Main completion method, has support for installation and actual completion.
+ * @param name Name of the command to complete.
+ * @param completer Name of the command to call on completion.
+ * @param cb Get called when a tab-completion command happens.
+ */
+ export function complete(name: string, completer: string, cb: CallBack): void;
+
+ /**
+ * Simple helper function to know if the script is run in the context of a completion command.
+ */
+ export function isComplete(): boolean;
+
+ /**
+ * Helper to return the list of short and long options, parsed from the usual --help output of a command (cake/rake -H, vagrant, commander -h, optimist.help(), ...).
+ */
+ export function parseOut(str: string): { shorts: string[]; longs: string[] };
+
+ /**
+ * Same purpose as parseOut, but for parsing tasks from an help command (cake/rake -T, vagrant, etc.).
+ */
+ export function parseTasks(str: string, prefix: string, reg?: RegExp|string): string[];
+
+ /**
+ * Helper to return completion output and log to standard output.
+ * @param values Array of values to complete against.
+ * @param data The data object returned by the complete callback, used mainly to filter results accordingly upon the text that is supplied by the user.
+ * @param prefix A prefix to add to the completion results, useful for options to add dashes (eg. - or --).
+ */
+ export function log(values: string[], data: Data, prefix?: string): void;
+
+ interface CallBack {
+ (error?: Error, data?: Data, text?: string): any;
+ }
+
+ /**
+ * Holds interesting values to drive the output of the completion.
+ */
+ interface Data {
+
+ /**
+ * full command being completed
+ */
+ line: string;
+
+ /**
+ * number of words
+ */
+ words: number;
+
+ /**
+ * cursor position
+ */
+ point: number;
+
+ /**
+ * tabing in the middle of a word: foo bar baz bar foobarrrrrrr
+ */
+ partial: string;
+
+ /**
+ * last word of the line
+ */
+ last: string;
+
+ /**
+ * last partial of the line
+ */
+ lastPartial: string;
+
+ /**
+ * the previous word
+ */
+ prev: string;
+ }
+
+}
diff --git a/tsmonad/tests/either-tests.ts b/tsmonad/tests/either-tests.ts
new file mode 100644
index 000000000..1530562be
--- /dev/null
+++ b/tsmonad/tests/either-tests.ts
@@ -0,0 +1,45 @@
+///
+
+class User {
+
+ private age: number;
+
+ constructor(age?: number) {
+ this.age = age ? age : 0;
+ }
+
+ public getAge(): TsMonad.Either {
+ if (this.age > 0) {
+ return TsMonad.Either.right(this.age);
+ } else {
+ return TsMonad.Either.left('Information withheld');
+ }
+ }
+}
+
+module Station {
+
+ export class BusPass {
+
+ public isValidForRoute(route: string): boolean {
+ return true;
+ }
+ }
+
+ export function getBusPass(age: number): TsMonad.Either {
+ if (age > 18) {
+ return TsMonad.Either.right(new BusPass());
+ } else {
+ return TsMonad.Either.left('Too young for a bus pass');
+ }
+ }
+}
+
+var user = new User(42)
+
+var canRideForFree = user.getAge()
+ .bind(age => Station.getBusPass(age))
+ .caseOf({
+ right: busPass => busPass.isValidForRoute('Weston'),
+ left: errorMessage => { console.log(errorMessage); return false; }
+ });
diff --git a/tsmonad/tests/maybe-tests.ts b/tsmonad/tests/maybe-tests.ts
new file mode 100644
index 000000000..76f0a7256
--- /dev/null
+++ b/tsmonad/tests/maybe-tests.ts
@@ -0,0 +1,20 @@
+///
+
+var turns_out_to_be_100 = TsMonad.Maybe.just(10)
+ .caseOf({
+ just: n => n * n,
+ nothing: () => -1
+ });
+
+var turns_out_to_be_nothing = TsMonad.Maybe.nothing()
+ .caseOf({
+ just: n => n * n,
+ nothing: () => -1
+ });
+
+var turns_out_to_be_true = TsMonad.Maybe.just(123)
+ .lift(n => n * 2)
+ .caseOf({
+ just: n => n === 246,
+ nothing: () => false
+ });
\ No newline at end of file
diff --git a/tsmonad/tests/writer-tests.ts b/tsmonad/tests/writer-tests.ts
new file mode 100644
index 000000000..fd8200aeb
--- /dev/null
+++ b/tsmonad/tests/writer-tests.ts
@@ -0,0 +1,8 @@
+///
+
+var is_true = TsMonad.Writer.writer(['Started with 0'], 0)
+ .bind(x => TsMonad.Writer.writer(['+ 8'], x + 8))
+ .bind(x => TsMonad.Writer.writer(['- 6', '* 8'], 8 * (x - 6)))
+ .caseOf({
+ writer: (s, v) => v === 16 && s.join(', ') === 'Started with 0, + 8, - 6, * 8'
+ });
\ No newline at end of file
diff --git a/tsmonad/tsmonad-tests.ts b/tsmonad/tsmonad-tests.ts
new file mode 100644
index 000000000..8959950d9
--- /dev/null
+++ b/tsmonad/tsmonad-tests.ts
@@ -0,0 +1,3 @@
+///
+///
+///
diff --git a/tsmonad/tsmonad.d.ts b/tsmonad/tsmonad.d.ts
new file mode 100644
index 000000000..081c446c3
--- /dev/null
+++ b/tsmonad/tsmonad.d.ts
@@ -0,0 +1,640 @@
+// Type definitions for TsMonad
+// Project: https://github.com/cbowdon/TsMonad
+// Definitions by: Chris Bowdon
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module TsMonad {
+ /**
+ * @name EitherType
+ * @description Enumerate the different types contained by an Either object.
+ */
+ enum EitherType {
+ Left = 0,
+ Right = 1,
+ }
+ /**
+ * @name EitherPatterns
+ * @description Define a contract to unwrap Either object using callbacks
+ * for Left and Right.
+ * @see Either#
+ */
+ interface EitherPatterns {
+ /**
+ * @name left
+ * @description Function to handle the Left.
+ * @type {(l: L) => T}
+ */
+ left: (l: L) => T;
+ /**
+ * @name right
+ * @description Function to handle the Right.
+ * @type {(r: R) => T}
+ */
+ right: (r: R) => T;
+ }
+ /**
+ * @name either
+ * @description Build an Either object.
+ * @function
+ * @param l The object as a Left (optional).
+ * @param r The object as a Right (optional).
+ * @returns {Either} Either object containing the input.
+ * @throws {TypeError} If there are both or none of left and right
+ * parameter.
+ * @see Either#
+ */
+ function either(l?: L, r?: R): Either;
+ /**
+ * @name Either
+ * @class Either has exactly two sub types, Left (L) and Right (R). If an
+ * Either object contains an instance of L, then the Either is a
+ * Left. Otherwise it contains an instance of R and is a Right. By
+ * convention, the Left constructor is used to hold an error value and
+ * the Right constructor is used to hold a correct value.
+ */
+ class Either implements Monad, Functor, Eq> {
+ private type;
+ private l;
+ private r;
+ /**
+ * @description Build an Either object. For internal use only.
+ * @constructor
+ * @methodOf Either#
+ * @param {EitherType} type Indicates if the Either content is a Left or a Right.
+ * @param {L} l The Left value (optional).
+ * @param {R} l The Right value (optional).
+ */
+ constructor(type: EitherType, l?: L, r?: R);
+ /**
+ * @name left
+ * @description Helper function to build an Either with a Left.
+ * @methodOf Either#
+ * @static
+ * @param {L} l The Left value.
+ * @returns {Either} Either object containing a Left.
+ */
+ static left(l: L): Either;
+ /**
+ * @name right
+ * @description Helper function to build an Either with a Right.
+ * @methodOf Either#
+ * @static
+ * @param {R} r The Right value.
+ * @returns {Either} Either object containing a Right.
+ */
+ static right(r: R): Either;
+ /**
+ * @name unit
+ * @description Wrap a value inside an Either Right object.
+ * @methodOf Either#
+ * @public
+ * @param {T} t
+ * @returns {Either} Either object containing a Right.
+ * @see Monad#unit
+ */
+ public unit(t: T): Either;
+ /**
+ * @name bind
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Either#
+ * @public
+ * @param {(r: R) => Either} f Function applied on the Right.
+ * @returns {Either} The result of the function f wrapped inside
+ * an Either object.
+ * @see Monad#bind
+ */
+ public bind(f: (r: R) => Either): Either;
+ /**
+ * @name of
+ * @description Alias for unit.
+ * @methodOf Either#
+ * @public
+ * @see Either#unit
+ * @see Monad#of
+ */
+ public of: (t: T) => Either;
+ /**
+ * @name chain
+ * @description Alias for bind.
+ * @methodOf Either#
+ * @public
+ * @see Either#bind
+ * @see Monad#chain
+ */
+ public chain: (f: (r: R) => Either) => Either;
+ /**
+ * @name fmap
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Either#
+ * @public
+ * @param {(r: R) => T} f Function applied on the Right.
+ * @returns {Either} The result of the function f wrapped inside
+ * an Either object.
+ * @see Functor#fmap
+ */
+ public fmap(f: (r: R) => T): Either;
+ /**
+ * @name lift
+ * @description Alias for fmap.
+ * @methodOf Either#
+ * @public
+ * @see Either#fmap
+ * @see Functor#lift
+ */
+ public lift: (f: (r: R) => T) => Either;
+ /**
+ * @name map
+ * @description Alias for fmap.
+ * @methodOf Either#
+ * @public
+ * @see Either#fmap
+ * @see Functor#map
+ */
+ public map: (f: (r: R) => T) => Either;
+ /**
+ * @name caseOf
+ * @description Execute a function depending on the Either content.
+ * It allows to unwrap the object for Left or Right types.
+ * @methodOf Either#
+ * @public
+ * @param {EitherPatterns} pattern Object containing the
+ * functions to applied on each Either types.
+ * @return {T} The returned value of the functions specified in the
+ * EitherPatterns interface.
+ * @see EitherPatterns#
+ */
+ public caseOf(pattern: EitherPatterns): T;
+ /**
+ * @name equals
+ * @description Compare the type and the content of two Either
+ * objects.
+ * @methodOf Either#
+ * @public
+ * @param {Either} other The Either to compare with.
+ * @return {boolean} True if the type and content value are equals,
+ * false otherwise.
+ * @see Eq#equals
+ */
+ public equals(other: Either): any;
+ }
+}
+declare module TsMonad {
+ /**
+ * @name eq
+ * @description Compare two objects :
+ * 1. if objects implement Eq, defer to their .equals
+ * 2. if are arrays, iterate and recur
+ * @function
+ * @param {any} a Any object.
+ * @param {any} b Any object.
+ * @returns {boolean} In case 1, the `.equals()` function returned value.
+ * In case 2, true if each elements are equals, false otherwise.
+ */
+ function eq(a: any, b: any): any;
+ /**
+ * @name Eq
+ * @description Define a contract to compare (in)equalities between
+ * objects.
+ */
+ interface Eq {
+ /**
+ * @name equals
+ * @description Determine if two objects are equals.
+ * @methodOf Eq
+ * @public
+ * @param {T} The object to compare with.
+ * @returns {boolean} True if the objects are equals, false otherwise.
+ */
+ equals(t: T): boolean;
+ }
+ interface Monad {
+ /**
+ * @name unit
+ * @description Wrap an object inside a monad.
+ * @methodOf Monad#
+ * @public
+ * @param {U} t The object to wrap.
+ * @returns {Monad} A Monad with the value wrapped inside.
+ */
+ unit(t: U): Monad;
+ /**
+ * @name bind
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Monad#
+ * @public
+ * @param {(t: T) => Monad} f Function applied on the Monad content.
+ * @returns {Monad} The result of the function f wrapped inside
+ * a Monad object.
+ */
+ bind(f: (t: T) => Monad): Monad;
+ /**
+ * @name of
+ * @description Alias for unit. Fantasy Land Monad conformance.
+ * @methodOf Monad#
+ * @public
+ * @see Monad#unit
+ */
+ of(t: U): Monad;
+ /**
+ * @name chain
+ * @description Alias for bind. Fantasy Land Monad conformance.
+ * @methodOf Monad#
+ * @public
+ * @see Monad#bind
+ */
+ chain(f: (t: T) => Monad): Monad;
+ }
+ /**
+ * @name Functor
+ * @description Define a contract to add basic functor functions to an
+ * object.
+ */
+ interface Functor {
+ /**
+ * @name fmap
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Functor#
+ * @public
+ * @param {(t: T) => U} f Function applied on the functor content.
+ * @returns {Functor} The result of the function f wrapped inside
+ * an Functor object.
+ * @see Functor#fmap
+ */
+ fmap(f: (t: T) => U): Functor;
+ /**
+ * @name lift
+ * @description Alias for fmap.
+ * @methodOf Functor#
+ * @public
+ * @see Functor#fmap
+ */
+ lift(f: (t: T) => U): Functor;
+ /**
+ * @name map
+ * @description Alias for fmap. Fantasy Land Monad conformance.
+ * @methodOf Functor#
+ * @public
+ * @see Functor#fmap
+ */
+ map(f: (t: T) => U): Functor;
+ }
+}
+declare module TsMonad {
+ /**
+ * @name MaybeType
+ * @description Enumerate the different types contained by an Maybe object.
+ * @see Maybe#
+ */
+ enum MaybeType {
+ Nothing = 0,
+ Just = 1,
+ }
+ /**
+ * @name MaybePatterns
+ * @description Define a contract to unwrap Maybe object using callbacks
+ * for Just and Nothing.
+ * @see Maybe#
+ */
+ interface MaybePatterns {
+ /**
+ * @name just
+ * @description Function to handle the Just.
+ * @type {(t: T) => U}
+ */
+ just: (t: T) => U;
+ /**
+ * @name nothing
+ * @description Function to handle the Nothing.
+ * @type {() => U}
+ */
+ nothing: () => U;
+ }
+ /**
+ * @name maybe
+ * @description Build a Maybe object.
+ * @function
+ * @param {T} t The object to wrap.
+ * @returns {Maybe} A Maybe object containing the input. If t is null
+ * or undefined, the Maybe object is filled with Nothing.
+ * @see Maybe#
+ */
+ function maybe(t: T): Maybe;
+ /**
+ * @name Maybe
+ * @class Encapsulates an optional value. A value of type Maybe a either
+ * contains a value of type a (represented as Just a), or it is empty
+ * (represented as Nothing).
+ */
+ class Maybe implements Monad, Functor, Eq> {
+ private type;
+ private value;
+ /**
+ * @description Build a Maybe object. For internal use only.
+ * @constructor
+ * @methodOf Maybe#
+ * @param {MaybeType} type Indicates if the Maybe content is a Just or a Nothing.
+ * @param {T} value The value to wrap (optional).
+ */
+ constructor(type: MaybeType, value?: T);
+ /**
+ * @name maybe
+ * @description Helper function to build a Maybe object.
+ * @methodOf Maybe#
+ * @static
+ * @param {T} t The value to wrap.
+ * @returns {Maybe} A Maybe object containing the value passed in input. If t is null
+ * or undefined, the Maybe object is filled with Nothing.
+ */
+ static maybe(t: T): Maybe;
+ /**
+ * @name just
+ * @description Helper function to build a Maybe object filled with a
+ * Just type.
+ * @methodOf Maybe#
+ * @static
+ * @param {T} t The value to wrap.
+ * @returns {Maybe} A Maybe object containing the value passed in input.
+ * @throws {TypeError} If t is null or undefined.
+ */
+ static just(t: T): Maybe;
+ /**
+ * @name nothing
+ * @description Helper function to build a Maybe object filled with a
+ * Nothing type.
+ * @methodOf Maybe#
+ * @static
+ * @returns {Maybe} A Maybe with a Nothing type.
+ */
+ static nothing(): Maybe;
+ /**
+ * @name unit
+ * @description Wrap an object inside a Maybe.
+ * @public
+ * @methodOf Maybe#
+ * @param {U} u The object to wrap.
+ * @returns {Monad} A Monad with the value wrapped inside.
+ * @see Monad#unit
+ */
+ public unit(u: U): Maybe;
+ /**
+ * @name bind
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Maybe#
+ * @public
+ * @param {(t: T) => Maybe} f Function applied on the Maybe content.
+ * @returns {Maybe} The result of the function f wrapped inside
+ * a Maybe object.
+ * @see Monad#bind
+ */
+ public bind(f: (t: T) => Maybe): Maybe;
+ /**
+ * @name of
+ * @description Alias for unit.
+ * @methodOf Maybe#
+ * @public
+ * @see Maybe#unit
+ * @see Monad#of
+ */
+ public of: (u: U) => Maybe;
+ /**
+ * @name chain
+ * @description Alias for bind.
+ * @methodOf Maybe#
+ * @public
+ * @see Maybe#unit
+ * @see Monad#of
+ */
+ public chain: (f: (t: T) => Maybe) => Maybe;
+ /**
+ * @name fmap
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Maybe#
+ * @public
+ * @param {(t: T) => U} f Function applied on the Maybe content.
+ * @returns {Maybe} The result of the function f wrapped inside
+ * an Maybe object.
+ * @see Functor#fmap
+ */
+ public fmap(f: (t: T) => U): Maybe;
+ /**
+ * @name lift
+ * @description Alias for fmap.
+ * @methodOf Maybe#
+ * @public
+ * @see Maybe#fmap
+ * @see Monad#of
+ */
+ public lift: (f: (t: T) => U) => Maybe;
+ /**
+ * @name map
+ * @description Alias for fmap.
+ * @methodOf Maybe#
+ * @public
+ * @see Maybe#fmap
+ * @see Monad#of
+ */
+ public map: (f: (t: T) => U) => Maybe;
+ /**
+ * @name caseOf
+ * @description Execute a function depending on the Maybe content. It
+ * allows to unwrap the object for Just or Nothing types.
+ * @methodOf Maybe#
+ * @public
+ * @param {MaybePatterns} pattern Object containing the
+ * functions to applied on each Maybe types.
+ * @return {U} The returned value of the functions specified in the
+ * MaybePatterns interface.
+ * @see MaybePatterns#
+ */
+ public caseOf(patterns: MaybePatterns): U;
+ /**
+ * @name equals
+ * @description Compare the type and the content of two Maybe
+ * objects.
+ * @methodOf Maybe#
+ * @public
+ * @param {Maybe} other The Maybe to compare with.
+ * @return {boolean} True if the type and content value are equals,
+ * false otherwise.
+ * @see Eq#equals
+ */
+ public equals(other: Maybe): any;
+ }
+}
+declare module TsMonad {
+ /**
+ * @name WriterPatterns
+ * @description Define a contract to unwrap Writer object using a
+ * callback.
+ * @see Writer#
+ */
+ interface WriterPatterns {
+ /**
+ * @name writer
+ * @description Function to handle the Writer content.
+ * @type {(story: S[], value: T) => U}
+ */
+ writer: (story: S[], value: T) => U;
+ }
+ /**
+ * @name writer
+ * @description Build a Writer object.
+ * @function
+ * @param {S[]} story The collection to store logs.
+ * @param {T} value The object to wrap.
+ * @returns {Writer} A Writer object containing the log collection
+ * and the wrapped value.
+ * @see Writer#
+ */
+ function writer(story: S[], value: T): Writer;
+ /**
+ * @name Writer
+ * @class Allow to do computations while making sure that all the log
+ * values are combined into one log value that then gets attached to
+ * the result.
+ */
+ class Writer implements Monad, Eq> {
+ private story;
+ private value;
+ /**
+ * @description Build a Writer object. For internal use only.
+ * @constructor
+ * @methodOf Writer#
+ * @param {S[]} story The collection of logs.
+ * @param {T} value The object to wrap.
+ */
+ constructor(story: S[], value: T);
+ /**
+ * @name writer
+ * @description Helper function to build a Writer object.
+ * @methodOf Writer#
+ * @static
+ * @param {S[]} story The collection of logs.
+ * @param {T} value The object to wrap.
+ * @returns {Writer} A Writer object containing the collection of logs
+ * and the wrapped value.
+ */
+ static writer(story: S[], value: T): Writer;
+ /**
+ * @name writer
+ * @description Helper function to build a Writer object with the log
+ * passed in input only.
+ * @methodOf Writer#
+ * @static
+ * @param {S} s A log to store.
+ * @returns {Writer} A Writer object containing the collection of logs
+ * and a zeroed value.
+ */
+ static tell(s: S): Writer;
+ /**
+ * @name unit
+ * @description Wrap an object inside a Writer.
+ * @public
+ * @methodOf Writer#
+ * @param {U} u The object to wrap.
+ * @returns {Monad} A Writer with the value wrapped inside and an
+ * empty collection of logs.
+ * @see Monad#unit
+ */
+ public unit(u: U): Writer;
+ /**
+ * @name bind
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Writer#
+ * @public
+ * @param {(t: T) => Writer} f Function applied on the Writer content.
+ * @returns {Writer} The result of the function f append to the
+ * Writer object.
+ * @see Monad#bind
+ */
+ public bind(f: (t: T) => Writer): Writer;
+ /**
+ * @name of
+ * @description Alias for unit.
+ * @methodOf Writer#
+ * @public
+ * @see Writer#unit
+ * @see Monad#of
+ */
+ public of: (u: U) => Writer;
+ /**
+ * @name chain
+ * @description Alias for bind
+ * @methodOf Writer#
+ * @public
+ * @see Writer#unit
+ * @see Monad#of
+ */
+ public chain: (f: (t: T) => Writer) => Writer;
+ /**
+ * @name fmap
+ * @description Apply the function passed as parameter on the object.
+ * @methodOf Writer#
+ * @public
+ * @param {(t: T) => U} f Function applied on the wrapped value.
+ * @returns {Writer} The result of the function f wrapped inside
+ * an Writer object. It has an empty collection of logs.
+ * @see Functor#fmap
+ */
+ public fmap(f: (t: T) => U): Writer;
+ /**
+ * @name lift
+ * @description Alias for fmap
+ * @methodOf Writer#
+ * @public
+ * @see Writer#fmap
+ * @see Monad#of
+ */
+ public lift: (f: (t: T) => U) => Writer;
+ /**
+ * @name map
+ * @description Alias for fmap
+ * @methodOf Writer#
+ * @public
+ * @see Writer#fmap
+ * @see Monad#of
+ */
+ public map: (f: (t: T) => U) => Writer;
+ /**
+ * @name caseOf
+ * @description Execute a function on the Writer content. It allows to
+ * unwrap the object.
+ * @methodOf Writer#
+ * @public
+ * @param {WriterPatterns} pattern Object containing the
+ * functions to applied on the Writer content.
+ * @return {U} The returned value of the function specified in the
+ * WriterPatterns interface.
+ * @see WriterPatterns#
+ */
+ public caseOf(patterns: WriterPatterns): U;
+ /**
+ * @name equals
+ * @description Compare the type and the content of two Writer
+ * objects.
+ * @methodOf Writer#
+ * @public
+ * @param {Writer} other The Writer to compare with.
+ * @return {boolean} True if the collection of logs and content value
+ * are equals, false otherwise.
+ * @see Eq#equals
+ */
+ public equals(other: Writer): boolean;
+ }
+}
+declare var module: {
+ exports: any;
+ require(id: string): any;
+ id: string;
+ filename: string;
+ loaded: boolean;
+ parent: any;
+ children: any[];
+};
+/**
+* @name tsmonad
+* @namespace Hold functionalities related to TsMonad library.
+*/
+declare module 'tsmonad' {
+ export = TsMonad;
+}
diff --git a/when/when-tests.ts b/when/when-tests.ts
index 61b688a03..602a2867e 100644
--- a/when/when-tests.ts
+++ b/when/when-tests.ts
@@ -132,9 +132,11 @@ promise = when(1).then((val: number) => when(val + val), (err: any) => 2);
/* promise.spread(onFulfilledArray) */
-// TODO: Work out how to do this...
-// promise = when([1, '2', true]).spread((a: number, b: string, c: boolean) => a);
-// promise = when([1, '2', true]).spread((a: number, b: string, c: boolean) => when(a));
+promise = when([]).spread(() => 2);
+promise = when([1]).spread((a: number) => a);
+promise = when([1, '2']).spread((a: number, b: string) => a);
+promise = when([1, '2', true]).spread((a: number, b: string, c: boolean) => a);
+promise = when([1, '2', true]).spread((a: number, b: string, c: boolean) => when(a));
/* promise.fold(combine, promise2) */
diff --git a/when/when.d.ts b/when/when.d.ts
index be5e25f15..cd99d2a9a 100644
--- a/when/when.d.ts
+++ b/when/when.d.ts
@@ -180,6 +180,13 @@ declare module When {
then(onFulfilled: (value: T) => U | Promise, onRejected?: (reason: any) => U | Promise, onProgress?: (update: any) => void): Promise;
+ spread(onFulfilled: _.Fn0 | T>): Promise;
+ spread(onFulfilled: _.Fn1 | T>): Promise;
+ spread(onFulfilled: _.Fn2 | T>): Promise;
+ spread(onFulfilled: _.Fn3 | T>): Promise;
+ spread(onFulfilled: _.Fn4 | T>): Promise;
+ spread(onFulfilled: _.Fn5 | T>): Promise