Merge branch 'master' of https://github.com/borisyankov/DefinitelyTyped into ui-grid-generic

# By Ilya Mochalov (24) and others
# Via Masahiro Wakame (87) and others
* 'master' of https://github.com/borisyankov/DefinitelyTyped: (189 commits)
  update npm-shrinkwrap.json
  update dt-tester
  fix mapbox/mapbox.d.ts
  Fix issue #5854
  lodash: changed _.pull() method
  lodash: changed _.without() method
  findup-sync: Update to v0.3.0 and include cwd property in options.
  Adding tests file and adjusting meshblu definitions
  Make a generic base version of HTMLAttributes and DOMAttributes to allow for components that pass all remaining properties to an underlying HTML element.
  lodash: added _.takeRight() method
  meshblu 1.30.1 definitions
  node-cache: added tests
  node-cache: added definitions
  Added missing gridHeight property
  Add typings and test code from Pusher Documentation (https://pusher.com/docs)
  Add version
  Provide pusher-js with typings
  Add pusher-js
  Update pubsubjs to latest version, and add exported module name
  Update reference to Q definitions
  ...

Conflicts:
	ui-grid/ui-grid-tests.ts
	ui-grid/ui-grid.d.ts
This commit is contained in:
Joe Skeen
2015-09-23 08:35:30 -06:00
165 changed files with 34176 additions and 2082 deletions
@@ -0,0 +1,84 @@
/// <reference path="./amazon-product-api.d.ts" />
/// <reference path="../node/node.d.ts"/>
import amazon = require('amazon-product-api');
var client = amazon.createClient({
awsId: process.env.AWS_ACCESS_KEY_ID,
awsSecret: process.env.AWS_SECRET,
awsTag: process.env.AWS_ASSOCIATE_TAG
});
// Item Search
var searchQuery = {
director: 'Quentin Tarantino',
actor: 'Samuel L. Jackson',
searchIndex: 'DVD',
audienceRating: 'R',
responseGroup: 'ItemAttributes,Offers,Images'
};
client.itemSearch(searchQuery).then((results) => {
console.log(getResultCount(results) + " search results");
}).catch(function(err){
console.log(err);
});
client.itemSearch(searchQuery, (err, results) => {
if(err) {
console.log(err);
return;
}
console.log(getResultCount(results) + " search results");
});
// Item Lookup
var lookupQuery = {
itemId: 'B00008OE6I',
idType: 'ASIN',
responseGroup: 'OfferFull',
Condition: 'All'
};
client.itemLookup(lookupQuery).then((results) => {
console.log(getResultCount(results) + " lookup results");
}).catch(function(err){
console.log(err);
});
client.itemLookup(lookupQuery, (err, results) => {
if(err) {
console.log(err);
return;
}
console.log(getResultCount(results) + " lookup results");
});
// Browse Node Lookup
var nodeLookupQuery = {
browseNodeId: '2625373011'
};
client.browseNodeLookup(nodeLookupQuery).then((results) => {
console.log(getResultCount(results) + " node lookup results");
}).catch(function(err){
console.log(err);
});
client.browseNodeLookup(nodeLookupQuery, (err, results) => {
if(err) {
console.log(err);
return;
}
console.log(getResultCount(results) + " node lookup results");
});
function getResultCount(results: Object[]) {
return results != undefined ? results.length : 0;
}
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for amazon-product-api
// Project: https://github.com/t3chnoboy/amazon-product-api
// Definitions by: Matti Lehtinen <https://github.com/MattiLehtinen/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../es6-promise/es6-promise.d.ts"/>
declare module "amazon-product-api" {
interface ICredentials {
awsId: string,
awsSecret: string,
awsTag: string
}
interface IAmazonProductQueryCallback {
(err: string, results: Object[]): void;
}
interface IAmazonProductClient {
itemSearch(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
itemLookup(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
browseNodeLookup(query: any, callback?: IAmazonProductQueryCallback) : Promise<Object[]>;
}
export function createClient(credentials:ICredentials) : IAmazonProductClient;
}
+265
View File
@@ -0,0 +1,265 @@
/// <reference path="amplify-deferred.d.ts" />
/// <reference path="../jquery/jquery.d.ts" />
// Copied examples directly from AmplifyJs site
// Subscribe and publish with no data
amplify.subscribe("nodataexample", function () {
alert("nodataexample topic published!");
});
// Subscribe and publish with data
amplify.publish("nodataexample");
amplify.subscribe("dataexample", function (data) {
alert(data.foo); // bar
});
amplify.publish("dataexample", { foo: "bar" });
amplify.subscribe("dataexample2", function (param1, param2) {
alert(param1 + param2); // barbaz
});
//...
amplify.publish("dataexample2", "bar", "baz");
// Subscribe and publish with context and data
amplify.subscribe("datacontextexample", $("p:first"), function (data) {
this.text(data.exampleText); // first p element would have "foo bar baz" as text
});
amplify.publish("datacontextexample", { exampleText: "foo bar baz" });
// Subscribe to a topic with high priority
amplify.subscribe("priorityexample", function (data) {
alert(data.foo);
});
amplify.subscribe("priorityexample", function (data) {
if (data.foo === "oops") {
return false;
}
}, 1);
// Store data with amplify storage picking the default storage technology:
amplify.publish("priorityexample", { foo: "bar" });
amplify.publish("priorityexample", { foo: "oops" });
amplify.store("storeExample1", { foo: "bar" });
amplify.store("storeExample2", "baz");
// retrieve the data later via the key
var myStoredValue = amplify.store("storeExample1"),
myStoredValue2 = amplify.store("storeExample2"),
myStoredValues = amplify.store();
myStoredValue.foo; // bar
myStoredValue2; // baz
myStoredValues.storeExample1.foo; // bar
myStoredValues.storeExample2; // baz
// Store data explicitly with session storage
amplify.store.sessionStorage("explicitExample", { foo2: "baz" });
// retrieve the data later via the key
var myStoredValue2 = amplify.store.sessionStorage("explicitExample");
myStoredValue2.foo2; // baz
// REQUEST
// Set up and use a request utilizing Ajax
amplify.request.define("ajaxExample1", "ajax", {
url: "/myApiUrl",
dataType: "json",
type: "GET"
});
// later in code
amplify.request("ajaxExample1", function (data) {
data.foo; // bar
});
// Set up and use a request utilizing Ajax and Caching
amplify.request.define("ajaxExample2", "ajax", {
url: "/myApiUrl",
dataType: "json",
type: "GET",
cache: "persist"
});
// later in code
amplify.request("ajaxExample2", function (data) {
data.foo; // bar
});
// a second call will result in pulling from the cache
amplify.request("ajaxExample2", function (data) {
data.baz; // qux
})
// Set up and use a RESTful request utilizing Ajax
amplify.request.define("ajaxRESTFulExample", "ajax", {
url: "/myRestFulApi/{type}/{id}",
type: "GET"
})
// later in code
amplify.request("ajaxRESTFulExample",
{
type: "foo",
id: "bar"
},
function (data) {
// /myRESTFulApi/foo/bar was the URL used
data.foo; // bar
}
);
// POST data with Ajax
amplify.request.define("ajaxPostExample", "ajax", {
url: "/myRestFulApi",
type: "POST"
})
// later in code
amplify.request("ajaxPostExample",
{
type: "foo",
id: "bar"
},
function (data) {
data.foo; // bar
}
);
// Using data maps
// When searching Twitter, the key for the search phrase is q.If we want a more descriptive name, such as term, we can use a data map:
amplify.request.define("twitter-search", "ajax", {
url: "http://search.twitter.com/search.json",
dataType: "jsonp",
dataMap: {
term: "q"
}
});
amplify.request("twitter-search", { term: "amplifyjs" });
// Similarly, we can create a request that searches for mentions, by accepting a username:
amplify.request.define("twitter-mentions", "ajax", {
url: "http://search.twitter.com/search.json",
dataType: "jsonp",
dataMap: function (data) {
return {
q: "@" + data.user
};
}
});
amplify.request("twitter-mentions", { user: "amplifyjs" });
// Setting up and using decoders
//Example:
var appEnvelopeDecoder: amplifyDecoder = function (data, status, xhr, success, error) {
if (data.status === "success") {
success(data.data);
} else if (data.status === "fail" || data.status === "error") {
error(data.message, data.status);
} else {
error(data.message, "fatal");
}
};
//a new decoder can be added to the amplifyDecoders interface
interface amplifyDecoders {
appEnvelope: amplifyDecoder;
}
amplify.request.decoders.appEnvelope = appEnvelopeDecoder;
//but you can also just add it via an index
amplify.request.decoders['appEnvelopeStr'] = appEnvelopeDecoder;
amplify.request.define("decoderExample", "ajax", {
url: "/myAjaxUrl",
type: "POST",
decoder: "appEnvelope"
});
amplify.request({
resourceId: "decoderExample",
success: function (data) {
data.foo; // bar
},
error: function (message, level) {
alert("always handle errors with alerts.");
}
});
// POST with caching and single - use decoder
// Example:
amplify.request.define("decoderSingleExample", "ajax", {
url: "/myAjaxUrl",
type: "POST",
decoder: function (data, status, xhr, success, error) {
if (data.status === "success") {
success(data.data);
} else if (data.status === "fail" || data.status === "error") {
error(data.message, data.status);
} else {
error(data.message, "fatal");
}
}
});
amplify.request({
resourceId: "decoderSingleExample",
success: function (data) {
data.foo; // bar
},
error: function (message, level) {
alert("always handle errors with alerts.");
}
});
// Handling Status
// Status in Success and Error Callbacks
// amplify.request comes with built in support for status.The status parameter appears in the default success or error callbacks when using an ajax definition.
amplify.request.define("statusExample1", "ajax", {
//...
});
amplify.request({
resourceId: "statusExample1",
success: function (data, status) {
},
error: function (data, status) {
}
});
amplify.request({
resourceId: "statusExample1"
}).done(function (data, status) {
}).fail(function (data, status) {
}).always(function (data, status) { });
@@ -0,0 +1 @@
+182
View File
@@ -0,0 +1,182 @@
// Type definitions for AmplifyJs 1.1.0 using JQuery Deferred
// Project: http://amplifyjs.com/
// Definitions by: Jonas Eriksson <https://github.com/joeriks/>, Laurentiu Stamate <https://github.com/laurentiustamate94>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface amplifyRequestSettings {
resourceId: string;
data?: any;
success?: (...args: any[]) => void;
error?: (...args: any[]) => void;
}
interface amplifyDecoder {
(
data?: any,
status?: string,
xhr?: JQueryXHR,
success?: (...args: any[]) => void,
error?: (...args: any[]) => void
): void
}
interface amplifyDecoders {
[decoderName: string]: amplifyDecoder;
jsSend: amplifyDecoder;
}
interface amplifyAjaxSettings extends JQueryAjaxSettings {
cache?: any;
dataMap?: {} | ((data: any) => {});
decoder?: any /* string or amplifyDecoder */;
}
interface amplifyRequest {
/***
* Request a resource.
* resourceId: Identifier string for the resource.
* data: A set of key/value pairs of data to be sent to the resource.
* callback: A function to invoke if the resource is retrieved successfully.
*/
(resourceId: string, hash?: any, callback?: Function): JQueryPromise<any>;
/***
* Request a resource.
* settings: A set of key/value pairs of settings for the request.
* resourceId: Identifier string for the resource.
* data (optional): Data associated with the request.
* success (optional): Function to invoke on success.
* error (optional): Function to invoke on error.
*/
(settings: amplifyRequestSettings): JQueryPromise<any>;
/***
* Define a resource.
* resourceId: Identifier string for the resource.
* requestType: The type of data retrieval method from the server. See the request types sections for more information.
* settings: A set of key/value pairs that relate to the server communication technology. The following settings are available:
* Any settings found in jQuery.ajax().
* cache: See the cache section for more details.
* decoder: See the decoder section for more details.
*/
define(resourceId: string, requestType: string, settings?: amplifyAjaxSettings): void;
/***
* Define a custom request.
* resourceId: Identifier string for the resource.
* resource: Function to handle requests. Receives a hash with the following properties:
* resourceId: Identifier string for the resource.
* data: Data provided by the user.
* success: Callback to invoke on success.
* error: Callback to invoke on error.
*/
define(resourceId: string, resource: (settings: amplifyRequestSettings) => void): void;
decoders: amplifyDecoders;
cache: any;
}
interface amplifySubscribe {
/***
* Subscribe to a message.
* topic: Name of the message to subscribe to.
* callback: Function to invoke when the message is published.
*/
(topic: string, callback: Function): void;
/***
* Subscribe to a message.
* topic: Name of the message to subscribe to.
* context: What this will be when the callback is invoked.
* callback: Function to invoke when the message is published.
* [priority]: Priority relative to other subscriptions for the same message. Lower values have higher priority. Default is 10.
*/
(topic: string, context: any, callback: Function, priority?: number): void;
/***
* Subscribe to a message.
* topic: Name of the message to subscribe to.
* callback: Function to invoke when the message is published.
* [priority]: Priority relative to other subscriptions for the same message. Lower values have higher priority. Default is 10.
*/
(topic: string, callback: Function, priority?: number): void;
}
interface amplifyStorageTypeStore {
/***
* Stores a value for a given key using the default storage type.
*
* key: Identifier for the value being stored.
* value: The value to store. The value can be anything that can be serialized as JSON.
* [options]: A set of key/value pairs that relate to settings for storing the value.
*/
(key: string, value: any, options?: any): void;
/***
* Gets a stored value based on the key.
*/
(key: string): any;
/***
* Gets a hash of all stored values.
*/
(): any;
}
interface amplifyStore extends amplifyStorageTypeStore {
/***
* IE 8+, Firefox 3.5+, Safari 4+, Chrome, Opera 10.5+, iPhone 2+, Android 2+
*/
localStorage: amplifyStorageTypeStore;
/***
* IE 8+, Firefox 2+, Safari 4+, Chrome, Opera 10.5+, iPhone 2+, Android 2+
*/
sessionStorage: amplifyStorageTypeStore;
/***
* Firefox 2+
*/
globalStorage: amplifyStorageTypeStore;
/***
* IE 5 - 7
*/
userData: amplifyStorageTypeStore;
/***
* An in-memory store is provided as a fallback if none of the other storage types are available.
*/
memory: amplifyStorageTypeStore;
}
interface amplifyStatic {
subscribe: amplifySubscribe;
/***
* Remove a subscription.
* topic: The topic being unsubscribed from.
* callback: The callback that was originally subscribed.
*/
unsubscribe(topic: string, callback: Function): void;
/***
* Publish a message.
* topic: The name of the message to publish.
* Any additional parameters will be passed to the subscriptions.
* amplify.publish returns a boolean indicating whether any subscriptions returned false. The return value is true if none of the subscriptions returned false, and false otherwise. Note that only one subscription can return false because doing so will prevent additional subscriptions from being invoked.
*/
publish(topic: string, ...args: any[]): boolean;
store: amplifyStore;
request: amplifyRequest;
}
declare var amplify: amplifyStatic;
+1 -1
View File
@@ -45,7 +45,7 @@ declare module angular.growl {
/**
* Pre-defined server error interceptor.
*/
serverMessagesInterceptor: (string|Function)[];
serverMessagesInterceptor: (string|IHttpInterceptorFactory)[];
/**
* Set default TTL settings.
+2 -2
View File
@@ -22,8 +22,8 @@ declare module angular.localForage {
}
interface ILocalForageService {
setDriver(driver:string):angular.IPromise<void>;
driver<T>():lf.ILocalForage<T>;
driver(): LocalForageDriver;
setDriver(name: string | string[]): angular.IPromise<void>;
setItem(key:string, value:any):angular.IPromise<void>;
setItem(keys:Array<string>, values:Array<any>):angular.IPromise<void>;
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -16,7 +16,7 @@ class Cmp {
Cmp.annotations = [
Component({
selector: 'cmp',
injectables: [Service, bind(Service2).toValue(null)]
bindings: [Service, bind(Service2).toValue(null)]
}),
View({
template: '{{greeting}} world!',
@@ -27,9 +27,9 @@ Cmp.annotations = [
properties: [
'text: tooltip'
],
hostListeners: {
'onmouseenter': 'onMouseEnter()',
'onmouseleave': 'onMouseLeave()'
host: {
'(onmouseenter)': 'onMouseEnter()',
'(onmouseleave)': 'onMouseLeave()'
}
})
];
+6646 -354
View File
File diff suppressed because it is too large Load Diff
+1007
View File
File diff suppressed because it is too large Load Diff
+1007
View File
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -81,7 +81,7 @@ declare module ngRouter {
* ]);
* ```
*/
config(definitions: List<RouteDefinition>): Promise<any>;
config(definitions: Array<RouteDefinition>): Promise<any>;
/**
@@ -135,7 +135,7 @@ declare module ngRouter {
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
* app's base href.
*/
generate(linkParams: List<any>): Instruction;
generate(linkParams: Array<any>): Instruction;
}
class RootRouter extends Router {
@@ -258,7 +258,7 @@ declare module ngRouter {
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
* generates a url with a leading slash relative to the provided `parentComponent`.
*/
generate(linkParams: List<any>, parentComponent: any): Instruction;
generate(linkParams: Array<any>, parentComponent: any): Instruction;
}
class LocationStrategy {
@@ -343,7 +343,7 @@ declare module ngRouter {
*/
class Pipeline {
steps: List<Function>;
steps: Array<Function>;
process(instruction: Instruction): Promise<any>;
}
@@ -547,7 +547,7 @@ declare module ngRouter {
urlPath: string;
urlParams: List<string>;
urlParams: Array<string>;
params: StringMap<string, any>;
@@ -568,7 +568,7 @@ declare module ngRouter {
child: Url;
auxiliary: List<Url>;
auxiliary: Array<Url>;
params: StringMap<string, any>;
@@ -594,9 +594,9 @@ declare module ngRouter {
}
const routerDirectives : List<any> ;
const routerDirectives : Array<any> ;
var routerInjectables : List<any> ;
var routerInjectables : Array<any> ;
class Route implements RouteDefinition {
@@ -669,7 +669,7 @@ declare module ngRouter {
const ROUTE_DATA : OpaqueToken ;
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
var RouteConfig : (configs: Array<RouteDefinition>) => ClassDecorator ;
interface ComponentDefinition {
+9 -9
View File
@@ -81,7 +81,7 @@ declare module ngRouter {
* ]);
* ```
*/
config(definitions: List<RouteDefinition>): Promise<any>;
config(definitions: Array<RouteDefinition>): Promise<any>;
/**
@@ -135,7 +135,7 @@ declare module ngRouter {
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
* app's base href.
*/
generate(linkParams: List<any>): Instruction;
generate(linkParams: Array<any>): Instruction;
}
class RootRouter extends Router {
@@ -258,7 +258,7 @@ declare module ngRouter {
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
* generates a url with a leading slash relative to the provided `parentComponent`.
*/
generate(linkParams: List<any>, parentComponent: any): Instruction;
generate(linkParams: Array<any>, parentComponent: any): Instruction;
}
class LocationStrategy {
@@ -343,7 +343,7 @@ declare module ngRouter {
*/
class Pipeline {
steps: List<Function>;
steps: Array<Function>;
process(instruction: Instruction): Promise<any>;
}
@@ -547,7 +547,7 @@ declare module ngRouter {
urlPath: string;
urlParams: List<string>;
urlParams: Array<string>;
params: StringMap<string, any>;
@@ -568,7 +568,7 @@ declare module ngRouter {
child: Url;
auxiliary: List<Url>;
auxiliary: Array<Url>;
params: StringMap<string, any>;
@@ -596,9 +596,9 @@ declare module ngRouter {
const ROUTE_DATA : OpaqueToken ;
const ROUTER_DIRECTIVES : List<any> ;
const ROUTER_DIRECTIVES : Array<any> ;
const ROUTER_BINDINGS : List<any> ;
const ROUTER_BINDINGS : Array<any> ;
class Route implements RouteDefinition {
@@ -669,7 +669,7 @@ declare module ngRouter {
data?: any;
}
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
var RouteConfig : (configs: Array<RouteDefinition>) => ClassDecorator ;
interface ComponentDefinition {
+738
View File
@@ -0,0 +1,738 @@
// Type definitions for Angular v2.0.0-alpha.37
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// ***********************************************************
// This file is generated by the Angular build process.
// Please do not create manual edits or send pull requests
// modifying this file.
// ***********************************************************
// angular2/router depends transitively on these libraries.
// If you don't have them installed you can install them using TSD
// https://github.com/DefinitelyTyped/tsd
///<reference path="./angular2.d.ts"/>
/**
* @module
* @description
* Maps application URLs into application states, to support deep-linking and navigation.
*/
declare module ngRouter {
/**
* # Router
* The router is responsible for mapping URLs to components.
*
* You can see the state of the router by inspecting the read-only field `router.navigating`.
* This may be useful for showing a spinner, for instance.
*
* ## Concepts
* Routers and component instances have a 1:1 correspondence.
*
* The router holds reference to a number of "outlets." An outlet is a placeholder that the
* router dynamically fills in depending on the current URL.
*
* When the router navigates from a URL, it must first recognizes it and serialize it into an
* `Instruction`.
* The router uses the `RouteRegistry` to get an `Instruction`.
*/
class Router {
navigating: boolean;
lastNavigationAttempt: string;
registry: RouteRegistry;
parent: Router;
hostComponent: any;
/**
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
* component.
*/
childRouter(hostComponent: any): Router;
/**
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
* component.
*/
auxRouter(hostComponent: any): Router;
/**
* Register an outlet to notified of primary route changes.
*
* You probably don't need to use this unless you're writing a reusable component.
*/
registerPrimaryOutlet(outlet: RouterOutlet): Promise<boolean>;
/**
* Register an outlet to notified of auxiliary route changes.
*
* You probably don't need to use this unless you're writing a reusable component.
*/
registerAuxOutlet(outlet: RouterOutlet): Promise<boolean>;
/**
* Given an instruction, returns `true` if the instruction is currently active,
* otherwise `false`.
*/
isRouteActive(instruction: Instruction): boolean;
/**
* Dynamically update the routing configuration and trigger a navigation.
*
* # Usage
*
* ```
* router.config([
* { 'path': '/', 'component': IndexComp },
* { 'path': '/user/:id', 'component': UserComp },
* ]);
* ```
*/
config(definitions: RouteDefinition[]): Promise<any>;
/**
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
*
* If the given URL begins with a `/`, router will navigate absolutely.
* If the given URL does not begin with `/`, the router will navigate relative to this component.
*/
navigate(url: string, _skipLocationChange?: boolean): Promise<any>;
/**
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
* complete.
*/
navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
/**
* Updates this router and all descendant routers according to the given instruction
*/
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
/**
* Subscribe to URL updates from the router
*/
subscribe(onNext: (value: any) => void): Object;
/**
* Removes the contents of this router's outlet and all descendant outlets
*/
deactivate(instruction: Instruction): Promise<any>;
/**
* Given a URL, returns an instruction representing the component graph
*/
recognize(url: string): Promise<Instruction>;
/**
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
* router has yet to successfully navigate.
*/
renavigate(): Promise<any>;
/**
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
* app's base href.
*/
generate(linkParams: any[]): Instruction;
}
class RootRouter extends Router {
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
}
/**
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
*
* ## Use
*
* ```
* <router-outlet></router-outlet>
* ```
*/
class RouterOutlet {
name: string;
/**
* Called by the Router to instantiate a new component during the commit phase of a navigation.
* This method in turn is responsible for calling the `onActivate` hook of its child.
*/
activate(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} during the commit phase of a navigation when an outlet
* reuses a component between different routes.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
reuse(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} when an outlet reuses a component across navigations.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
deactivate(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If this resolves to `false`, the given navigation is cancelled.
*
* This method delegates to the child component's `canDeactivate` hook if it exists,
* and otherwise resolves to true.
*/
canDeactivate(nextInstruction: ComponentInstruction): Promise<boolean>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If the new child component has a different Type than the existing child component,
* this will resolve to `false`. You can't reuse an old component when the new component
* is of a different Type.
*
* Otherwise, this method delegates to the child component's `canReuse` hook if it exists,
* or resolves to true if the hook is not present.
*/
canReuse(nextInstruction: ComponentInstruction): Promise<boolean>;
}
/**
* The RouterLink directive lets you link to specific parts of your app.
*
* Consider the following route configuration:
*
* ```
* @RouteConfig([
* { path: '/user', component: UserCmp, as: 'user' }
* ]);
* class MyComp {}
* ```
*
* When linking to this `user` route, you can write:
*
* ```
* <a [router-link]="['./user']">link to user component</a>
* ```
*
* RouterLink expects the value to be an array of route names, followed by the params
* for that level of routing. For instance `['/team', {teamId: 1}, 'user', {userId: 2}]`
* means that we want to generate a link for the `team` route with params `{teamId: 1}`,
* and with a child route `user` with params `{userId: 2}`.
*
* The first route name should be prepended with `/`, `./`, or `../`.
* If the route begins with `/`, the router will look up the route from the root of the app.
* If the route begins with `./`, the router will instead look in the current component's
* children for the route. And if the route begins with `../`, the router will look at the
* current component's parent.
*/
class RouterLink {
visibleHref: string;
isRouteActive: boolean;
routeParams: any;
onClick(): boolean;
}
class RouteParams {
params: StringMap<string, string>;
get(param: string): string;
}
/**
* The RouteRegistry holds route configurations for each component in an Angular app.
* It is responsible for creating Instructions from URLs, and generating URLs based on route and
* parameters.
*/
class RouteRegistry {
/**
* Given a component and a configuration object, add the route to this registry
*/
config(parentComponent: any, config: RouteDefinition): void;
/**
* Reads the annotations of a component and configures the registry based on them
*/
configFromComponent(component: any): void;
/**
* Given a URL and a parent component, return the most specific instruction for navigating
* the application into the state specified by the url
*/
recognize(url: string, parentComponent: any): Promise<Instruction>;
/**
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
* generates a url with a leading slash relative to the provided `parentComponent`.
*/
generate(linkParams: any[], parentComponent: any): Instruction;
}
class LocationStrategy {
path(): string;
pushState(ctx: any, title: string, url: string): void;
forward(): void;
back(): void;
onPopState(fn: (_: any) => any): void;
getBaseHref(): string;
}
class HashLocationStrategy extends LocationStrategy {
onPopState(fn: EventListener): void;
getBaseHref(): string;
path(): string;
pushState(state: any, title: string, url: string): void;
forward(): void;
back(): void;
}
class PathLocationStrategy extends LocationStrategy {
onPopState(fn: EventListener): void;
getBaseHref(): string;
path(): string;
pushState(state: any, title: string, url: string): void;
forward(): void;
back(): void;
}
/**
* This is the service that an application developer will directly interact with.
*
* Responsible for normalizing the URL against the application's base href.
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
* trailing slash:
* - `/my/app/user/123` is normalized
* - `my/app/user/123` **is not** normalized
* - `/my/app/user/123/` **is not** normalized
*/
class Location {
platformStrategy: LocationStrategy;
path(): string;
normalize(url: string): string;
normalizeAbsolutely(url: string): string;
go(url: string): void;
forward(): void;
back(): void;
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void;
}
const APP_BASE_HREF : OpaqueToken ;
/**
* Responsible for performing each step of navigation.
* "Steps" are conceptually similar to "middleware"
*/
class Pipeline {
steps: Function[];
process(instruction: Instruction): Promise<any>;
}
/**
* Defines route lifecycle method [onActivate], which is called by the router at the end of a
* successful route navigation.
*
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
* depending on the result of [canReuse].
*
* If `onActivate` returns a promise, the route change will wait until the promise settles to
* instantiate and activate child components.
*
* ## Example
* ```
* @Directive({
* selector: 'my-cmp'
* })
* class MyCmp implements OnActivate {
* onActivate(next, prev) {
* this.log = 'Finished navigating from ' + prev.urlPath + ' to ' + next.urlPath;
* }
* }
* ```
*/
interface OnActivate {
onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [onDeactivate], which is called by the router before destroying
* a component as part of a route change.
*
* If `onDeactivate` returns a promise, the route change will wait until the promise settles.
*
* ## Example
* ```
* @Directive({
* selector: 'my-cmp'
* })
* class MyCmp implements CanReuse, OnReuse {
* canReuse() {
* return true;
* }
*
* onReuse(next, prev) {
* this.params = next.params;
* }
* }
* ```
*/
interface OnDeactivate {
onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [onReuse], which is called by the router at the end of a
* successful route navigation when [canReuse] is implemented and returns or resolves to true.
*
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
* depending on the result of [canReuse].
*
* ## Example
* ```
* @Directive({
* selector: 'my-cmp'
* })
* class MyCmp implements CanReuse, OnReuse {
* canReuse() {
* return true;
* }
*
* onReuse(next, prev) {
* this.params = next.params;
* }
* }
* ```
*/
interface OnReuse {
onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [canDeactivate], which is called by the router to determine
* if a component can be removed as part of a navigation.
*
* If `canDeactivate` returns or resolves to `false`, the navigation is cancelled.
*
* If `canDeactivate` throws or rejects, the navigation is also cancelled.
*
* ## Example
* ```
* @Directive({
* selector: 'my-cmp'
* })
* class MyCmp implements CanDeactivate {
* canDeactivate(next, prev) {
* return askUserIfTheyAreSureTheyWantToQuit();
* }
* }
* ```
*/
interface CanDeactivate {
canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [canReuse], which is called by the router to determine whether a
* component should be reused across routes, or whether to destroy and instantiate a new component.
*
* If `canReuse` returns or resolves to `true`, the component instance will be reused.
*
* If `canReuse` throws or rejects, the navigation will be cancelled.
*
* ## Example
* ```
* @Directive({
* selector: 'my-cmp'
* })
* class MyCmp implements CanReuse, OnReuse {
* canReuse(next, prev) {
* return next.params.id == prev.params.id;
* }
*
* onReuse(next, prev) {
* this.id = next.params.id;
* }
* }
* ```
*/
interface CanReuse {
canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [canActivate], which is called by the router to determine
* if a component can be instantiated as part of a navigation.
*
* Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
* This is because [canActivate] is called before the component is instantiated.
*
* If `canActivate` returns or resolves to `false`, the navigation is cancelled.
*
* If `canActivate` throws or rejects, the navigation is also cancelled.
*
* ## Example
* ```
* @Directive({
* selector: 'control-panel-cmp'
* })
* @CanActivate(() => checkIfUserIsLoggedIn())
* class ControlPanelCmp {
* // ...
* }
* ```
*/
var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
ClassDecorator ;
/**
* `Instruction` is a tree of `ComponentInstructions`, with all the information needed
* to transition each component in the app to a given route, including all auxiliary routes.
*
* This is a public API.
*/
class Instruction {
component: ComponentInstruction;
child: Instruction;
auxInstruction: StringMap<string, Instruction>;
replaceChild(child: Instruction): Instruction;
}
/**
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
* composed of a tree of these `ComponentInstruction`s.
*
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
* to route lifecycle hooks, like {@link CanActivate}.
*
* `ComponentInstruction`s are [https://en.wikipedia.org/wiki/Hash_consing](hash consed). You should
* never construct one yourself with "new." Instead, rely on {@link PathRecognizer} to construct
* `ComponentInstruction`s.
*
* You should not modify this object. It should be treated as immutable.
*/
class ComponentInstruction {
reuse: boolean;
urlPath: string;
urlParams: string[];
params: StringMap<string, any>;
componentType: any;
resolveComponentType(): Promise<ng.Type>;
specificity: any;
terminal: any;
routeData(): Object;
}
/**
* This class represents a parsed URL
*/
class Url {
path: string;
child: Url;
auxiliary: Url[];
params: StringMap<string, any>;
toString(): string;
segmentToString(): string;
}
class OpaqueToken {
toString(): string;
}
const ROUTE_DATA : OpaqueToken ;
const ROUTER_DIRECTIVES : any[] ;
const ROUTER_BINDINGS : any[] ;
class Route implements RouteDefinition {
data: any;
path: string;
component: ng.Type;
as: string;
loader: Function;
redirectTo: string;
}
class Redirect implements RouteDefinition {
path: string;
redirectTo: string;
as: string;
loader: Function;
data: any;
}
class AuxRoute implements RouteDefinition {
data: any;
path: string;
component: ng.Type;
as: string;
loader: Function;
redirectTo: string;
}
class AsyncRoute implements RouteDefinition {
data: any;
path: string;
loader: Function;
as: string;
}
interface RouteDefinition {
path: string;
component?: ng.Type | ComponentDefinition;
loader?: Function;
redirectTo?: string;
as?: string;
data?: any;
}
var RouteConfig : (configs: RouteDefinition[]) => ClassDecorator ;
interface ComponentDefinition {
type: string;
loader?: Function;
component?: ng.Type;
}
}
declare module "angular2/router" {
export = ngRouter;
}
+277 -228
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular v2.0.0-alpha.36
// Type definitions for Angular v2.0.0-alpha.37
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -28,52 +28,75 @@ declare module ngRouter {
/**
* # Router
* The router is responsible for mapping URLs to components.
*
*
* You can see the state of the router by inspecting the read-only field `router.navigating`.
* This may be useful for showing a spinner, for instance.
*
*
* ## Concepts
* Routers and component instances have a 1:1 correspondence.
*
*
* The router holds reference to a number of "outlets." An outlet is a placeholder that the
* router dynamically fills in depending on the current URL.
*
*
* When the router navigates from a URL, it must first recognizes it and serialize it into an
* `Instruction`.
* The router uses the `RouteRegistry` to get an `Instruction`.
*/
class Router {
navigating: boolean;
lastNavigationAttempt: string;
registry: RouteRegistry;
parent: Router;
hostComponent: any;
/**
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
* component.
*/
childRouter(hostComponent: any): Router;
/**
* Register an object to notify of route changes. You probably don't need to use this unless
* you're writing a reusable component.
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
* component.
*/
registerOutlet(outlet: RouterOutlet): Promise<boolean>;
auxRouter(hostComponent: any): Router;
/**
* Register an outlet to notified of primary route changes.
*
* You probably don't need to use this unless you're writing a reusable component.
*/
registerPrimaryOutlet(outlet: RouterOutlet): Promise<boolean>;
/**
* Register an outlet to notified of auxiliary route changes.
*
* You probably don't need to use this unless you're writing a reusable component.
*/
registerAuxOutlet(outlet: RouterOutlet): Promise<boolean>;
/**
* Given an instruction, returns `true` if the instruction is currently active,
* otherwise `false`.
*/
isRouteActive(instruction: Instruction): boolean;
/**
* Dynamically update the routing configuration and trigger a navigation.
*
*
* # Usage
*
*
* ```
* router.config([
* { 'path': '/', 'component': IndexComp },
@@ -81,129 +104,153 @@ declare module ngRouter {
* ]);
* ```
*/
config(definitions: List<RouteDefinition>): Promise<any>;
config(definitions: RouteDefinition[]): Promise<any>;
/**
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
*
*
* If the given URL begins with a `/`, router will navigate absolutely.
* If the given URL does not begin with `/`, the router will navigate relative to this component.
*/
navigate(url: string, _skipLocationChange?: boolean): Promise<any>;
/**
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
* complete.
*/
navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
/**
* Updates this router and all descendant routers according to the given instruction
*/
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
/**
* Subscribe to URL updates from the router
*/
subscribe(onNext: (value: any) => void): Object;
/**
* Removes the contents of this router's outlet and all descendant outlets
*/
deactivate(instruction: Instruction): Promise<any>;
/**
* Given a URL, returns an instruction representing the component graph
*/
recognize(url: string): Promise<Instruction>;
/**
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
* router has yet to successfully navigate.
*/
renavigate(): Promise<any>;
/**
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
* app's base href.
*/
generate(linkParams: List<any>): Instruction;
generate(linkParams: any[]): Instruction;
}
class RootRouter extends Router {
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
}
/**
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
*
*
* ## Use
*
*
* ```
* <router-outlet></router-outlet>
* ```
*/
class RouterOutlet {
childRouter: Router;
name: string;
/**
* Given an instruction, update the contents of this outlet.
* Called by the Router to instantiate a new component during the commit phase of a navigation.
* This method in turn is responsible for calling the `onActivate` hook of its child.
*/
commit(instruction: Instruction): Promise<any>;
activate(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by Router during recognition phase
* Called by the {@link Router} during the commit phase of a navigation when an outlet
* reuses a component between different routes.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
canDeactivate(nextInstruction: Instruction): Promise<boolean>;
reuse(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by Router during recognition phase
* Called by the {@link Router} when an outlet reuses a component across navigations.
* This method in turn is responsible for calling the `onReuse` hook of its child.
*/
canReuse(nextInstruction: Instruction): Promise<boolean>;
deactivate(nextInstruction: Instruction): Promise<any>;
deactivate(nextInstruction: ComponentInstruction): Promise<any>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If this resolves to `false`, the given navigation is cancelled.
*
* This method delegates to the child component's `canDeactivate` hook if it exists,
* and otherwise resolves to true.
*/
canDeactivate(nextInstruction: ComponentInstruction): Promise<boolean>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
*
* If the new child component has a different Type than the existing child component,
* this will resolve to `false`. You can't reuse an old component when the new component
* is of a different Type.
*
* Otherwise, this method delegates to the child component's `canReuse` hook if it exists,
* or resolves to true if the hook is not present.
*/
canReuse(nextInstruction: ComponentInstruction): Promise<boolean>;
}
/**
* The RouterLink directive lets you link to specific parts of your app.
*
*
* Consider the following route configuration:
*
*
* ```
* @RouteConfig([
* { path: '/user', component: UserCmp, as: 'user' }
* ]);
* class MyComp {}
* ```
*
*
* When linking to this `user` route, you can write:
*
*
* ```
* <a [router-link]="['./user']">link to user component</a>
* ```
*
*
* RouterLink expects the value to be an array of route names, followed by the params
* for that level of routing. For instance `['/team', {teamId: 1}, 'user', {userId: 2}]`
* means that we want to generate a link for the `team` route with params `{teamId: 1}`,
* and with a child route `user` with params `{userId: 2}`.
*
*
* The first route name should be prepended with `/`, `./`, or `../`.
* If the route begins with `/`, the router will look up the route from the root of the app.
* If the route begins with `./`, the router will instead look in the current component's
@@ -211,21 +258,23 @@ declare module ngRouter {
* current component's parent.
*/
class RouterLink {
visibleHref: string;
isRouteActive: boolean;
routeParams: any;
onClick(): boolean;
}
class RouteParams {
params: StringMap<string, string>;
get(param: string): string;
}
/**
* The RouteRegistry holds route configurations for each component in an Angular app.
@@ -233,83 +282,83 @@ declare module ngRouter {
* parameters.
*/
class RouteRegistry {
/**
* Given a component and a configuration object, add the route to this registry
*/
config(parentComponent: any, config: RouteDefinition): void;
/**
* Reads the annotations of a component and configures the registry based on them
*/
configFromComponent(component: any): void;
/**
* Given a URL and a parent component, return the most specific instruction for navigating
* the application into the state specified by the url
*/
recognize(url: string, parentComponent: any): Promise<Instruction>;
/**
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
* generates a url with a leading slash relative to the provided `parentComponent`.
*/
generate(linkParams: List<any>, parentComponent: any): Instruction;
generate(linkParams: any[], parentComponent: any): Instruction;
}
class LocationStrategy {
path(): string;
pushState(ctx: any, title: string, url: string): void;
forward(): void;
back(): void;
onPopState(fn: (_: any) => any): void;
getBaseHref(): string;
}
class HashLocationStrategy extends LocationStrategy {
onPopState(fn: EventListener): void;
getBaseHref(): string;
path(): string;
pushState(state: any, title: string, url: string): void;
forward(): void;
back(): void;
}
class PathLocationStrategy extends LocationStrategy {
onPopState(fn: EventListener): void;
getBaseHref(): string;
path(): string;
pushState(state: any, title: string, url: string): void;
forward(): void;
back(): void;
}
/**
* This is the service that an application developer will directly interact with.
*
*
* Responsible for normalizing the URL against the application's base href.
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
* trailing slash:
@@ -318,47 +367,49 @@ declare module ngRouter {
* - `/my/app/user/123/` **is not** normalized
*/
class Location {
platformStrategy: LocationStrategy;
path(): string;
normalize(url: string): string;
normalizeAbsolutely(url: string): string;
go(url: string): void;
forward(): void;
back(): void;
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void;
}
const APP_BASE_HREF : OpaqueToken ;
/**
* Responsible for performing each step of navigation.
* "Steps" are conceptually similar to "middleware"
*/
class Pipeline {
steps: List<Function>;
steps: Function[];
process(instruction: Instruction): Promise<any>;
}
/**
* Defines route lifecycle method [onActivate], which is called by the router at the end of a
* successful route navigation.
*
*
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
* depending on the result of [canReuse].
*
*
* If `onActivate` returns a promise, the route change will wait until the promise settles to
* instantiate and activate child components.
*
*
* ## Example
* ```
* @Directive({
@@ -372,17 +423,17 @@ declare module ngRouter {
* ```
*/
interface OnActivate {
onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [onDeactivate], which is called by the router before destroying
* a component as part of a route change.
*
*
* If `onDeactivate` returns a promise, the route change will wait until the promise settles.
*
*
* ## Example
* ```
* @Directive({
@@ -392,7 +443,7 @@ declare module ngRouter {
* canReuse() {
* return true;
* }
*
*
* onReuse(next, prev) {
* this.params = next.params;
* }
@@ -400,18 +451,18 @@ declare module ngRouter {
* ```
*/
interface OnDeactivate {
onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [onReuse], which is called by the router at the end of a
* successful route navigation when [canReuse] is implemented and returns or resolves to true.
*
*
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
* depending on the result of [canReuse].
*
*
* ## Example
* ```
* @Directive({
@@ -421,7 +472,7 @@ declare module ngRouter {
* canReuse() {
* return true;
* }
*
*
* onReuse(next, prev) {
* this.params = next.params;
* }
@@ -429,19 +480,19 @@ declare module ngRouter {
* ```
*/
interface OnReuse {
onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [canDeactivate], which is called by the router to determine
* if a component can be removed as part of a navigation.
*
*
* If `canDeactivate` returns or resolves to `false`, the navigation is cancelled.
*
*
* If `canDeactivate` throws or rejects, the navigation is also cancelled.
*
*
* ## Example
* ```
* @Directive({
@@ -455,19 +506,19 @@ declare module ngRouter {
* ```
*/
interface CanDeactivate {
canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [canReuse], which is called by the router to determine whether a
* component should be reused across routes, or whether to destroy and instantiate a new component.
*
*
* If `canReuse` returns or resolves to `true`, the component instance will be reused.
*
*
* If `canReuse` throws or rejects, the navigation will be cancelled.
*
*
* ## Example
* ```
* @Directive({
@@ -477,7 +528,7 @@ declare module ngRouter {
* canReuse(next, prev) {
* return next.params.id == prev.params.id;
* }
*
*
* onReuse(next, prev) {
* this.id = next.params.id;
* }
@@ -485,22 +536,22 @@ declare module ngRouter {
* ```
*/
interface CanReuse {
canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
}
/**
* Defines route lifecycle method [canActivate], which is called by the router to determine
* if a component can be instantiated as part of a navigation.
*
*
* Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
* This is because [canActivate] is called before the component is instantiated.
*
*
* If `canActivate` returns or resolves to `false`, the navigation is cancelled.
*
*
* If `canActivate` throws or rejects, the navigation is also cancelled.
*
*
* ## Example
* ```
* @Directive({
@@ -514,172 +565,170 @@ declare module ngRouter {
*/
var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
ClassDecorator ;
/**
* `Instruction` is a tree of `ComponentInstructions`, with all the information needed
* to transition each component in the app to a given route, including all auxiliary routes.
*
*
* This is a public API.
*/
class Instruction {
component: ComponentInstruction;
child: Instruction;
auxInstruction: StringMap<string, Instruction>;
replaceChild(child: Instruction): Instruction;
}
/**
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
* composed of a tree of these `ComponentInstruction`s.
*
*
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
* to route lifecycle hooks, like {@link CanActivate}.
*
* `ComponentInstruction`s are [https://en.wikipedia.org/wiki/Hash_consing](hash consed). You should
* never construct one yourself with "new." Instead, rely on {@link PathRecognizer} to construct
* `ComponentInstruction`s.
*
* You should not modify this object. It should be treated as immutable.
*/
class ComponentInstruction {
reuse: boolean;
urlPath: string;
urlParams: List<string>;
urlParams: string[];
params: StringMap<string, any>;
componentType: any;
resolveComponentType(): Promise<Type>;
resolveComponentType(): Promise<ng.Type>;
specificity: any;
terminal: any;
routeData(): Object;
}
class Url {
path: string;
child: Url;
auxiliary: List<Url>;
params: StringMap<string, any>;
toString(): string;
segmentToString(): string;
}
class OpaqueToken {
toString(): string;
}
/**
* Runtime representation of a type.
*
* In JavaScript a Type is a constructor function.
* This class represents a parsed URL
*/
interface Type extends Function {
new(args: any): any;
class Url {
path: string;
child: Url;
auxiliary: Url[];
params: StringMap<string, any>;
toString(): string;
segmentToString(): string;
}
class OpaqueToken {
toString(): string;
}
const ROUTE_DATA : OpaqueToken ;
const ROUTER_DIRECTIVES : List<any> ;
const ROUTER_BINDINGS : List<any> ;
const ROUTER_DIRECTIVES : any[] ;
const ROUTER_BINDINGS : any[] ;
class Route implements RouteDefinition {
data: any;
path: string;
component: Type;
component: ng.Type;
as: string;
loader: Function;
redirectTo: string;
}
class Redirect implements RouteDefinition {
path: string;
redirectTo: string;
as: string;
loader: Function;
data: any;
}
class AuxRoute implements RouteDefinition {
data: any;
path: string;
component: Type;
component: ng.Type;
as: string;
loader: Function;
redirectTo: string;
}
class AsyncRoute implements RouteDefinition {
data: any;
path: string;
loader: Function;
as: string;
}
interface RouteDefinition {
path: string;
component?: Type | ComponentDefinition;
component?: ng.Type | ComponentDefinition;
loader?: Function;
redirectTo?: string;
as?: string;
data?: any;
}
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
var RouteConfig : (configs: RouteDefinition[]) => ClassDecorator ;
interface ComponentDefinition {
type: string;
loader?: Function;
component?: Type;
component?: ng.Type;
}
}
declare module "angular2/router" {
+1 -1
View File
@@ -16,7 +16,7 @@ declare module ngtoaster {
error(params: IPopParams): void
error(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
toasterId?:number): void
into(params: IPopParams): void
info(params: IPopParams): void
info(title?:string, body?:string, timeout?:number, bodyOutputType?:string, clickHandler?:EventListener,
toasterId?:number): void
wait(params: IPopParams): void
+2 -2
View File
@@ -30,11 +30,11 @@ declare module angular.animate {
/**
* Globally enables / disables animations.
*
* @param value If provided then set the animation on or off.
* @param element If provided then the element will be used to represent the enable/disable operation.
* @param value If provided then set the animation on or off.
* @returns current animation state
*/
enabled(value?: boolean, element?: JQuery): boolean;
enabled(element?: JQuery, value?: boolean): boolean;
/**
* Performs an inline animation on the element.
+16
View File
@@ -933,3 +933,19 @@ function NgModelControllerTyping() {
});
};
}
function ngFilterTyping() {
var $filter: angular.IFilterService;
var items: string[];
$filter("name")(items, "test");
$filter("name")(items, {name: "test"});
$filter("name")(items, (val, index, array) => {
return array;
});
$filter("name")(items, (val, index, array) => {
return array;
}, (actual, expected) => {
return actual == expected;
});
}
+101 -57
View File
@@ -782,7 +782,23 @@ declare module angular {
*
* @param name Name of the filter function to retrieve
*/
(name: string): Function;
(name: string): IFilterFunc;
}
interface IFilterFunc {
<T>(array: T[], expression: string | IFilterPatternObject | IFilterPredicateFunc<T>, comparator?: IFilterComparatorFunc<T>|boolean): T[];
}
interface IFilterPatternObject {
[name: string]: string;
}
interface IFilterPredicateFunc<T> {
(value: T, index: number, array: T[]): T[];
}
interface IFilterComparatorFunc<T> {
(actual: T, expected: T): boolean;
}
/**
@@ -1312,51 +1328,25 @@ declare module angular {
/**
* Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
*/
defaults: IRequestConfig;
defaults: IHttpProviderDefaults;
/**
* Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
*/
pendingRequests: any[];
pendingRequests: IRequestConfig[];
}
/**
* Object describing the request to be made and how it should be processed.
* see http://docs.angularjs.org/api/ng/service/$http#usage
*/
interface IRequestShortcutConfig {
interface IRequestShortcutConfig extends IHttpProviderDefaults {
/**
* {Object.<string|Object>}
* Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.
*/
params?: any;
/**
* Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent.
*/
headers?: any;
/**
* Name of HTTP header to populate with the XSRF token.
*/
xsrfHeaderName?: string;
/**
* Name of cookie containing the XSRF token.
*/
xsrfCookieName?: string;
/**
* {boolean|Cache}
* If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching.
*/
cache?: any;
/**
* whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information.
*/
withCredentials?: boolean;
/**
* {string|Object}
* Data to be sent as the request message data.
@@ -1364,25 +1354,12 @@ declare module angular {
data?: any;
/**
* {function(data, headersGetter)|Array.<function(data, headersGetter)>}
* Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version.
*/
transformRequest?: any;
/**
* {function(data, headersGetter)|Array.<function(data, headersGetter)>}
* Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version.
*/
transformResponse?: any;
/**
* {number|Promise}
* Timeout in milliseconds, or promise that should abort the request when resolved.
*/
timeout?: any;
timeout?: number|IPromise<any>;
/**
* See requestType.
* See [XMLHttpRequest.responseType]https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype
*/
responseType?: string;
}
@@ -1425,31 +1402,98 @@ declare module angular {
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>|TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
}
// See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228
interface IHttpResquestTransformer {
(data: any, headersGetter: IHttpHeadersGetter): any;
}
// The definition of fields are the same as IHttpPromiseCallbackArg
interface IHttpResponseTransformer {
(data: any, headersGetter: IHttpHeadersGetter, status: number): any;
}
interface IHttpRequestConfigHeaders {
[requestType: string]: string|(() => string);
common?: string|(() => string);
get?: string|(() => string);
post?: string|(() => string);
put?: string|(() => string);
patch?: string|(() => string);
}
/**
* Object that controls the defaults for $http provider
* Object that controls the defaults for $http provider. Not all fields of IRequestShortcutConfig can be configured
* via defaults and the docs do not say which. The following is based on the inspection of the source code.
* https://docs.angularjs.org/api/ng/service/$http#defaults
* https://docs.angularjs.org/api/ng/service/$http#usage
* https://docs.angularjs.org/api/ng/provider/$httpProvider The properties section
*/
interface IHttpProviderDefaults {
cache?: boolean;
/**
* {boolean|Cache}
* If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching.
*/
cache?: any;
/**
* Transform function or an array of such functions. The transform function takes the http request body and
* headers and returns its transformed (typically serialized) version.
* @see {@link https://docs.angularjs.org/api/ng/service/$http#transforming-requests-and-responses}
*/
transformRequest?: ((data: any, headersGetter?: any) => any)|((data: any, headersGetter?: any) => any)[];
xsrfCookieName?: string;
transformRequest?: IHttpResquestTransformer |IHttpResquestTransformer[];
/**
* Transform function or an array of such functions. The transform function takes the http response body and
* headers and returns its transformed (typically deserialized) version.
*/
transformResponse?: IHttpResponseTransformer | IHttpResponseTransformer[];
/**
* Map of strings or functions which return strings representing HTTP headers to send to the server. If the
* return value of a function is null, the header will not be sent.
* The key of the map is the request verb in lower case. The "common" key applies to all requests.
* @see {@link https://docs.angularjs.org/api/ng/service/$http#setting-http-headers}
*/
headers?: IHttpRequestConfigHeaders;
/** Name of HTTP header to populate with the XSRF token. */
xsrfHeaderName?: string;
/** Name of cookie containing the XSRF token. */
xsrfCookieName?: string;
/**
* whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information.
*/
withCredentials?: boolean;
headers?: {
common?: any;
post?: any;
put?: any;
patch?: any;
}
/**
* A function used to the prepare string representation of request parameters (specified as an object). If
* specified as string, it is interpreted as a function registered with the $injector. Defaults to
* $httpParamSerializer.
*/
paramSerializer?: string | ((obj: any) => string);
}
interface IHttpInterceptor {
request?: (config: IRequestConfig) => IRequestConfig|IPromise<IRequestConfig>;
requestError?: (rejection: any) => any;
response?: <T>(response: IHttpPromiseCallbackArg<T>) => IPromise<T>|T;
responseError?: (rejection: any) => any;
}
interface IHttpInterceptorFactory {
(...args: any[]): IHttpInterceptor;
}
interface IHttpProvider extends IServiceProvider {
defaults: IHttpProviderDefaults;
interceptors: any[];
/**
* Register service factories (names or implementations) for interceptors which are called before and after
* each request.
*/
interceptors: (string|IHttpInterceptorFactory|(string|IHttpInterceptorFactory)[])[];
useApplyAsync(): boolean;
useApplyAsync(value: boolean): IHttpProvider;
@@ -1693,7 +1737,7 @@ declare module angular {
interface IInjectorService {
annotate(fn: Function): string[];
annotate(inlineAnnotatedFunction: any[]): string[];
get<T>(name: string): T;
get<T>(name: string, caller?: string): T;
has(name: string): boolean;
instantiate<T>(typeConstructor: Function, locals?: any): T;
invoke(inlineAnnotatedFunction: any[]): any;
+1
View File
@@ -19,6 +19,7 @@ declare module Backbone {
interface NavigateOptions {
trigger?: boolean;
replace?: boolean;
}
interface RouterOptions {
+47
View File
@@ -550,6 +550,13 @@ fooArrProm = fooArrProm.filter<Foo>((item: Foo) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooArrProm = fooArrProm.each<Foo, Bar>((item: Foo): Bar => bar);
fooArrProm = fooArrProm.each<Foo, Bar>((item: Foo, index: number): Bar => index ? bar : null);
fooArrProm = fooArrProm.each<Foo, Bar>((item: Foo, index: number, arrayLength: number): Bar => bar);
fooArrProm = fooArrProm.each<Foo, Bar>((item: Foo, index: number, arrayLength: number): Promise<Bar> => barProm);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.try(() => {
return foo;
@@ -1123,3 +1130,43 @@ fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: numb
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// each()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArrThen
fooArrThen = Promise.each(fooThenArrThen, (item: Foo) => bar);
fooArrThen = Promise.each(fooThenArrThen, (item: Foo) => barThen);
fooArrThen = Promise.each(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => bar);
fooArrThen = Promise.each(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => barThen);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArrThen
fooArrThen = Promise.each(fooArrThen, (item: Foo) => bar);
fooArrThen = Promise.each(fooArrThen, (item: Foo) => barThen);
fooArrThen = Promise.each(fooArrThen, (item: Foo, index: number, arrayLength: number) => bar);
fooArrThen = Promise.each(fooArrThen, (item: Foo, index: number, arrayLength: number) => barThen);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArr
fooArrThen = Promise.each(fooThenArr, (item: Foo) => bar);
fooArrThen = Promise.each(fooThenArr, (item: Foo) => barThen);
fooArrThen = Promise.each(fooThenArr, (item: Foo, index: number, arrayLength: number) => bar);
fooArrThen = Promise.each(fooThenArr, (item: Foo, index: number, arrayLength: number) => barThen);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArr
fooArrThen = Promise.each(fooArr, (item: Foo) => bar);
fooArrThen = Promise.each(fooArr, (item: Foo) => barThen);
fooArrThen = Promise.each(fooArr, (item: Foo, index: number, arrayLength: number) => bar);
fooArrThen = Promise.each(fooArr, (item: Foo, index: number, arrayLength: number) => barThen);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+17
View File
@@ -328,6 +328,11 @@ declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>, options?: Promise.ConcurrencyOption): Promise<U[]>;
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean, options?: Promise.ConcurrencyOption): Promise<U[]>;
/**
* Same as calling ``Promise.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
each<R, U>(iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable<U>): Promise<R[]>;
/**
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
*
@@ -607,6 +612,18 @@ declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
// array with values
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>, option?: Promise.ConcurrencyOption): Promise<R[]>;
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise<R[]>;
/**
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
*
* Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*/
// promise of array with promises of value
static each<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable<U>): Promise<R[]>;
// array with promises of value
static each<R, U>(values: Promise.Thenable<R>[], iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable<U>): Promise<R[]>;
// array with values OR promise of array with values
static each<R, U>(values: R[] | Promise.Thenable<R[]>, iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable<U>): Promise<R[]>;
}
declare module Promise {
+1 -1
View File
@@ -27,7 +27,7 @@ interface LinearChartData {
interface CircularChartData {
value: number;
color: string;
color?: string;
highlight?: string;
label?: string;
}
+9
View File
@@ -245,3 +245,12 @@ function contentSettings() {
}
});
}
// https://developer.chrome.com/extensions/runtime#method-openOptionsPage
function testOptionsPage() {
chrome.runtime.openOptionsPage();
chrome.runtime.openOptionsPage(function() {
// Do a thing ...
});
}
+1
View File
@@ -1649,6 +1649,7 @@ declare module chrome.runtime {
export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void;
export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void;
export function getURL(path: string): string;
export function openOptionsPage(callback?: () => void): void;
export function reload(): void;
export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void;
export function restart(): void;
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="codemirror.d.ts" />
/// <reference path="searchcursor.d.ts" />
var doc = new CodeMirror.Doc('text some string and another text match');
var cursor = doc.getSearchCursor('text', new CodeMirror.Pos(0,0), false);
cursor = doc.getSearchCursor('text', new CodeMirror.Pos(0,0));
cursor = doc.getSearchCursor('text');
cursor.find(false);
cursor.findNext();
cursor.findPrevious();
cursor.from();
cursor.to();
cursor.replace("blah");
cursor.replace("text", "origin");
+45
View File
@@ -0,0 +1,45 @@
// Type definitions for CodeMirror
// Project: https://github.com/marijnh/CodeMirror
// Definitions by: jacqt <https://github.com/jacqt>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module CodeMirror {
interface Doc {
/** This method can be used to implement search/replace functionality.
* `query`: This can be a regular * expression or a string (only strings will match across lines -
* if they contain newlines).
* `start`: This provides the starting position of the search. It can be a `{line, ch} object,
* or can be left off to default to the start of the document
* `caseFold`: This is only relevant when matching a string. IT will cause the search to be case-insenstive */
getSearchCursor(query: string | RegExp, start?: Position, caseFold?: boolean): SearchCursor;
}
interface SearchCursor {
/** Searches forward or backward from the current position. The return value indicates whether a match was
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
* you want to extract matched groups */
find(reverse: boolean): boolean | any[];
/** Searches forward from the current position. The return value indicates whether a match was
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
* you want to extract matched groups */
findNext(): boolean | any[];
/** Searches backward from the current position. The return value indicates whether a match was
* found. If matching a regular expression, the return value will be the array returned by the match method, in case
* you want to extract matched groups */
findPrevious(): boolean | any[];
/** Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch}
* objects pointing the start of the match. */
from(): Position;
/** Only valid when the last call to find, findNext, or findPrevious did not return false. Returns {line, ch}
* objects pointing the end of the match. */
to(): Position;
/** Replaces the currently found match with the given text and adjusts the cursor position to reflect the deplacement. */
replace(text: string, origin?: string): void;
}
}
+30
View File
@@ -0,0 +1,30 @@
/// <reference path="config.d.ts" />
import config = require('config');
var value1: string = config.get<string>("");
var value2: any = config.get("");
var has: boolean = config.has("");
// util tests:
var extended1: any = config.util.extendDeep({}, {});
var extended2: any = config.util.extendDeep({}, {}, 20);
var clone1: any = config.util.cloneDeep({});
var clone2: any = config.util.cloneDeep({}, 20);
var equals1: boolean = config.util.equalsDeep({}, {});
var equals2: boolean = config.util.equalsDeep({}, {}, 20);
var diff1: any = config.util.diffDeep({}, {});
var diff2: any = config.util.diffDeep({}, {}, 20);
var immutable1: any = config.util.makeImmutable({});
var immutable2: any = config.util.makeImmutable({}, "");
var immutable3: any = config.util.makeImmutable({}, "", "");
var hidden1: any = config.util.makeHidden({}, "");
var hidden2: any = config.util.makeHidden({}, "", "");
var env: string = config.util.getEnv("");
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for node-config
// Project: https://github.com/lorenwest/node-config
// Definitions by: Roman Korneev <https://github.com/RWander>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "config" {
// see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities
interface IUtil {
// Extend an object (and any object it contains) with one or more objects (and objects contained in them).
extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any;
// Return a deep copy of the specified object.
cloneDeep(copyFrom: any, depth?: number): any;
// Return true if two objects have equal contents.
equalsDeep(object1: any, object2: any, dept?: number): boolean;
// Returns an object containing all elements that differ between two objects.
diffDeep(object1: any, object2: any, depth?: number): any;
// Make a javascript object property immutable (assuring it cannot be changed from the current value).
makeImmutable(object: any, propertyName?: string, propertyValue?: string): any;
// Make an object property hidden so it doesn't appear when enumerating elements of the object.
makeHidden(object: any, propertyName: string, propertyValue?: string): any;
// Get the current value of a config environment variable
getEnv(varName: string): string;
}
export function get<T>(setting: string): T;
export function has(setting: string): boolean;
export var util: IUtil;
}
+2
View File
@@ -7,4 +7,6 @@ cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
cordova.plugins.Keyboard.close();
cordova.plugins.Keyboard.disableScroll(true);
cordova.plugins.Keyboard.disableScroll(false);
cordova.plugins.Keyboard.show();
cordova.plugins.Keyboard.close();
console.log(cordova.plugins.Keyboard.isVisible);
+8
View File
@@ -17,6 +17,14 @@ declare module Ionic {
* Close the keyboard if it is open.
*/
close(): void;
/**
* Force keyboard to be shown on Android.
* This typically helps if autofocus on a text element does not pop up the keyboard automatically
*
* Supported Platforms: Android, Blackberry 10
*/
show(): void;
/**
* Disable native scrolling, useful if you are using JavaScript to scroll
@@ -0,0 +1,19 @@
/// <reference path="../cordova/cordova.d.ts" />
/// <reference path="./cordova-plugin-app-version.d.ts" />
cordova.getAppVersion.getAppName()
.then(appName=> {
console.log(appName)
});
cordova.getAppVersion.getPackageName()
.then(packageName=> {
console.log(packageName);
});
cordova.getAppVersion.getVersionCode()
.then(versionCode=> {
console.log(versionCode);
});
cordova.getAppVersion.getVersionNumber()
.then(versionNumber=> {
console.log(versionNumber);
});
@@ -0,0 +1,15 @@
// Type definitions for cordova-plugin-app-version v0.1.7
// Project: https://github.com/whiteoctober/cordova-plugin-app-version
// Definitions by: Markus Wagner <https://github.com/Ritzlgrmft/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../q/Q.d.ts" />
interface Cordova {
getAppVersion: {
getAppName: () => Q.IPromise<string>;
getPackageName: () => Q.IPromise<string>;
getVersionCode: () => Q.IPromise<string>;
getVersionNumber: () => Q.IPromise<string>;
};
}
@@ -0,0 +1,62 @@
/// <reference path="../cordova/cordova.d.ts" />
/// <reference path="./cordova-plugin-ibeacon.d.ts" />
function registerDelegates() {
cordova.plugins.locationManager.enableDebugLogs();
cordova.plugins.locationManager.delegate.didRangeBeaconsInRegion = (pluginResult) => didRangeBeaconsInRegion(pluginResult);
cordova.plugins.locationManager.delegate.didEnterRegion = (pluginResult) => didEnterRegion(pluginResult);
cordova.plugins.locationManager.delegate.didExitRegion = (pluginResult) => didExitRegion(pluginResult);
cordova.plugins.locationManager.delegate.didDetermineStateForRegion = (pluginResult) => didDetermineStateForRegion(pluginResult);
cordova.plugins.locationManager.delegate.didChangeAuthorizationStatus = (authorizationStatus) => didChangeAuthorizationStatus(authorizationStatus);
cordova.plugins.locationManager.delegate.didStartMonitoringForRegion = (pluginResult) => didStartMonitoringForRegion(pluginResult);
cordova.plugins.locationManager.delegate.monitoringDidFailForRegionWithError = (pluginResult) => monitoringDidFailForRegionWithError(pluginResult);
cordova.plugins.locationManager.onDomDelegateReady();
}
function didRangeBeaconsInRegion(pluginResult: BeaconPlugin.PluginResult): void {
for (var beacon of pluginResult.beacons) {
console.log(beacon.uuid, beacon.major, beacon.minor, beacon.accuracy, beacon.proximity, beacon.rssi, beacon.tx);
}
}
function didEnterRegion(pluginResult: BeaconPlugin.PluginResult): void {
var region: BeaconPlugin.Region = new cordova.plugins.locationManager.BeaconRegion("identifier", "uuid", 1, 2);;
cordova.plugins.locationManager.startRangingBeaconsInRegion(this.createBeaconRegionFromPluginResult(pluginResult))
.then(() => {
console.log("startRangingBeaconsInRegion succeeded");
})
.catch((reason: any) => {
console.error("startRangingBeaconsInRegion failed: " + reason);
});
}
function didExitRegion(pluginResult: BeaconPlugin.PluginResult): void {
var region: BeaconPlugin.Region;
cordova.plugins.locationManager.stopRangingBeaconsInRegion(region)
.then(() => {
console.log("stopRangingBeaconsInRegion succeeded");
})
.catch((reason: any) => {
console.error("stopRangingBeaconsInRegion failed: " + reason);
});
}
function didDetermineStateForRegion(pluginResult: BeaconPlugin.PluginResult): void {
if (pluginResult.state === "CLRegionStateInside") {
console.log(pluginResult.region.identifier);
}
}
function didChangeAuthorizationStatus(authorizationStatus: string): void {
console.log(authorizationStatus);
}
function didStartMonitoringForRegion(pluginResult: BeaconPlugin.PluginResult): void {
console.log(pluginResult.region.identifier);
}
function monitoringDidFailForRegionWithError(pluginResult: BeaconPlugin.PluginResult): void {
console.log(pluginResult.region.identifier);
}
+95
View File
@@ -0,0 +1,95 @@
// Type definitions for cordova-plugin-ibeacon v3.3.0
// Project: https://github.com/petermetz/cordova-plugin-ibeacon
// Definitions by: Markus Wagner <https://github.com/Ritzlgrmft/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../q/Q.d.ts" />
interface CordovaPlugins {
locationManager: BeaconPlugin.LocationManager;
}
declare module BeaconPlugin {
/**
* Beacon Plugin.
*/
export interface LocationManager {
delegate: Delegate;
BeaconRegion: BeaconRegion;
onDomDelegateReady(): void;
startMonitoringForRegion(region: Region): Q.Promise<void>;
stopMonitoringForRegion(region: Region): Q.Promise<void>;
requestStateForRegion(region: Region): Q.Promise<void>;
startRangingBeaconsInRegion(region: Region): Q.Promise<void>;
stopRangingBeaconsInRegion(region: Region): Q.Promise<void>;
getAuthorizationStatus(): Q.Promise<PluginResult>;
requestWhenInUseAuthorization(): Q.Promise<void>;
requestAlwaysAuthorization(): Q.Promise<void>;
getMonitoredRegions(): Q.Promise<Region[]>;
getRangedRegions(): Q.Promise<Region[]>;
isRangingAvailable(): Q.Promise<boolean>;
isMonitoringAvailableForClass(region: Region): Q.Promise<boolean>;
startAdvertising(region: Region, measuredPower: boolean): Q.Promise<void>;
stopAdvertising(): Q.Promise<void>;
isAdvertisingAvailable(): Q.Promise<boolean>;
isAdvertising(): Q.Promise<boolean>;
disableDebugLogs(): Q.Promise<void>;
enableDebugNotifications(): Q.Promise<void>;
disableDebugNotifications(): Q.Promise<void>;
enableDebugLogs(): Q.Promise<void>;
isBluetoothEnabled(): Q.Promise<boolean>;
enableBluetooth(): Q.Promise<void>;
disableBluetooth(): Q.Promise<void>;
appendToDeviceLog(message: string): Q.Promise<string>;
}
export interface PluginResult {
eventType: string;
region: Region;
beacons: Beacon[];
authorizationStatus: string;
state: string;
}
export interface Delegate {
didDetermineStateForRegion(pluginResult: PluginResult): void;
didStartMonitoringForRegion(pluginResult: PluginResult): void;
didExitRegion(pluginResult: PluginResult): void;
didEnterRegion(pluginResult: PluginResult): void;
didRangeBeaconsInRegion(pluginResult: PluginResult): void;
peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void;
peripheralManagerDidUpdateState(pluginResult: PluginResult): void;
didChangeAuthorizationStatus(authorizationStatus: string): void;
monitoringDidFailForRegionWithError(pluginResult: PluginResult): void;
}
export interface Region {
identifier: string;
new (identifier: string): Region;
}
export interface BeaconRegion extends Region {
uuid: string;
major: string;
minor: string;
notifyEntryStateOnDisplay: boolean;
new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion;
}
export interface CircularRegion extends Region {
latitude: number;
longitude: number;
radius: number;
new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion;
}
export interface Beacon {
uuid: string;
major: string;
minor: string;
proximity: string;
tx: number;
rssi: number;
accuracy: number;
}
}
+169
View File
@@ -0,0 +1,169 @@
/// <reference path="core-decorators.d.ts" />
//
// @autobind
//
import { autobind } from 'core-decorators';
class Person {
@autobind
getPerson() {
return this;
}
}
let person = new Person();
let getPerson = person.getPerson;
getPerson() === person;
//
// @readonly
//
import { readonly } from 'core-decorators';
class Meal {
@readonly
entree: string = 'steak';
}
var dinner = new Meal();
dinner.entree = 'salmon';
//
// @override
//
import { override } from 'core-decorators';
class Parent {
speak(first: string, second: string) {}
}
class Child extends Parent {
@override
speak() {}
// SyntaxError: Child#speak() does not properly override Parent#speak(first, second)
}
// or
class Child2 extends Parent {
@override
speaks() {}
// SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain.
//
// Did you mean "speak"?
}
//
// @deprecate (alias: @deprecated)
//
import { deprecate, deprecated } from 'core-decorators';
class Person2 {
@deprecate
facepalm() {}
@deprecate('We stopped facepalming')
facepalmHard() {}
@deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' })
facepalmHarder() {}
}
let person2 = new Person2();
person2.facepalm();
// DEPRECATION Person#facepalm: This function will be removed in future versions.
person2.facepalmHard();
// DEPRECATION Person#facepalmHard: We stopped facepalming
person2.facepalmHarder();
// DEPRECATION Person#facepalmHarder: We stopped facepalming
//
// See http://knowyourmeme.com/memes/facepalm for more details.
//
//
// @debounce
//
import { debounce } from 'core-decorators';
class Editor {
content = '';
@debounce(500)
updateContent(content: string) {
this.content = content;
}
}
//
// @suppressWarnings
//
import { suppressWarnings } from 'core-decorators';
class Person3 {
@deprecated
facepalm() {}
@suppressWarnings
facepalmWithoutWarning() {
this.facepalm();
}
}
let person3 = new Person3();
person3.facepalmWithoutWarning();
// no warning is logged
//
// @nonenumerable
//
import { nonenumerable } from 'core-decorators';
class Meal2 {
entree = 'steak';
@nonenumerable
cost: number = 4.44;
}
var dinner2 = new Meal2();
for (var key in dinner2) {
key;
// "entree" only, not "cost"
}
Object.keys(dinner2);
// ["entree"]
//
// @nonconfigurable
//
import { nonconfigurable } from 'core-decorators';
class Meal3 {
@nonconfigurable
entree: string = 'steak';
}
var dinner3 = new Meal3();
Object.defineProperty(dinner3, 'entree', {
enumerable: false
});
// Cannot redefine property: entree
@@ -0,0 +1 @@
--experimentalDecorators --noImplicitAny --target ES5
+89
View File
@@ -0,0 +1,89 @@
// Type definitions for core-decorators.js v0.1.5
// Project: https://github.com/jayphelps/core-decorators.js
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "core-decorators" {
export interface ClassDecorator {
<TFunction extends Function>(target: TFunction): TFunction|void;
}
export interface ParameterDecorator {
(target: Object, propertyKey: string|symbol, parameterIndex: number): void;
}
export interface PropertyDecorator {
(target: Object, propertyKey: string|symbol): void;
}
export interface MethodDecorator {
<T>(target: Object, propertyKey: string|symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>|void;
}
export interface PropertyOrMethodDecorator extends MethodDecorator, PropertyDecorator {
(target: Object, propertyKey: string|symbol): void;
}
export interface Deprecate extends MethodDecorator {
(message?: string, option?: DeprecateOption): MethodDecorator;
}
export interface DeprecateOption {
url: string;
}
/**
* Forces invocations of this function to always have this refer to the class instance,
* even if the function is passed around or would otherwise lose its this context. e.g. var fn = context.method;
*/
var autobind: MethodDecorator;
/**
* Marks a property or method as not being writable.
*/
var readonly: PropertyOrMethodDecorator;
/**
* Checks that the marked method indeed overrides a function with the same signature somewhere on the prototype chain.
*/
var override: MethodDecorator;
/**
* Calls console.warn() with a deprecation message. Provide a custom message to override the default one. You can also provide an options hash with a url, for further reading.
*/
var deprecate: Deprecate;
/**
* Calls console.warn() with a deprecation message. Provide a custom message to override the default one. You can also provide an options hash with a url, for further reading.
*/
var deprecated: Deprecate;
/**
* Creates a new debounced function which will be invoked after wait milliseconds since the time it was invoked. Default timeout is 300 ms.
*/
var debounce: (wait: number) => MethodDecorator;
/**
* Suppresses any JavaScript console.warn() call while the decorated function is called. (i.e. on the stack)
*/
var suppressWarnings: MethodDecorator;
/**
* Marks a property or method as not being enumerable.
*/
var nonenumerable: PropertyOrMethodDecorator;
/**
* Marks a property or method as not being writable.
*/
var nonconfigurable: PropertyOrMethodDecorator;
/**
* Initial implementation included, likely slow. WIP.
*/
var memoize: MethodDecorator;
export {
autobind,
readonly,
override,
deprecate,
deprecated,
debounce,
suppressWarnings,
nonenumerable,
nonconfigurable,
memoize // WIP
};
}
+44 -42
View File
@@ -139,7 +139,7 @@ function groupedBarChart() {
.style("text-anchor", "end")
.text("Population");
var state = svg.selectAll(".state")
var state = svg.selectAll(".state")
.data(data)
.enter().append("g")
.attr("class", "g")
@@ -672,8 +672,8 @@ function dragMultiples() {
function dragmove(d: { x: number; y: number }) {
d3.select(this)
.attr("cx", d.x = Math.max(radius, Math.min(width - radius, (<any> d3.event).x)))
.attr("cy", d.y = Math.max(radius, Math.min(height - radius, (<any> d3.event).y)));
.attr("cx", d.x = Math.max(radius, Math.min(width - radius, (<d3.DragEvent> d3.event).x)))
.attr("cy", d.y = Math.max(radius, Math.min(height - radius, (<d3.DragEvent> d3.event).y)));
}
}
@@ -873,7 +873,7 @@ function populationPyramid() {
// Allow the arrow keys to change the displayed year.
window.focus();
d3.select(window).on("keydown", function () {
switch (d3.event.keyCode) {
switch ((<KeyboardEvent> d3.event).keyCode) {
case 37: year = Math.max(year0, year - 10); break;
case 39: year = Math.min(year1, year + 10); break;
}
@@ -1167,7 +1167,7 @@ function azimuthalEquidistant() {
.translate([width / 2, height / 2])
.clipAngle(180 - 1e-3)
.precision(.1);
var path = d3.geo.path()
.projection(projection);
@@ -1209,7 +1209,7 @@ function azimuthalEquidistant() {
d3.select(self.frameElement).style("height", height + "px");
}
//Example from http://bl.ocks.org/mbostock/4060366
function voronoiTesselation() {
var width = 960,
@@ -1237,7 +1237,7 @@ function voronoiTesselation() {
.attr("r", 2);
redraw();
function redraw() {
path = path.data(voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String);
path.exit().remove();
@@ -1254,7 +1254,7 @@ function forceDirectedVoronoi() {
simulate = true,
zoomToAdd = true,
color = d3.scale.quantize<string>().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"])
var numVertices = (w*h) / 3000;
var vertices = d3.range(numVertices).map(function(i) {
var angle = radius * (i+10);
@@ -1266,15 +1266,15 @@ function forceDirectedVoronoi() {
var prevEventScale = 1;
var zoom = d3.behavior.zoom().on("zoom", function(d,i) {
if (zoomToAdd){
if ((<any> d3.event).scale > prevEventScale) {
var angle = radius * vertices.length;
vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)})
} else if (vertices.length > 2 && (<any> d3.event).scale != prevEventScale) {
vertices.pop();
}
force.nodes(vertices).start()
if ((<d3.ZoomEvent> d3.event).scale > prevEventScale) {
var angle = radius * vertices.length;
vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)})
} else if (vertices.length > 2 && (<d3.ZoomEvent> d3.event).scale != prevEventScale) {
vertices.pop();
}
force.nodes(vertices).start()
} else {
if ((<any> d3.event).scale > prevEventScale) {
if ((<d3.ZoomEvent> d3.event).scale > prevEventScale) {
radius+= .01
} else {
radius -= .01
@@ -1285,18 +1285,18 @@ function forceDirectedVoronoi() {
});
force.nodes(vertices).start()
}
prevEventScale = (<any> d3.event).scale;
prevEventScale = (<d3.ZoomEvent> d3.event).scale;
});
d3.select(window)
.on("keydown", function() {
// shift
if(d3.event.keyCode == 16) {
if((<KeyboardEvent> d3.event).keyCode == 16) {
zoomToAdd = false
}
// s
if(d3.event.keyCode == 83) {
if((<KeyboardEvent> d3.event).keyCode == 83) {
simulate = !simulate
if(simulate) {
force.start()
@@ -1308,38 +1308,38 @@ function forceDirectedVoronoi() {
.on("keyup", function() {
zoomToAdd = true
})
var svg = d3.select("#chart")
.append("svg")
.attr("width", w)
.attr("height", h)
.call(zoom)
var force = d3.layout.force()
.charge(-300)
.size([w, h])
.on("tick", update);
force.nodes(vertices).start();
var circle = <d3.selection.Update<any>> svg.selectAll("circle");
var path = <d3.selection.Update<any>> svg.selectAll("path");
var link = <d3.selection.Update<any>> svg.selectAll("line");
function update() {
path = path.data(d3_geom_voronoi(vertices));
path.enter().append("path")
// drag node by dragging cell
.call(d3.behavior.drag()
.on("drag", function(d, i) {
vertices[i] = {x: vertices[i].x + (<any> d3.event).dx, y: vertices[i].y + (<any> d3.event).dy}
vertices[i] = {x: vertices[i].x + (<d3.DragEvent> d3.event).dx, y: vertices[i].y + (<d3.DragEvent> d3.event).dy}
})
)
.style("fill", function(d, i) { return color(0) })
path.attr("d", function(d) { return "M" + d.join("L") + "Z"; })
.transition().duration(150).style("fill", function(d, i) { return color(d3.geom.polygon(d).area()) })
path.exit().remove();
circle = circle.data(vertices)
circle.enter().append("circle")
.attr("r", 0)
@@ -1347,16 +1347,16 @@ function forceDirectedVoronoi() {
circle.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
circle.exit().transition().attr("r", 0).remove();
link = link.data(d3_geom_voronoi.links(vertices))
link.enter().append("line")
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; })
link.exit().remove()
if(!simulate) force.stop()
}
}
@@ -1521,7 +1521,7 @@ module hierarchicalEdgeBundling {
.value(function (d) { return d.size; } );
var bundle = d3.layout.bundle<Result>();
var line = d3.svg.line.radial<Result>()
.interpolate("bundle")
.tension(.85)
@@ -1851,7 +1851,7 @@ function chordDiagram() {
[8010, 16145, 8090, 8045],
[1013, 990, 940, 6907]
];
var chord = d3.layout.chord()
.padding(.05)
.sortSubgroups(d3.descending)
@@ -2031,7 +2031,7 @@ function irisParallel() {
}
function drag(d: string) {
x.range()[i] = (<any> d3.event).x;
x.range()[i] = (<d3.DragEvent> d3.event).x;
traits.sort(function (a, b) { return x(a) - x(b); } );
g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } );
foreground.attr("d", path);
@@ -2085,14 +2085,14 @@ function healthAndWealth() {
// The x & y axes.
var xAxis = d3.svg.axis().orient("bottom").scale(xScale).ticks(12, d3.format(",d")),
yAxis = d3.svg.axis().scale(yScale).orient("left");
// Create the SVG container and set the origin.
var svg = d3.select("#chart").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
@@ -2152,7 +2152,7 @@ function healthAndWealth() {
// Add an overlay for the year label.
var box = (<SVGTextElement>label.node()).getBBox();
var overlay = svg.append("rect")
.attr("class", "overlay")
.attr("x", box.x)
@@ -2669,12 +2669,14 @@ function multiTest() {
function testD3Events () {
d3.select('svg')
.on('click', () => {
var coords = [d3.event.pageX, d3.event.pageY];
console.log("clicked", d3.event.target, "at " + coords);
let e = <MouseEvent>d3.event;
var coords = [e.pageX, e.pageY];
console.log("clicked", e.target, "at " + coords);
})
.on('keypress', () => {
if (d3.event.shiftKey) {
console.log('shift + ' + d3.event.which);
let e = <KeyboardEvent>d3.event;
if (e.shiftKey) {
console.log('shift + ' + e.which);
}
});
}
@@ -2690,4 +2692,4 @@ function testD3MutlieTimeFormat() {
["%B", function(d) { return d.getMonth(); }],
["%Y", function() { return true; }]
]);
}
}
Vendored
+24 -7
View File
@@ -807,7 +807,7 @@ declare module d3 {
interface Transition<Datum> {
transition(): Transition<Datum>;
delay(): number;
delay(delay: number): Transition<Datum>;
delay(delay: (datum: Datum, index: number, outerIndex: number) => number): Transition<Datum>;
@@ -920,16 +920,33 @@ declare module d3 {
export function flush(): void;
}
/**
* Interface for any and all d3 events.
*/
interface Event extends KeyboardEvent, MouseEvent {
}
interface BaseEvent {
type: string;
sourceEvent?: Event;
}
/**
* Define a D3-specific ZoomEvent per https://github.com/mbostock/d3/wiki/Zoom-Behavior#event
*/
interface ZoomEvent extends BaseEvent {
scale: number;
translate: [number, number];
}
/**
* Define a D3-specific DragEvent per https://github.com/mbostock/d3/wiki/Drag-Behavior#on
*/
interface DragEvent extends BaseEvent {
x: number;
y: number;
dx: number;
dy: number;
}
/**
* The current event's value. Use this variable in a handler registered with `selection.on`.
*/
export var event: Event;
export var event: Event | BaseEvent;
/**
* Returns the x and y coordinates of the mouse relative to the provided container element, using d3.event for the mouse's position on the page.
+6
View File
@@ -106,6 +106,8 @@ declare module "express" {
use(handler: ErrorRequestHandler): T;
use(path: string, ...handler: RequestHandler[]): T;
use(path: string, handler: ErrorRequestHandler): T;
use(path: string[], ...handler: RequestHandler[]): T;
use(path: string[], handler: ErrorRequestHandler): T;
}
export function Router(options?: any): Router;
@@ -410,6 +412,10 @@ declare module "express" {
originalUrl: string;
url: string;
baseUrl: string;
app: Application;
}
interface MediaType {
+156
View File
@@ -0,0 +1,156 @@
/// <reference path="faker.d.ts" />
import faker = require('faker');
faker.address.zipCode();
faker.address.zipCode('###');
faker.address.city();
faker.address.city(0);
faker.address.cityPrefix();
faker.address.citySuffix();
faker.address.streetName();
faker.address.streetAddress();
faker.address.streetAddress(false);;
faker.address.streetSuffix();
faker.address.streetPrefix();
faker.address.secondaryAddress();
faker.address.county();
faker.address.country();
faker.address.countryCode();
faker.address.state();
faker.address.state(false);
faker.address.stateAbbr();
faker.address.latitude();
faker.address.longitude();
faker.commerce.color();
faker.commerce.department();
faker.commerce.productName();
faker.commerce.price();
faker.commerce.price(0, 0, 0, '#');
faker.commerce.productAdjective();
faker.commerce.productMaterial();
faker.commerce.product();
faker.company.suffixes();
faker.company.companyName();
faker.company.companyName(0);
faker.company.companySuffix();
faker.company.catchPhrase();
faker.company.bs();
faker.company.catchPhraseAdjective();
faker.company.catchPhraseDescriptor();
faker.company.catchPhraseNoun();
faker.company.bsAdjective();
faker.company.bsBuzz();
faker.company.bsNoun();
faker.date.past();
faker.date.future();
faker.date.between('foo', 'bar');
faker.date.between(new Date(), new Date());
faker.date.recent();
faker.date.recent(100);
faker.date.month();
faker.date.month({
abbr: true,
context: true
});
faker.date.weekday();
faker.date.weekday({
abbr: true,
context: true
});
faker.finance.account();
faker.finance.account(0);
faker.finance.accountName();
faker.finance.mask();
faker.finance.mask(0, false, false);
faker.finance.amount();
faker.finance.amount(0, 0, 0, '#');
faker.finance.transactionType();
faker.finance.currencyCode();
faker.finance.currencyName();
faker.finance.currencySymbol();
faker.hacker.abbreviation();
faker.hacker.adjective();
faker.hacker.noun();
faker.hacker.verb();
faker.hacker.ingverb();
faker.hacker.phrase();
faker.helpers.randomize();
faker.helpers.randomize([1,2,3,4]);
faker.helpers.randomize(['foo', 'bar', 'quux']);
faker.helpers.slugify('foo bar quux');
faker.helpers.replaceSymbolWithNumber('foo# bar#');
faker.helpers.replaceSymbols('foo# bar? quux#');
faker.helpers.shuffle(['foo', 'bar', 'quux']);
faker.helpers.mustache('{{foo}}{{bar}}', {foo: 'x', bar: 'y'});
faker.helpers.createCard();
faker.helpers.contextualCard();
faker.helpers.userCard();
faker.internet.avatar();
faker.internet.email();
faker.internet.email('foo', 'bar', 'quux');
faker.internet.protocol();
faker.internet.url();
faker.internet.domainName();
faker.internet.domainSuffix();
faker.internet.domainWord();
faker.internet.ip();
faker.internet.userAgent();
faker.internet.color();
faker.internet.color(0, 0, 0);
faker.internet.mac();
faker.internet.password();
faker.internet.password(0, false, '#', 'foo');
faker.lorem.words();
faker.lorem.words(0);
faker.lorem.sentence();
faker.lorem.sentence(0, 0);
faker.lorem.sentences();
faker.lorem.sentences(0);
faker.lorem.paragraph();
faker.lorem.paragraph(0);
faker.lorem.paragraphs();
faker.lorem.paragraphs(0, '');
faker.name.firstName();
faker.name.firstName(0);
faker.name.lastName();
faker.name.lastName(0);
faker.name.findName();
faker.name.findName('', '', 0);
faker.name.jobTitle();
faker.name.prefix();
faker.name.suffix();
faker.name.title();
faker.name.jobDescriptor();
faker.name.jobArea();
faker.name.jobType();
faker.phone.phoneNumber();
faker.phone.phoneNumber('#');
faker.phone.phoneNumberFormat();
// https://github.com/Marak/faker.js/blob/master/lib/phone_number.js#L9-L13
faker.phone.phoneNumberFormat(0);
faker.phone.phoneFormats();
faker.random.number();
faker.random.number(0);
faker.random.number({
min: 0,
max: 0,
precision: 0
});
faker.random.arrayElement();
faker.random.arrayElement(['foo', 'bar', 'quux'])
faker.random.objectElement();
faker.random.objectElement({foo: 'bar', field: 'foo'});
faker.random.uuid();
faker.random.boolean();
+260
View File
@@ -0,0 +1,260 @@
// Type definitions for faker
// Project: http://marak.com/faker.js/
// Definitions by: Bas Pennings <https://github.com/basp/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Faker {
interface Post {
words: string;
sentence: string;
sentences: string;
paragraph: string;
}
interface Address {
street: string;
suite: string;
city: string;
zipcode: string;
geo: {
lat: string;
lon: string
}
}
interface Transaction {
amount: number,
date: Date,
business: string,
name: string,
type: string,
account: string
}
interface Company {
name: string;
catchPhrase: string;
bs: string;
}
interface Card {
name: string;
username: string;
email: string;
address: Address;
phone: string,
website: string,
company: Company;
posts: Post[],
accountHistory: Transaction[]
}
interface ContextualCard {
name: string;
username: string;
avatar: string;
email: string;
dob: Date;
phone: string;
address: Address;
website: string;
company: Company;
}
interface UserCard {
name: string;
username: string;
email: string;
address: Address;
phone: string;
website: string;
company: Company;
}
interface AddressGenerators {
zipCode(format?: string): string;
city(format?: number): string;
cityPrefix(): string;
citySuffix(): string;
streetName(): string;
streetAddress(useFullAddress?: boolean): string;
streetSuffix(): string;
streetPrefix(): string;
secondaryAddress(): string;
county(): string;
country(): string;
countryCode(): string;
state(useAbbr?: boolean): string;
stateAbbr(): string;
latitude(): string;
longitude(): string;
}
interface CommerceGenerators {
color(): string;
department(): string;
productName(): string;
price(min?: number, max?: number, dec?: number, symbol?: string): string;
productAdjective(): string;
productMaterial(): string;
product(): string;
}
interface CompanyGenerators {
suffixes(): string[];
companyName(format?: number): string;
companySuffix(): string;
catchPhrase(): string;
bs(): string;
catchPhraseAdjective(): string;
catchPhraseDescriptor(): string;
catchPhraseNoun(): string;
bsAdjective(): string;
bsBuzz(): string;
bsNoun(): string;
}
interface DateGenerators {
past(years?: number, refDate?: Date|string): Date;
future(years?: number, refDate?: Date|string): Date;
between(from: Date|string, to: Date|string): Date;
recent(days?: number): Date;
month(options?: {
abbr?: boolean,
context?: boolean
}): string;
weekday(options?: {
abbr?: boolean,
context?: boolean
}): string;
}
interface FinanceGenerators {
account(length?: number): string;
accountName(): string;
mask(length?: number, parens?: boolean, elipsis?: boolean): string;
amount(min?: number, max?: number, dec?: number, symbol?: string): string;
transactionType(): string;
currencyCode(): string;
currencyName(): string;
currencySymbol(): string;
}
interface HackerGenerators {
abbreviation(): string;
adjective(): string;
noun(): string;
verb(): string;
ingverb(): string;
phrase(): string;
}
interface Helpers {
randomize<T>(array?: Array<T>): T;
slugify(str: string): string;
replaceSymbolWithNumber(s: string, symbol?: string): string;
replaceSymbols(str: string): string;
shuffle<T>(array: Array<T>): Array<T>;
mustache(str: string, data: Object): string;
createCard(): Card;
contextualCard(): Card;
userCard(): UserCard;
createTransaction(): Transaction;
}
interface ImageGenerators {
image(): string;
avator(): string;
imageUrl(width?: number, height?: number, category?: string): string;
abstract(width?: number, height?: number): string;
animals(width?: number, height?: number): string;
business(width?: number, height?: number): string;
cats(width?: number, height?: number): string;
city(width?: number, height?: number): string;
food(width?: number, height?: number): string;
nightlife(width?: number, height?: number): string;
fashion(width?: number, height?: number): string;
people(width?: number, height?: number): string;
nature(width?: number, height?: number): string;
sports(width?: number, height?: number): string;
technics(width?: number, height?: number): string;
transport(width?: number, height?: number): string;
}
interface InternetGenerators {
avatar(): string;
email(firstName?: string, lastName?: string, provider?: string): string;
userName(firstName?: string, lastName?: string): string;
protocol(): string;
url(): string;
domainName(): string;
domainSuffix(): string;
domainWord(): string;
ip(): string;
userAgent(): string;
color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string;
mac(): string;
password(len?: number, memorable?: boolean, pattern?: string, prefix?: string): string;
}
interface LoremGenerators {
words(num?: number): string[];
sentence(wordCount?: number, range?: number): string;
sentences(sentenceCount?: number): string;
paragraph(sentenceCount?: number): string;
paragraphs(paragraphCount?: number, separator?: string): string;
}
interface NameGenerators {
firstName(gender?: number): string;
lastName(gender?: number): string;
findName(firstName?: string, lastName?: string, gender?: number): string;
jobTitle(): string;
prefix(): string;
suffix(): string;
title(): string;
jobDescriptor(): string;
jobArea(): string;
jobType(): string;
}
interface PhoneGenerators {
phoneNumber(format?: string): string;
// https://github.com/Marak/faker.js/blob/master/lib/phone_number.js#L9-L13
phoneNumberFormat(phoneFormatsArrayIndex?: number): string;
phoneFormats(): string;
}
interface RandomGenerators {
number(max: number): number;
number(options?: {
min?: number,
max?: number,
precision?: number
}): number;
arrayElement<T>(array?: Array<T>): T;
objectElement(object?: Object, field?: string): any;
uuid(): string;
boolean(): boolean;
}
}
declare module "faker" {
var faker: {
address: Faker.AddressGenerators;
commerce: Faker.CommerceGenerators;
company: Faker.CompanyGenerators;
date: Faker.DateGenerators;
finance: Faker.FinanceGenerators;
hacker: Faker.HackerGenerators;
helpers: Faker.Helpers;
image: Faker.ImageGenerators;
internet: Faker.InternetGenerators;
lorem: Faker.LoremGenerators;
name: Faker.NameGenerators;
phone: Faker.PhoneGenerators;
random: Faker.RandomGenerators;
}
export = faker;
}
+4
View File
@@ -11,3 +11,7 @@ str = findup(['foo', 'bar']);
str = findup('foo', {
debug: true
});
str = findup('foo', {
cwd: "c:\\"
});
+7 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for findup-sync v0.1.3
// Type definitions for findup-sync v0.3.0
// Project: https://github.com/cowboy/node-findup-sync
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Nathan Brown <https://github.com/ngbrown>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../minimatch/minimatch.d.ts" />
@@ -8,8 +8,11 @@
declare module 'findup-sync' {
import minimatch = require('minimatch');
function mod(pattern: string, opts?: minimatch.IOptions): string;
function mod(pattern: string[], opts?: minimatch.IOptions): string;
interface IOptions extends minimatch.IOptions {
cwd?: string;
}
function mod(pattern: string[] | string, opts?: IOptions): string;
export = mod;
}
+78
View File
@@ -0,0 +1,78 @@
/// <reference path="flowjs.d.ts" />
// flow object
var flowObject: flowjs.IFlow;
var bool: boolean = flowObject.support;
bool = flowObject.supportDirectory;
var obj: Object = flowObject.opts;
var flowFileArray: flowjs.IFlowFile[] = flowObject.files;
flowObject.assignBrowse(<HTMLElement[]> [], false, false, {});
flowObject.assignDrop(<HTMLElement[]> []);
flowObject.unAssignDrop(<HTMLElement[]> []);
flowObject.on("", () => {});
flowObject.off("", () => {});
flowObject.upload();
flowObject.pause();
flowObject.resume();
flowObject.cancel();
flowObject.progress();
bool = flowObject.isUploading();
flowObject.addFile(<File> {});
flowObject.removeFile(<flowjs.IFlowFile> {});
var flowFile: flowjs.IFlowFile = flowObject.getFromUniqueIdentifier("");
var num: number = flowObject.getSize();
num = flowObject.sizeUploaded();
num = flowObject.timeRemaining();
// flow options
var flowOptions: flowjs.IFlowOptions = {};
flowOptions.target = "";
flowOptions.singleFile = true;
flowOptions.chunkSize= 0;
flowOptions.forceChunkSize = true;
flowOptions.simultaneousUploads= 0;
flowOptions.fileParameterName = "";
flowOptions.query = {};
flowOptions.headers = {};
flowOptions.withCredentials = true;
flowOptions.method = "";
flowOptions.testMethod = "";
flowOptions.uploadMethod = "";
flowOptions.allowDuplicateUploads = true;
flowOptions.prioritizeFirstAndLastChunk = true;
flowOptions.testchunks = true;
flowOptions.preprocess = () => {};
flowOptions.initFileFn = () => {};
flowOptions.generateUniqueIdentifier = () => {};
flowOptions.maxChunkRetries= 0;
flowOptions.chunkRetryInterval= 0;
flowOptions.progressCallbacksInterval= 0;
flowOptions.speedSmoothingFactor= 0;
flowOptions.successStatuses = [""];
flowOptions.permanentErrors = [""];
// flow file
flowObject = flowFile.flowObj;
var htmlFile: File = flowFile.file;
var str: string = flowFile.name;
str = flowFile.relativePath;
num = flowFile.size;
str = flowFile.uniqueIdentifier;
num = flowFile.averageSpeed;
num = flowFile.currentSpeed;
var anyArray: any[] = flowFile.chunks;
bool = flowFile.paused;
bool = flowFile.error;
num = flowFile.progress(true);
flowFile.pause();
flowFile.resume();
flowFile.cancel();
flowFile.retry();
flowFile.bootstrap();
bool = flowFile.isUploading();
bool = flowFile.isComplete;
num = flowFile.sizeUploaded;
num = flowFile.timeRemaining;
str = flowFile.getExtension;
str = flowFile.getType;
+85
View File
@@ -0,0 +1,85 @@
// Type definitions for flowjs
// Project: https://github.com/flowjs/flow.js
// Definitions by: Ryan McNamara <https://github.com/ryan10132>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module flowjs {
interface IFlow {
support: boolean;
supportDirectory: boolean;
opts: Object;
files: IFlowFile[];
assignBrowse(domNodes: HTMLElement[], isDirectory: boolean, singleFile: boolean, attributes: Object): void;
assignDrop(domNodes: HTMLElement[]): void;
unAssignDrop(domNodes: HTMLElement[]): void;
on(event: string, callback: Function): void;
off(event?: string, callback?: Function): void;
upload(): void;
pause(): void;
resume(): void;
cancel(): void;
progress(): number;
isUploading(): boolean;
addFile(file: File): void;
removeFile(file: IFlowFile): void;
getFromUniqueIdentifier(uniqueIdentifier: string): IFlowFile;
getSize(): number;
sizeUploaded(): number;
timeRemaining(): number;
}
interface IFlowOptions {
target?: string;
singleFile?: boolean;
chunkSize?: number;
forceChunkSize?: boolean;
simultaneousUploads?: number;
fileParameterName?: string;
query?: Object;
headers?: Object;
withCredentials?: boolean;
method?: string;
testMethod?: string;
uploadMethod?: string;
allowDuplicateUploads?: boolean;
prioritizeFirstAndLastChunk?: boolean;
testchunks?: boolean;
preprocess?: Function;
initFileFn?: Function;
generateUniqueIdentifier?: Function;
maxChunkRetries?: number;
chunkRetryInterval?: number;
progressCallbacksInterval?: number;
speedSmoothingFactor?: number;
successStatuses?: string[];
permanentErrors?: string[];
}
interface IFlowFile {
flowObj: IFlow;
file: File;
name: string;
relativePath: string;
size: number;
uniqueIdentifier: string;
averageSpeed: number;
currentSpeed: number;
chunks: any[];
paused: boolean;
error: boolean;
progress(relative: boolean): number;
pause(): void;
resume(): void;
cancel(): void;
retry(): void;
bootstrap(): void;
isUploading(): boolean;
isComplete: boolean;
sizeUploaded: number;
timeRemaining: number;
getExtension: string;
getType: string;
}
}
+26
View File
@@ -0,0 +1,26 @@
///<reference path="graphviz.d.ts"/>
import graphviz = require('graphviz');
// Create digraph G
var g: graphviz.Graph = graphviz.digraph("G");
// Add node (ID: Hello)
var n1: graphviz.Node = g.addNode( "Hello", {"color" : "blue"} );
n1.set( "style", "filled" );
// Add node (ID: World)
g.addNode( "World" );
// Add edge between the two nodes
var e: graphviz.Edge = g.addEdge( n1, "World" );
e.set( "color", "red" );
// Print the dot script
console.log( g.to_dot() );
// Set GraphViz path (if not in your path)
g.setGraphVizPath( "/usr/local/bin" );
// Generate a PNG output
g.output( "png", "test01.png" );
+93
View File
@@ -0,0 +1,93 @@
// Type definitions for Graphviz 0.0.8
// Project: git://github.com/glejeune/node-graphviz.git
// Definitions by: Matt Frantz <https://github.com/mhfrantz/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// graphviz.d.ts
declare module 'graphviz' {
export interface HasAttributes {
set(name: string, value: any): void;
get(name: string): any;
}
export interface Node extends HasAttributes {
}
export interface Edge extends HasAttributes {
}
export interface OutputCallback {
(data: string): void;
}
export interface ErrorCallback {
(code: number, stdout: string, stderr: string): void;
}
export interface RenderOptions {
type: string; // output file type (png, jpeg, ps, ...)
use: string; // Graphviz command to use (dot, neato, ...)
path: string; // GraphViz path
G: any; // graph options
N: any; // node options
E: any; // edge options
}
export interface Graph extends HasAttributes {
addNode(id: string, attrs?: any): Node;
nodeCount(): number;
// TODO: Use union types when we have TS 1.4
addEdge(nodeOne: string, nodeTwo: string, attrs?: any): Edge;
addEdge(nodeOne: string, nodeTwo: Node, attrs?: any): Edge;
addEdge(nodeOne: Node, nodeTwo: string, attrs?: any): Edge;
addEdge(nodeOne: Node, nodeTwo: Node, attrs?: any): Edge;
edgeCount(): number;
// Subgraph (cluster) API
addCluster(id: string): Graph;
getCluster(id: string): Graph;
clusterCount(): number;
setNodeAttribut(name: string, value: any): void;
getNodeAttribut(name: string): any;
setEdgeAttribut(name: string, value: any): void;
getEdgeAttribut(name: string): any;
to_dot(): string;
// Graphviz command to use (dot, neato, ...)
use: string;
// Path containing Graphviz binaries.
setGraphVizPath(directoryPath: string): void;
// TODO: Use union types when we can have TS 1.4
render(type: string, filename: string, errback?: ErrorCallback): void;
render(options: RenderOptions, filename: string, errback?: ErrorCallback): void;
render(type: string, callback: OutputCallback, errback?: ErrorCallback): void;
render(options: RenderOptions, callback: OutputCallback, errback?: ErrorCallback): void;
// alias for render
output(type: string, filename: string, errback?: ErrorCallback): void;
output(options: RenderOptions, filename: string, errback?: ErrorCallback): void;
output(type: string, callback: OutputCallback, errback?: ErrorCallback): void;
output(options: RenderOptions, callback: OutputCallback, errback?: ErrorCallback): void;
}
export function graph(id: string): Graph;
export function digraph(id: string): Graph;
interface ParseCallback {
(graph: Graph): void;
}
export function parse(path: string, callback: ParseCallback, errback?: ErrorCallback): void;
}
+20
View File
@@ -0,0 +1,20 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="gridstack.d.ts" />
// Type definitions for Gridstack
// Project: http://troolee.github.io/gridstack.js/
// Definitions by: Pascal Senn <https://github.com/PascalSenn/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
var options = <IGridstackOptions> {
float: true
};
var gridstack:GridStack = $(document).gridstack(options);
gridstack.add_widget("test", 1, 2, 3, 4, true);
gridstack.batch_update();
gridstack.cell_height();;
gridstack.cell_height(2);
gridstack.cell_width();
gridstack.get_cell_from_pixel(<MousePosition>{ left:20, top: 20 });
+241
View File
@@ -0,0 +1,241 @@
// Type definitions for Gridstack
// Project: http://troolee.github.io/gridstack.js/
// Definitions by: Pascal Senn <https://github.com/PascalSenn/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface JQuery {
gridstack (options: IGridstackOptions):GridStack
}
interface GridStack {
/**
* Creates new widget and returns it.
*
* Widget will be always placed even if result height is more than actual grid height. You need to use will_it_fit method before calling add_widget for additional check.
*
* @param {string} el widget to add
* @param {number} x widget position x
* @param {number} y widget position y
* @param {number} width widget dimension width
* @param {number} height widget dimension height
* @param {boolean} auto_position if true then x, y parameters will be ignored and widget will be places on the first available position
*/
add_widget(el: string, x: number, y: number, width: number, height: number, auto_position: boolean): JQuery
/**
* Initializes batch updates. You will see no changes until commit method is called.
*/
batch_update():void
/**
* Gets current cell height.
*/
cell_height():number
/**
* Update current cell height. This method rebuilds an internal CSS style sheet. Note: You can expect performance issues if call this method too often.
* @param {number} val the cell height
*/
cell_height(val:number):void
/**
* Gets current cell width.
*/
cell_width():number
/**
* Finishes batch updates. Updates DOM nodes. You must call it after batch_update.
*/
commit():void
/**
* Destroys a grid instance.
*/
destroy(): void
/*
* Disables widgets moving/resizing.
*/
disable(): void
/*
* Enables widgets moving/resizing.
*/
enable(): void
/*
* Get the position of the cell under a pixel on screen.
* @param {MousePosition} position the position of the pixel to resolve in absolute coordinates, as an object with top and leftproperties
*/
get_cell_from_pixel(position: MousePosition): CellPosition,
/*
* Checks if specified area is empty.
* @param {number} x the position x.
* @param {number} y the position y.
* @param {number} width the width of to check
* @param {number} height the height of to check
*/
is_area_empty(x: number, y: number, width: number, height: number): void
/*
* Locks/unlocks widget.
* @param {HTMLElement} el widget to modify.
* @param {boolean} val if true widget will be locked.
*/
locked(el: HTMLElement, val: boolean): void
/*
* Set the minWidth for a widget.
* @param {HTMLElement} el widget to modify.
* @param {number} val A numeric value of the number of columns
*/
min_width(el: HTMLElement, val: number): void
/*
* Set the minHeight for a widget.
* @param {HTMLElement} el widget to modify.
* @param {number} val A numeric value of the number of rows
*/
min_height(el: HTMLElement, val: number): void
/*
* Enables/Disables moving.
* @param {HTMLElement} el widget to modify.
* @param {number} val if true widget will be draggable.
*/
movable(el: HTMLElement, val: boolean): void
/**
* Changes widget position
* @param {HTMLElement} el widget to modify
* @param {number} x new position x. If value is null or undefined it will be ignored.
* @param {number} y new position y. If value is null or undefined it will be ignored.
*
*/
move(el: HTMLElement, x: number, y: number): void
/**
* Removes widget from the grid.
* @param {HTMLElement} el widget to modify
* @param {boolean} detach_node if false DOM node won't be removed from the tree (Optional. Default true).
*/
remove_widget(el: HTMLElement, detach_node?: boolean): void
/**
* Removes all widgets from the grid.
*/
remove_all(): void
/**
* Changes widget size
* @param {HTMLElement} el widget to modify
* @param {number} width new dimensions width. If value is null or undefined it will be ignored.
* @param {number} height new dimensions height. If value is null or undefined it will be ignored.
*/
resize(el: HTMLElement, width: number, height: number): void
/**
* Enables/Disables resizing.
* @param {HTMLElement} el widget to modify
* @param {boolean} val if true widget will be resizable.
*/
resizable(el: HTMLElement, val: boolean): void
/**
* Toggle the grid static state. Also toggle the grid-stack-static class.
* @param {boolean} static_value if true the grid become static.
*/
set_static(static_value: boolean): void
/**
* Updates widget position/size.
* @param {HTMLElement} el widget to modify
* @param {number} x new position x. If value is null or undefined it will be ignored.
* @param {number} y new position y. If value is null or undefined it will be ignored.
* @param {number} width new dimensions width. If value is null or undefined it will be ignored.
* @param {number} height new dimensions height. If value is null or undefined it will be ignored.
*/
update(el: HTMLElement, x: number, y: number, width: number, height: number): void
/**
* Returns true if the height of the grid will be less the vertical constraint. Always returns true if grid doesn't have height constraint.
* @param {number} x new position x. If value is null or undefined it will be ignored.
* @param {number} y new position y. If value is null or undefined it will be ignored.
* @param {number} width new dimensions width. If value is null or undefined it will be ignored.
* @param {number} height new dimensions height. If value is null or undefined it will be ignored.
* @param {boolean} auto_position if true then x, y parameters will be ignored and widget will be places on the first available position
*/
will_it_fit(x: number, y: number, width: number, height: number, auto_position:boolean):boolean
}
/**
* Defines the coordiantes of a object
*/
interface MousePosition {
top: number,
left:number,
}
/**
* Defines the position of a cell inside the grid
*/
interface CellPosition {
x: number,
y:number
}
declare module GridStackUI {
interface Utils {
/**
* Sorts array of nodes
*@param nodes array to sort
*@param dir 1 for asc, -1 for desc (optional)
*@param width width of the grid. If undefined the width will be calculated automatically (optional).
**/
sort(nodes: HTMLElement[], dir: number, width: number): void
}
}
/**
* Gridstack Options
* Defines the options for a Gridstack
*/
interface IGridstackOptions {
/**
* if true the resizing handles are shown even if the user is not hovering over the widget (default: false)
*/
always_show_resize_handle: boolean;
/**
* turns animation on (default: true)
*/
animate: boolean;
/**
* if false gridstack will not initialize existing items (default: true)
*/
auto: boolean;
/**
* one cell height (default: 60)
*/
cell_height: number;
/**
* allows to override jQuery UI draggable options. (default: { handle: '.grid-stack-item-content', scroll: true, appendTo: 'body' })
*/
draggable: {};
/**
* draggable handle selector (default: '.grid-stack-item-content')
*/
handle: string;
/**
* maximum rows amount.Default is 0 which means no maximum rows
*/
height: number;
/**
* enable floating widgets (default: false) See example
*/
float: boolean;
/**
* widget class (default: 'grid-stack-item')
*/
item_class: string;
/**
* minimal width.If window width is less, grid will be shown in one - column mode (default: 768)
*/
min_width: number;
/**
* class for placeholder (default: 'grid-stack-placeholder')
*/
placeholder_class: string;
/**
* allows to override jQuery UI resizable options. (default: { autoHide: true, handles: 'se' })
*/
resizable: {};
/**
* makes grid static (default false).If true widgets are not movable/ resizable.You don't even need jQueryUI draggable/resizable. A CSS class grid-stack-static is also added to the container.
*/
static_grid: boolean;
/**
* vertical gap size (default: 20)
*/
vertical_margin: number;
/**
* amount of columns (default: 12)
*/
width: number;
}
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="gulp-shell.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
import shell = require('gulp-shell');
import gulp = require('gulp');
gulp.task('example', function () {
return gulp.src('*.js', {read: false})
.pipe(shell([
'echo <%= f(file.path) %>',
'ls -l <%= file.path %>'
], {
templateData: {
f: function (s: string) {
return s.replace(/$/, '.bak')
}
}
}))
});
gulp.task('shorthand', shell.task([
'echo hello',
'echo world'
]));
var paths: any = {
js: ['*.js', 'test/*.js']
};
gulp.task('test', shell.task('mocha -R spec'));
gulp.task('coverage', ['test'], shell.task('istanbul cover _mocha -- -R spec'));
gulp.task('coveralls', ['coverage'], shell.task('cat coverage/lcov.info | coveralls'));
gulp.task('lint', shell.task('eslint ' + paths.js.join(' ')));
gulp.task('default', ['coverage', 'lint']);
gulp.task('watch', function () {
gulp.watch(paths.js, ['default'])
});
+68
View File
@@ -0,0 +1,68 @@
// Type definitions for gulp-shell
// Project: https://github.com/sun-zheng-an/gulp-shell
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "gulp-shell" {
namespace shell {
interface Shell {
(commands: string|string[], options?: Option): NodeJS.ReadWriteStream;
task(commands: string|string[], options?: Option): () => NodeJS.ReadWriteStream;
}
interface Option {
/**
* You can add a custom error message for when the command fails. This can be a template which can be
* interpolated with the current command, some file info (e.g. file.path) and some error info
* (e.g. error.code).
* @default 'Command `<%= command %>` failed with exit code <%= error.code %>'
*/
errorMessage?: string;
/**
* By default, it will emit an error event when the command finishes unsuccessfully.
* @default false
*/
ignoreErrors?: boolean;
/**
* By default, it will print the command output.
* @default false
*/
quiet?: boolean;
/**
* Sets the current working directory for the command.
* @default process.cwd()
*/
cwd?: string;
/**
* The data that can be accessed in template.
*/
templateData?: any;
/**
* You won't need to set this option unless you encounter a "stdout maxBuffer exceeded" error.
* @default 16MB(16 * 1024 * 1024)
*/
maxBuffer?: number;
/**
* The maximum amount of time in milliseconds the process is allowed to run.
* @default
*/
timeout?: number;
/**
* By default, all the commands will be executed in an environment with all the variables in process.env
* and PATH prepended by ./node_modules/.bin (allowing you to run executables in your Node's dependencies).
* You can override any environment variables with this option.
* For example, setting it to {PATH: process.env.PATH} will reset the PATH
* if the default one brings your some troubles.
*/
env?: any;
}
}
var shell: shell.Shell;
export = shell;
}
+51
View File
@@ -0,0 +1,51 @@
/// <reference path="gulp-svg-sprite.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
/// <reference path="../svg-sprite/svg-sprite.d.ts" />
import svgSprite = require('gulp-svg-sprite');
import spriter = require('svg-sprite');
import gulp = require('gulp')
let config: spriter.Config;
// Basic configuration example
config = {
mode : {
css : { // Activate the «css» mode
render : {
css : true // Activate CSS output (with default options)
}
}
}
};
gulp.src('**/*.svg', {cwd: 'path/to/assets'})
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
config = {
shape : {
dimension : { // Set maximum dimensions
maxWidth : 32,
maxHeight : 32
},
spacing : { // Add padding
padding : 10
},
dest : 'out/intermediate-svg' // Keep the intermediate files
},
mode : {
view : { // Activate the «view» mode
bust : false,
render : {
scss : true // Activate Sass output (with default options)
}
},
symbol : true // Activate the «symbol» mode
}
};
gulp.src('**/*.svg', {cwd: 'path/to/assets'})
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for gulp-svg-sprite 1.2.9
// Project: https://github.com/jkphl/gulp-svg-sprite
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../svg-sprite/svg-sprite.d.ts" />
declare module "gulp-svg-sprite" {
import spriter = require('svg-sprite');
namespace svgSprite {
interface SvgSprite {
(options?: spriter.Config): NodeJS.ReadWriteStream;
}
}
var svgSprite: svgSprite.SvgSprite;
export = svgSprite;
}
+1
View File
@@ -23,6 +23,7 @@ declare module "gulp-typescript" {
sourceRoot?: string;
sortOutput?: boolean;
target?: string;
typescript?: any;
}
interface Project {
+1 -1
View File
@@ -302,7 +302,7 @@ interface SwipeRecognizerStatic
new( options?:any ):SwipeRecognizer;
}
interface SwipeRecognizer
interface SwipeRecognizer extends AttrRecognizer
{
}
+5
View File
@@ -122,6 +122,11 @@ declare module jake{
* stop execution on error, default true
*/
breakOnError?:boolean;
/**
*
*/
windowsVerbatimArguments?: boolean
}
export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions):void;
@@ -0,0 +1,21 @@
/// <reference path="jasmine-es6-promise-matchers.d.ts" />
describe('specs', () => {
beforeEach(() => {
JasminePromiseMatchers.install
});
afterEach(() => {
JasminePromiseMatchers.uninstall
});
it('should have correct syntax', (done) => {
var foo = {};
var bar = {};
expect(foo).toBeResolvedWith(bar, done);
expect(foo).toBeRejectedWith(bar, done);
expect(foo).toBeResolved(done);
expect(foo).toBeRejected(done);
});
})
@@ -0,0 +1,36 @@
// Type definitions for jasmine-es6-promise-matchers
// Project: https://github.com/bvaughn/jasmine-es6-promise-matchers
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jasmine/jasmine.d.ts" />
declare module JasminePromiseMatchers {
export function install():void;
export function uninstall():void;
}
declare module jasmine {
interface Matchers {
/**
* Verifies that a Promise is (or has been) rejected.
*/
toBeRejected(done?: () => void): boolean;
/**
* Verifies that a Promise is (or has been) rejected with the specified parameter.
*/
toBeRejectedWith(value: any, done?: () => void): boolean;
/**
* Verifies that a Promise is (or has been) resolved.
*/
toBeResolved(done?: () => void): boolean;
/**
* Verifies that a Promise is (or has been) resolved with the specified parameter.
*/
toBeResolvedWith(value: any, done?: () => void): boolean;
}
}
+15 -15
View File
@@ -58,7 +58,7 @@ declare module jasmine {
function addMatchers(matchers: CustomMatcherFactories): void;
function stringMatching(str: string): Any;
function stringMatching(str: RegExp): Any;
interface Any {
new (expectedClass: any): any;
@@ -72,7 +72,7 @@ declare module jasmine {
length: number;
[n: number]: T;
}
interface ArrayContaining {
new (sample: any[]): any;
@@ -279,21 +279,21 @@ declare module jasmine {
isNot?: boolean;
message(): any;
toBe(expected: any): boolean;
toEqual(expected: any): boolean;
toMatch(expected: any): boolean;
toBeDefined(): boolean;
toBeUndefined(): boolean;
toBeNull(): boolean;
toBe(expected: any, expectationFailOutput?: any): boolean;
toEqual(expected: any, expectationFailOutput?: any): boolean;
toMatch(expected: any, expectationFailOutput?: any): boolean;
toBeDefined(expectationFailOutput?: any): boolean;
toBeUndefined(expectationFailOutput?: any): boolean;
toBeNull(expectationFailOutput?: any): boolean;
toBeNaN(): boolean;
toBeTruthy(): boolean;
toBeFalsy(): boolean;
toBeTruthy(expectationFailOutput?: any): boolean;
toBeFalsy(expectationFailOutput?: any): boolean;
toHaveBeenCalled(): boolean;
toHaveBeenCalledWith(...params: any[]): boolean;
toContain(expected: any): boolean;
toBeLessThan(expected: any): boolean;
toBeGreaterThan(expected: any): boolean;
toBeCloseTo(expected: any, precision: any): boolean;
toContain(expected: any, expectationFailOutput?: any): boolean;
toBeLessThan(expected: any, expectationFailOutput?: any): boolean;
toBeGreaterThan(expected: any, expectationFailOutput?: any): boolean;
toBeCloseTo(expected: any, precision: any, expectationFailOutput?: any): boolean;
toContainHtml(expected: string): boolean;
toContainText(expected: string): boolean;
toThrow(expected?: any): boolean;
@@ -450,7 +450,7 @@ declare module jasmine {
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
reset(): void;
}
interface CallInfo {
/** The context (the this) for the call */
object: any;
+34
View File
@@ -0,0 +1,34 @@
///<reference path="java.d.ts"/>
///<reference path="../bluebird/bluebird.d.ts"/>
import java = require('java');
import BluePromise = require('bluebird');
java.asyncOptions = {
syncSuffix: 'Sync',
asyncSuffix: '',
promiseSuffix: 'P',
promisify: BluePromise.promisify
};
java.registerClientP((): Promise<void> => {
return BluePromise.resolve();
});
interface ProxyFunctions {
[index: string]: Function;
}
java.ensureJvm()
.then(() => {
// java.d.ts does not declare any Java types.
// We can import a java class, but we don't know the shape of the class here, so must use any
var Boolean: any = java.import('java.lang.Boolean');
var functions: ProxyFunctions = {
accept: function(t: any): void { },
andThen: function(after: any): any {}
};
var proxy: any = java.newProxy('java.util.function.Consumer', functions);
});
+64
View File
@@ -0,0 +1,64 @@
// Type definitions for java 0.5.4
// Project: https://github.com/joeferner/java
// Definitions by: Jim Lloyd <https://github.com/jimlloyd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="../node/node.d.ts" />
// This is the core API exposed by https://github.com/joeferner/java.
// To get the full power of Typescript with Java, see https://github.com/RedSeal-co/ts-java.
declare module 'java' {
var NodeJavaCore: NodeJavaCore.NodeAPI;
export = NodeJavaCore;
}
declare module NodeJavaCore {
export interface Callback<T> {
(err?: Error, result?: T): void;
}
interface Promisify {
(funct: Function, receiver?: any): Function;
}
interface AsyncOptions {
syncSuffix: string;
asyncSuffix?: string;
promiseSuffix?: string;
promisify?: Promisify;
}
interface ProxyFunctions {
[index: string]: Function;
}
// *NodeAPI* declares methods & members exported by the node java module.
interface NodeAPI {
classpath: string[];
asyncOptions: AsyncOptions;
callMethod(instance: any, className: string, methodName: string, args: any[], callback: Callback<any>): void;
callMethodSync(instance: any, className: string, methodName: string, ...args: any[]): any;
callStaticMethodSync(className: string, methodName: string, ...args: any[]): any;
instanceOf(javaObject: any, className: string): boolean;
registerClient(before: (cb: Callback<void>) => void, after?: (cb: Callback<void>) => void): void;
registerClientP(beforeP: () => Promise<void>, afterP?: () => Promise<void>): void;
ensureJvm(done: Callback<void>): void;
ensureJvm(): Promise<void>;
newShort(val: number): any;
newLong(val: number): any;
newFloat(val: number): any;
newDouble(val: number): any;
import(className: string): any;
newInstance(className: string, ...args: any[]): void;
newInstanceSync(className: string, ...args: any[]): any;
newInstanceP(className: string, ...args: any[]): Promise<any>;
newArray<T>(className: string, arg: any[]): any;
getClassLoader(): any;
newProxy(interfaceName: string, functions: ProxyFunctions): any;
}
}
+2
View File
@@ -35,3 +35,5 @@ $.cookie("test", testObject, cookieOptions);
var result = <TestObject>$.cookie("test");
console.log(result.text);
$.cookie.defaults = cookieOptions;
+78 -6
View File
@@ -1,34 +1,106 @@
// Type definitions for jQuery Cookie Plugin 1.3
// Type definitions for jQuery Cookie Plugin 1.4.1
// Project: https://github.com/carhartl/jquery-cookie
// Definitions by: Roy Goode <https://github.com/RoyGoode/>
// Definitions by: Roy Goode <https://github.com/RoyGoode/>, Ben Lorantfy <https://github.com/BenLorantfy/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
interface JQueryCookieOptions {
/**
* Define lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted, the cookie becomes a session cookie.
*/
expires?: any;
/**
* Define the path where the cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire domain use path: '/'. Default: path of page where the cookie was created.
*/
path?: string;
/**
* Define the domain where the cookie is valid. Default: domain of page where the cookie was created.
*/
domain?: string;
/**
* If true, the cookie transmission requires a secure protocol (https). Default: false.
*/
secure?: boolean;
}
//
// The following jsdoc comments are used to add intellisense to editors that support it. Uses snippets
// of documentation from the Github repo when possible.
//
// The ordering here matters. For example, the read function with the converter parameter is purposefully after
// the set function. This is because the intellisense that shows up after you press comma should be the set first,
// since that is more common, then the conversion function if user starts typing a parameter with a function type
interface JQueryCookieStatic {
/**
* By default the cookie value is encoded/decoded when writing/reading, using encodeURIComponent/decodeURIComponent. Bypass this by setting raw to true:
*/
raw?: boolean;
/**
* Turn on automatic storage of JSON objects passed as the cookie value. Assumes JSON.stringify and JSON.parse
*/
json?: boolean;
/**
* Cookie attributes can be set globally by setting properties of the $.cookie.defaults object or individually for each call to $.cookie() by passing a plain object to the options argument. Per-call options override the default options.
*/
defaults?: JQueryCookieOptions;
/**
* Gets an object of cookies as key-value pairs
*/
(): {[key:string]:string};
/**
* Gets a cookie by name
* @param name The name of the cookie to get
*/
(name: string): any;
(name: string, converter: (value: string) => any): any;
/**
* Sets a cookie
* @param name The name of the cookie to set
* @param value The value to set the cookie to
*/
(name: string, value: string): void;
/**
* Gets a cookie by name after applying a conversion function to the value
* @param name The name of the cookie to get
* @param converter A conversion function to change the cookie's value to a different representation on the fly
*/
(name: string, converter: (value: string) => any): any;
/**
* Sets a cookie with some options
* @param name The name of the cookie to set
* @param value The value to set the cookie to
* @param options An object of options that change how the cookie is set
*/
(name: string, value: string, options: JQueryCookieOptions): void;
/**
* Sets a cookie using .toString(), or if $.cookie.json is set to true using JSON.stringify()
* @param name The name of the cookie to set
* @param value The value to set the cookie to
*/
(name: string, value: any): void;
/**
* Sets a cookie using .toString(), or if $.cookie.json is set to true using JSON.stringify()
* @param name The name of the cookie to set
* @param value The value to set the cookie to
* @param options An object of options that change how the cookie is set
*/
(name: string, value: any, options: JQueryCookieOptions): void;
}
interface JQueryStatic {
/**
* A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
*/
cookie?: JQueryCookieStatic;
/**
* Deletes a cookie
* @param name Name of cookie to delete
*/
removeCookie(name: string): boolean;
/**
* Deletes a cookie
* @param name Name of cookie to delete
* @param options The same attributes (path, domain) as what the cookie was written with
*/
removeCookie(name: string, options: JQueryCookieOptions): boolean;
}
+1 -1
View File
@@ -3359,7 +3359,7 @@ function test_promise_then_change_type() {
var def = $.Deferred<any>();
var promise = def.promise(null);
def.rejectWith(this, new Error());
def.rejectWith(this, [new Error()]);
return promise;
}
+4 -4
View File
@@ -241,7 +241,7 @@ interface JQueryCallback {
* @param context A reference to the context in which the callbacks in the list should be fired.
* @param arguments An argument, or array of arguments, to pass to the callbacks in the list.
*/
fireWith(context?: any, ...args: any[]): JQueryCallback;
fireWith(context?: any, args?: any[]): JQueryCallback;
/**
* Determine whether a supplied callback is in a list
@@ -395,7 +395,7 @@ interface JQueryDeferred<T> extends JQueryGenericPromise<T> {
* @param context Context passed to the progressCallbacks as the this object.
* @param args Optional arguments that are passed to the progressCallbacks.
*/
notifyWith(context: any, value?: any, ...args: any[]): JQueryDeferred<T>;
notifyWith(context: any, value?: any[]): JQueryDeferred<T>;
/**
* Reject a Deferred object and call any failCallbacks with the given args.
@@ -409,7 +409,7 @@ interface JQueryDeferred<T> extends JQueryGenericPromise<T> {
* @param context Context passed to the failCallbacks as the this object.
* @param args An optional array of arguments that are passed to the failCallbacks.
*/
rejectWith(context: any, value?: any, ...args: any[]): JQueryDeferred<T>;
rejectWith(context: any, value?: any[]): JQueryDeferred<T>;
/**
* Resolve a Deferred object and call any doneCallbacks with the given args.
@@ -425,7 +425,7 @@ interface JQueryDeferred<T> extends JQueryGenericPromise<T> {
* @param context Context passed to the doneCallbacks as the this object.
* @param args An optional array of arguments that are passed to the doneCallbacks.
*/
resolveWith(context: any, value?: T, ...args: any[]): JQueryDeferred<T>;
resolveWith(context: any, value?: T[]): JQueryDeferred<T>;
/**
* Return a Deferred's Promise object.
+1
View File
@@ -1438,6 +1438,7 @@ function test_dialog() {
});
$(".selector").dialog({ autoOpen: false });
$(".selector").dialog({ buttons: { Ok: function () { $(this).dialog("close"); } } });
$(".selector").dialog({ buttons: [ { text: "Ok", click: function () { $(this).dialog("close"); } } ] } );
$(".selector").dialog({ closeOnEscape: false });
$(".selector").dialog({ closeText: "hide" });
$(".selector").dialog({ dialogClass: "alert" });
+18 -8
View File
@@ -9,7 +9,7 @@
declare module JQueryUI {
// Accordion //////////////////////////////////////////////////
interface AccordionOptions {
interface AccordionOptions extends AccordionEvents {
active?: any; // boolean or number
animate?: any; // boolean, number, string or object
collapsible?: boolean;
@@ -37,7 +37,7 @@ declare module JQueryUI {
create?: AccordionEvent;
}
interface Accordion extends Widget, AccordionOptions, AccordionEvents {
interface Accordion extends Widget, AccordionOptions {
}
@@ -86,7 +86,8 @@ declare module JQueryUI {
disabled?: boolean;
icons?: any;
label?: string;
text?: boolean;
text?: string|boolean;
click?: (event?: Event) => void;
}
interface Button extends Widget, ButtonOptions {
@@ -341,7 +342,7 @@ declare module JQueryUI {
interface DialogOptions extends DialogEvents {
autoOpen?: boolean;
buttons?: { [buttonText: string]: (event?: Event) => void } | ButtonOptions[];
buttons?: { [buttonText: string]: (event?: Event) => void } | DialogButtonOptions[];
closeOnEscape?: boolean;
closeText?: string;
dialogClass?: string;
@@ -365,6 +366,14 @@ declare module JQueryUI {
close?: DialogEvent;
}
interface DialogButtonOptions {
icons?: any;
showText?: string | boolean;
text?: string;
click?: (eventObject: JQueryEventObject) => any;
[attr: string]: any; // attributes for the <button> element
}
interface DialogShowHideOptions {
effect: string;
delay?: number;
@@ -516,9 +525,10 @@ declare module JQueryUI {
// Progressbar //////////////////////////////////////////////////
interface ProgressbarOptions {
interface ProgressbarOptions extends ProgressbarEvents {
disabled?: boolean;
value?: number | boolean;
max?: number;
}
interface ProgressbarUIParams {
@@ -534,7 +544,7 @@ declare module JQueryUI {
create?: ProgressbarEvent;
}
interface Progressbar extends Widget, ProgressbarOptions, ProgressbarEvents {
interface Progressbar extends Widget, ProgressbarOptions {
}
@@ -792,7 +802,7 @@ declare module JQueryUI {
// Tooltip //////////////////////////////////////////////////
interface TooltipOptions {
interface TooltipOptions extends TooltipEvents {
content?: any; // () or string
disabled?: boolean;
hide?: any; // boolean, number, string or object
@@ -815,7 +825,7 @@ declare module JQueryUI {
open?: TooltipEvent;
}
interface Tooltip extends Widget, TooltipOptions, TooltipEvents {
interface Tooltip extends Widget, TooltipOptions {
}
@@ -0,0 +1,49 @@
///<reference path="json-stable-stringify.d.ts"/>
import stringify = require('json-stable-stringify');
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
{
console.log(stringify(obj));
}
{
// Second arg can be a stringify.Comparator function.
var s: string = stringify(obj, (a: stringify.Element, b: stringify.Element): number => a.key < b.key ? 1 : -1);
console.log(s);
}
{
// Can specify Comparator in an Options object.
function reverse(a: stringify.Element, b: stringify.Element): number {
return a.value < b.value ? 1 : -1;
}
var opts: stringify.Options = { cmp: reverse };
var s: string = stringify(obj, opts);
console.log(s);
}
{
// Space can be a string.
var s: string = stringify(obj, { space: ' ' });
console.log(s);
}
{
// Space can be an integer.
var s: string = stringify(obj, { space: 2 });
console.log(s);
}
{
// The replacer option can remove or modify values.
function removeStrings(key: string, value: any): any {
if (typeof value === "string") {
return undefined;
}
return value;
}
var s: string = stringify(obj, { replacer: removeStrings });
console.log(s);
}
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for json-stable-stringify 1.0.0
// Project: https://github.com/substack/json-stable-stringify
// Definitions by: Matt Frantz <https://github.com/mhfrantz/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'json-stable-stringify' {
function stringify(obj: any, opts?: stringify.Comparator | stringify.Options): string;
module stringify {
interface Element {
key: string;
value: any;
}
interface Comparator {
(a: Element, b: Element): number;
}
interface Replacer {
(key: string, value: any): any;
}
interface Options {
cmp?: Comparator;
space?: number | string;
replacer?: Replacer;
}
}
export = stringify;
}
+1
View File
@@ -27,6 +27,7 @@ declare module "jsonwebtoken" {
audience?: string;
subject?: string;
issuer?: string;
noTimestamp?: boolean;
}
export interface VerifyOptions {
+141 -135
View File
@@ -6,38 +6,38 @@ var div = document.getElementById('map');
var map : L.Map = L.map(div, {
center: L.latLng([51.505, -0.09]),
zoom: 13,
minZoom: 3,
maxZoom: 8,
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
dragging: true,
touchZoom: true,
scrollWheelZoom: true,
boxZoom: true,
tap: true,
zoom: 13,
minZoom: 3,
maxZoom: 8,
maxBounds: L.latLngBounds([L.latLng(-60, -60), L.latLng(60, 60)]),
dragging: true,
touchZoom: true,
scrollWheelZoom: true,
boxZoom: true,
tap: true,
tapTolerance: 30,
trackResize: true,
worldCopyJump: false,
closePopupOnClick: true,
bounceAtZoomLimits: true,
tapTolerance: 30,
trackResize: true,
worldCopyJump: false,
closePopupOnClick: true,
bounceAtZoomLimits: true,
keyboard: true,
keyboardPanOffset: 80,
keyboardZoomOffset: 1,
keyboard: true,
keyboardPanOffset: 80,
keyboardZoomOffset: 1,
inertia: true,
inertiaDeceleration: 3000,
inertiaMaxSpeed: 1500,
inertiaThreshold: 32,
inertia: true,
inertiaDeceleration: 3000,
inertiaMaxSpeed: 1500,
inertiaThreshold: 32,
zoomControl: true,
attributionControl: true,
zoomControl: true,
attributionControl: true,
fadeAnimation: true,
zoomAnimation: true,
zoomAnimationThreshold: 4,
markerZoomAnimation: true
fadeAnimation: true,
zoomAnimation: true,
zoomAnimationThreshold: 4,
markerZoomAnimation: true
});
@@ -53,16 +53,16 @@ map.setView(L.latLng(42, 51));
map.setView(L.latLng(42, 51), 12);
map.setView(L.latLng(42, 51), 12, {
reset: true,
pan: {
animate: true,
duration: 0.25,
easeLinearity: 0.25,
noMoveStart: false
},
zoom: {
animate: true
}
reset: true,
pan: {
animate: true,
duration: 0.25,
easeLinearity: 0.25,
noMoveStart: false
},
zoom: {
animate: true
}
});
map.setZoom(50);
@@ -81,21 +81,21 @@ map.setZoomAround(L.latLng(42, 51), 8, { animate: false });
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.fitBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)), {
paddingTopLeft: L.point(20, 20),
paddingBottomRight: L.point(20, 20),
padding: L.point(0, 0),
maxZoom: null
paddingTopLeft: L.point(20, 20),
paddingBottomRight: L.point(20, 20),
padding: L.point(0, 0),
maxZoom: null
});
map.fitWorld();
map.fitWorld({
animate: false
animate: false
});
map.panTo(L.latLng(42, 42));
map.panTo(L.latLng(42, 42), {
animate: true
animate: true
});
map.invalidateSize(true);
@@ -105,12 +105,12 @@ map.setMaxBounds(L.latLngBounds(L.latLng(10, 10), L.latLng(20, 20)));
map.locate();
map.locate({
watch: false,
setView: false,
maxZoom: 18,
timeout: 10000,
maximumAge: 0,
enableHighAccuracy: false
watch: false,
setView: false,
maxZoom: 18,
timeout: 10000,
maximumAge: 0,
enableHighAccuracy: false
});
map.stopLocate();
@@ -138,7 +138,7 @@ map.hasLayer(layer);
map.openPopup("canard", L.latLng(42, 51));
var popup = L.popup({
autoPan: true
autoPan: true
});
map.openPopup(popup);
@@ -171,51 +171,51 @@ map.getPanes().shadowPane.classList.add('roger');
map.getPanes().tilePane.classList.add('roger');
map.whenReady((m: L.Map) => {
m.zoomOut();
m.zoomOut();
});
map.on('click', () => {
map.zoomOut();
map.zoomOut();
});
map.off('dblclick', L.Util.falseFn);
map.once('contextmenu', (e: L.LeafletMouseEvent) => {
map.openPopup('contextmenu', e.latlng);
map.openPopup('contextmenu', e.latlng);
});
var marker = L.marker(L.latLng(42, 51), {
icon: L.icon({
iconUrl: 'roger.png',
iconRetinaUrl: 'roger-retina.png',
iconSize: L.point(40, 40),
iconAnchor: L.point(20, 0),
shadowUrl: 'roger-shadow.png',
shadowRetinaUrl: 'roger-shadow-retina.png',
shadowSize: L.point(44, 44),
shadowAnchor: L.point(22, 0),
popupAnchor: L.point(0, 0),
className: 'roger-icon'
}),
clickable: true,
draggable: false,
keyboard: true,
title: 'this is an icon',
alt: '',
zIndexOffset: 0,
opacity: 1.0,
riseOnHover: false,
riseOffset: 250
icon: L.icon({
iconUrl: 'roger.png',
iconRetinaUrl: 'roger-retina.png',
iconSize: L.point(40, 40),
iconAnchor: L.point(20, 0),
shadowUrl: 'roger-shadow.png',
shadowRetinaUrl: 'roger-shadow-retina.png',
shadowSize: L.point(44, 44),
shadowAnchor: L.point(22, 0),
popupAnchor: L.point(0, 0),
className: 'roger-icon'
}),
clickable: true,
draggable: false,
keyboard: true,
title: 'this is an icon',
alt: '',
zIndexOffset: 0,
opacity: 1.0,
riseOnHover: false,
riseOffset: 250
});
marker.addTo(map);
marker.on('click', (e: L.LeafletMouseEvent) => {
map.setView(e.latlng);
map.setView(e.latlng);
});
marker.once('mouseover', () => {
marker.openPopup();
marker.openPopup();
})
marker.setLatLng(marker.getLatLng());
@@ -228,7 +228,7 @@ marker.setOpacity(0.8);
marker.bindPopup(popup);
marker.unbindPopup();
marker.bindPopup('hello', {
closeOnClick: true
closeOnClick: true
});
marker.openPopup();
@@ -244,19 +244,19 @@ marker.toGeoJSON();
marker.dragging.enable();
popup = L.popup({
maxWidth: 300,
minWidth: 50,
maxHeight: null,
autoPan: true,
keepInView: false,
closeButton: true,
offset: L.point(0, 6),
autoPanPaddingTopLeft: null,
autoPanPaddingBottomRight: L.point(20, 20),
autoPanPadding: L.point(5, 5),
zoomAnimation: true,
closeOnClick: null,
className: 'roger'
maxWidth: 300,
minWidth: 50,
maxHeight: null,
autoPan: true,
keepInView: false,
closeButton: true,
offset: L.point(0, 6),
autoPanPaddingTopLeft: null,
autoPanPaddingBottomRight: L.point(20, 20),
autoPanPadding: L.point(5, 5),
zoomAnimation: true,
closeOnClick: null,
className: 'roger'
});
popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
@@ -264,65 +264,65 @@ popup.setLatLng(L.latLng(12, 54)).setContent('this is nice popup').openOn(map);
popup.update();
var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {
minZoom: 0,
maxZoom: 18,
maxNativeZoom: 17,
tileSize: 256,
subdomains: ['a','b','c'],
errorTileUrl: '',
attribution: '',
tms: false,
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
zoomReverse: false,
opacity: 1.0,
zIndex: null,
unloadInvisibleTiles: false,
updateWhenIdle: false,
detectRetina: true,
reuseTiles: true,
bounds: null
minZoom: 0,
maxZoom: 18,
maxNativeZoom: 17,
tileSize: 256,
subdomains: ['a','b','c'],
errorTileUrl: '',
attribution: '',
tms: false,
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
zoomReverse: false,
opacity: 1.0,
zIndex: null,
unloadInvisibleTiles: false,
updateWhenIdle: false,
detectRetina: true,
reuseTiles: true,
bounds: null
});
tileLayer.on('loading', L.Util.falseFn)
.off('loading', L.Util.falseFn)
.once('tileload', L.Util.falseFn);
.off('loading', L.Util.falseFn)
.once('tileload', L.Util.falseFn);
tileLayer.addTo(map);
tileLayer.bringToBack()
.bringToFront()
.setOpacity(0.7)
.setZIndex(9)
.redraw()
.setUrl('http://perdu.com')
.getContainer();
.bringToFront()
.setOpacity(0.7)
.setZIndex(9)
.redraw()
.setUrl('http://perdu.com')
.getContainer();
module CustomControl {
export interface Options {
title: string;
position?: string;
}
export interface Options {
title: string;
position?: string;
}
}
interface CustomControl extends L.Control {
getTitle(): string;
setTitle(title: string): CustomControl;
getTitle(): string;
setTitle(title: string): CustomControl;
}
var CustomControl: { new(options: CustomControl.Options): CustomControl };
CustomControl = L.Control.extend<CustomControl.Options, CustomControl>({
initialize: function(options: CustomControl.Options) {
L.Control.prototype.initialize.call(this, {
position: options.position || 'bottomleft',
});
this.title = options.title;
},
getTitle: function() {
return this.title;
},
setTitle: function(title: string) {
this.title = title;
},
initialize: function(options: CustomControl.Options) {
L.Control.prototype.initialize.call(this, {
position: options.position || 'bottomleft',
});
this.title = options.title;
},
getTitle: function() {
return this.title;
},
setTitle: function(title: string) {
this.title = title;
},
});
// Different latLng and latLngBounds expressions
@@ -413,3 +413,9 @@ polyline.addLatLng(latLngObjectLiteral);
var popup: L.Popup = L.popup();
popup.setLatLng(latLngLiteral);
popup.setLatLng(latLngObjectLiteral);
var zoomCtrl = L.control.zoom({
position: "topleft",
zoomInText: '+',
zoomOutText: '-'
});
+203 -175
View File
@@ -382,17 +382,55 @@ declare module L {
onRemove(map: Map): void;
}
module Control {
namespace Control {
export interface ZoomStatic extends ClassStatic {
/**
* Creates a zoom control.
*/
new(options?: ZoomOptions): Zoom;
new (options?: ZoomOptions): Zoom;
}
export interface Zoom extends L.Control {
}
export interface ZoomOptions {
/**
* The position of the control (one of the map corners).
* Can be 'topleft', 'topright', 'bottomleft', or 'bottomright'.
*
* Default value: 'topright'.
*/
position?: string; // 'topleft' | 'topright' | 'bottomleft' | 'bottomright'
/**
* The text set on the zoom in button.
*
* Default value: '+'
*/
zoomInText?: string;
/**
* The text set on the zoom out button.
*
* Default value: '-'
*/
zoomOutText?: string;
/**
* The title set on the zoom in button.
*
* Default value: 'Zoom in'
*/
zoomInTitle?: string;
/**
* The title set on the zoom out button.
*
* Default value: 'Zoom out'
*/
zoomOutTitle?: string;
}
export interface AttributionStatic extends ClassStatic {
/**
* Creates an attribution control.
@@ -478,12 +516,12 @@ declare module L {
function (options?: ControlOptions): Control;
}
module control {
namespace control {
/**
* Creates a zoom control.
*/
export function zoom(options?: ZoomOptions): L.Control.Zoom;
export function zoom(options?: Control.ZoomOptions): L.Control.Zoom;
/**
* Creates an attribution control.
@@ -503,7 +541,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface ControlOptions {
@@ -517,9 +555,9 @@ declare module L {
}
}
declare module L {
declare namespace L {
module CRS {
namespace CRS {
/**
* The most common CRS for online maps, used by almost all free and commercial
@@ -549,7 +587,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Creates a div icon instance with the given options.
@@ -568,7 +606,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface DivIconOptions {
@@ -602,7 +640,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface DomEvent {
@@ -663,9 +701,9 @@ declare module L {
export var DomEvent: DomEvent;
}
declare module L {
declare namespace L {
module DomUtil {
namespace DomUtil {
/**
* Returns an element with the given id if a string was passed, or just returns
@@ -766,7 +804,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Creates a Draggable object for moving the given element when you start dragging
@@ -816,7 +854,7 @@ declare module L {
declare module L {
declare namespace L {
/**
* Create a layer group, optionally given an initial set of layers.
@@ -894,44 +932,7 @@ declare module L {
}
}
declare module L {
export interface FitBoundsOptions extends ZoomPanOptions {
/**
* Sets the amount of padding in the top left corner of a map container that
* shouldn't be accounted for when setting the view to fit bounds. Useful if
* you have some control overlays on the map like a sidebar and you don't
* want them to obscure objects you're zooming to.
*
* Default value: [0, 0].
*/
paddingTopLeft?: Point;
/**
* The same for bottom right corner of the map.
*
* Default value: [0, 0].
*/
paddingBottomRight?: Point;
/**
* Equivalent of setting both top left and bottom right padding to the same value.
*
* Default value: [0, 0].
*/
padding?: Point;
/**
* The maximum possible zoom to use.
*
* Default value: null
*/
maxZoom?: number;
}
}
declare module L {
declare namespace L {
/**
* Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format
@@ -994,7 +995,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface GeoJSONOptions {
/**
* Function that will be used for creating layers for GeoJSON points (if not
@@ -1031,7 +1032,7 @@ declare module L {
declare module L {
declare namespace L {
/**
* Creates an icon instance with the given options.
@@ -1058,7 +1059,7 @@ declare module L {
export interface Icon {
}
module Icon {
namespace Icon {
/**
* L.Icon.Default extends L.Icon and is the blue icon Leaflet uses
* for markers by default.
@@ -1068,7 +1069,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface IconOptions {
@@ -1133,7 +1134,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface IControl {
@@ -1153,7 +1154,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface ICRS {
@@ -1205,7 +1206,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface IEventPowered<T> {
@@ -1285,7 +1286,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface IHandler {
@@ -1310,7 +1311,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface ILayer {
@@ -1329,8 +1330,8 @@ declare module L {
}
}
declare module L {
module Mixin {
declare namespace L {
namespace Mixin {
export interface LeafletMixinEvents extends IEventPowered<LeafletMixinEvents> {
}
@@ -1338,7 +1339,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates an image overlay object given the URL of the image and the geographical
@@ -1398,7 +1399,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface ImageOverlayOptions {
@@ -1409,7 +1410,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface IProjection {
@@ -1425,7 +1426,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* A constant that represents the Leaflet version in use.
@@ -1439,7 +1440,7 @@ declare module L {
export function noConflict(): typeof L;
}
declare module L {
declare namespace L {
/**
* Creates an object representing a geographical point with the given latitude
* and longitude.
@@ -1524,7 +1525,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Creates a LatLngBounds object by defining south-west and north-east corners
@@ -1650,7 +1651,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Create a layer group, optionally given an initial set of layers.
@@ -1736,7 +1737,7 @@ declare module L {
}
declare module L {
declare namespace L {
export interface LayersOptions {
@@ -1766,7 +1767,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletErrorEvent extends LeafletEvent {
@@ -1782,7 +1783,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletEvent {
@@ -1798,7 +1799,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletGeoJSONEvent extends LeafletEvent {
@@ -1824,7 +1825,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletLayerEvent extends LeafletEvent {
@@ -1835,7 +1836,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletLocationEvent extends LeafletEvent {
@@ -1883,7 +1884,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletMouseEvent extends LeafletEvent {
@@ -1911,7 +1912,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletPopupEvent extends LeafletEvent {
@@ -1922,7 +1923,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletDragEndEvent extends LeafletEvent {
@@ -1933,7 +1934,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletResizeEvent extends LeafletEvent {
@@ -1949,7 +1950,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LeafletTileEvent extends LeafletEvent {
@@ -1965,9 +1966,9 @@ declare module L {
}
}
declare module L {
declare namespace L {
module LineUtil {
namespace LineUtil {
/**
* Dramatically reduces the number of points in a polyline while retaining
@@ -1999,7 +2000,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface LocateOptions {
@@ -2052,19 +2053,19 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a map object given a div element and optionally an
* object literal with map options described below.
*/
function map(id: HTMLElement, options?: MapOptions): Map;
function map(id: HTMLElement, options?: Map.MapOptions): Map;
/**
* Instantiates a map object given a div element id and optionally an
* object literal with map options described below.
*/
function map(id: string, options?: MapOptions): Map;
function map(id: string, options?: Map.MapOptions): Map;
export interface MapStatic extends ClassStatic {
@@ -2074,7 +2075,7 @@ declare module L {
*
* @constructor
*/
new(id: HTMLElement, options?: MapOptions): Map;
new(id: HTMLElement, options?: Map.MapOptions): Map;
/**
* Instantiates a map object given a div element id and optionally an
@@ -2082,7 +2083,7 @@ declare module L {
*
* @constructor
*/
new(id: string, options?: MapOptions): Map;
new(id: string, options?: Map.MapOptions): Map;
}
export var Map: MapStatic;
@@ -2093,40 +2094,40 @@ declare module L {
* Sets the view of the map (geographical center and zoom) with the given
* animation options.
*/
setView(center: LatLngExpression, zoom?: number, options?: ZoomPanOptions): Map;
setView(center: LatLngExpression, zoom?: number, options?: Map.ZoomPanOptions): Map;
/**
* Sets the zoom of the map.
*/
setZoom(zoom: number, options?: ZoomOptions): Map;
setZoom(zoom: number, options?: Map.ZoomPanOptions): Map;
/**
* Increases the zoom of the map by delta (1 by default).
*/
zoomIn(delta?: number, options?: ZoomOptions): Map;
zoomIn(delta?: number, options?: Map.ZoomPanOptions): Map;
/**
* Decreases the zoom of the map by delta (1 by default).
*/
zoomOut(delta?: number, options?: ZoomOptions): Map;
zoomOut(delta?: number, options?: Map.ZoomPanOptions): Map;
/**
* Zooms the map while keeping a specified point on the map stationary
* (e.g. used internally for scroll zoom and double-click zoom).
*/
setZoomAround(latlng: LatLngExpression, zoom: number, options?: ZoomOptions): Map;
setZoomAround(latlng: LatLngExpression, zoom: number, options?: Map.ZoomPanOptions): Map;
/**
* Sets a map view that contains the given geographical bounds with the maximum
* zoom level possible.
*/
fitBounds(bounds: LatLngBounds, options?: FitBoundsOptions): Map;
fitBounds(bounds: LatLngBounds, options?: Map.FitBoundsOptions): Map;
/**
* Sets a map view that mostly contains the whole world with the maximum zoom
* level possible.
*/
fitWorld(options?: FitBoundsOptions): Map;
fitWorld(options?: Map.FitBoundsOptions): Map;
/**
* Pans the map to a given center. Makes an animated pan if new center is not more
@@ -2150,7 +2151,7 @@ declare module L {
* after you've changed the map size dynamically, also animating pan by default.
* If options.pan is false, panning will not occur.
*/
invalidateSize(options: ZoomPanOptions): Map;
invalidateSize(options: Map.ZoomPanOptions): Map;
/**
* Checks if the map container size changed and updates the map if so call it
@@ -2162,7 +2163,7 @@ declare module L {
* Restricts the map view to the given bounds (see map maxBounds option),
* passing the given animation options through to `setView`, if required.
*/
setMaxBounds(bounds: LatLngBounds, options?: ZoomPanOptions): Map;
setMaxBounds(bounds: LatLngBounds, options?: Map.ZoomPanOptions): Map;
/**
* Tries to locate the user using Geolocation API, firing locationfound event
@@ -2422,7 +2423,7 @@ declare module L {
/**
* Map state options
*/
options: MapOptions;
options: Map.MapOptions;
////////////////
////////////////
@@ -2442,7 +2443,7 @@ declare module L {
}
}
declare module L {
declare namespace L.Map {
export interface MapOptions {
@@ -2680,9 +2681,82 @@ declare module L {
*/
bounceAtZoomLimits?: boolean;
}
export interface ZoomOptions {
/**
* If not specified, zoom animation will happen if the zoom origin is inside the current view.
* If true, the map will attempt animating zoom disregarding where zoom origin is.
* Setting false will make it always reset the view completely without animation.
*/
animate?: boolean;
}
export interface ZoomPanOptions {
/**
* If true, the map view will be completely reset (without any animations).
*
* Default value: false.
*/
reset?: boolean;
/**
* Sets the options for the panning (without the zoom change) if it occurs.
*/
pan?: PanOptions;
/**
* Sets the options for the zoom change if it occurs.
*/
zoom?: ZoomOptions;
/**
* An equivalent of passing animate to both zoom and pan options (see below).
*/
animate?: boolean;
/**
* If true, it will delay moveend event so that it doesn't happen many times in a row.
*/
debounceMoveend?: boolean;
}
export interface FitBoundsOptions extends ZoomPanOptions {
/**
* Sets the amount of padding in the top left corner of a map container that
* shouldn't be accounted for when setting the view to fit bounds. Useful if
* you have some control overlays on the map like a sidebar and you don't
* want them to obscure objects you're zooming to.
*
* Default value: [0, 0].
*/
paddingTopLeft?: Point;
/**
* The same for bottom right corner of the map.
*
* Default value: [0, 0].
*/
paddingBottomRight?: Point;
/**
* Equivalent of setting both top left and bottom right padding to the same value.
*
* Default value: [0, 0].
*/
padding?: Point;
/**
* The maximum possible zoom to use.
*
* Default value: null
*/
maxZoom?: number;
}
}
declare module L {
declare namespace L {
export interface MapPanes {
@@ -2723,7 +2797,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a Marker object given a geographical point and optionally
@@ -2873,7 +2947,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface MarkerOptions {
@@ -2953,7 +3027,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a multi-polyline object given an array of latlngs arrays (one
@@ -2996,7 +3070,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a multi-polyline object given an array of arrays of geographical
@@ -3037,7 +3111,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface PanOptions {
@@ -3073,7 +3147,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface Path extends ILayer, IEventPowered<Path> {
@@ -3171,7 +3245,7 @@ declare module L {
off(eventMap?: any, context?: any): Path;
}
module Path {
namespace Path {
/**
* True if SVG is used for vector rendering (true for most modern browsers).
*/
@@ -3201,7 +3275,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface PathOptions {
@@ -3297,7 +3371,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Creates a Point object with the given x and y coordinates. If optional round
@@ -3373,7 +3447,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a polygon object given an array of geographical points and
@@ -3401,7 +3475,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a polyline object given an array of geographical points and
@@ -3453,7 +3527,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface PolylineOptions extends PathOptions {
@@ -3474,9 +3548,9 @@ declare module L {
}
}
declare module L {
declare namespace L {
module PolyUtil {
namespace PolyUtil {
/**
* Clips the polygon geometry defined by the given points by rectangular bounds.
@@ -3488,7 +3562,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a Popup object given an optional options object that describes
@@ -3567,7 +3641,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface PopupOptions {
@@ -3665,7 +3739,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface PosAnimationStatic extends ClassStatic {
/**
@@ -3702,9 +3776,9 @@ declare module L {
}
}
declare module L {
declare namespace L {
module Projection {
namespace Projection {
/**
* Spherical Mercator projection the most common projection for online maps,
@@ -3730,7 +3804,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
/**
* Instantiates a rectangle object with the given geographical bounds and
@@ -3756,7 +3830,7 @@ declare module L {
}
declare module L {
declare namespace L {
export interface ScaleOptions {
@@ -3794,7 +3868,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface TileLayerStatic extends ClassStatic {
/**
@@ -3894,7 +3968,7 @@ declare module L {
off(eventMap?: any, context?: any): TileLayer;
}
module TileLayer {
namespace TileLayer {
export interface WMS extends TileLayer {
/**
* Merges an object with the new parameters and re-requests tiles on the current
@@ -3942,7 +4016,7 @@ declare module L {
export var tileLayer: TileLayerFactory;
}
declare module L {
declare namespace L {
export interface TileLayerOptions {
@@ -4089,7 +4163,7 @@ declare module L {
}
}
declare module L {
declare namespace L {
export interface TransformationStatic extends ClassStatic {
/**
* Creates a transformation object with the given coefficients.
@@ -4113,9 +4187,9 @@ declare module L {
}
}
declare module L {
declare namespace L {
module Util {
namespace Util {
/**
* Merges the properties of the src object (or multiple objects) into dest object
@@ -4197,7 +4271,7 @@ declare module L {
}
declare module L {
declare namespace L {
export interface WMSOptions {
@@ -4237,52 +4311,6 @@ declare module L {
}
}
declare module L {
export interface ZoomOptions {
/**
* If not specified, zoom animation will happen if the zoom origin is inside the current view.
* If true, the map will attempt animating zoom disregarding where zoom origin is.
* Setting false will make it always reset the view completely without animation.
*/
animate?: boolean;
}
}
declare module L {
export interface ZoomPanOptions {
/**
* If true, the map view will be completely reset (without any animations).
*
* Default value: false.
*/
reset?: boolean;
/**
* Sets the options for the panning (without the zoom change) if it occurs.
*/
pan?: PanOptions;
/**
* Sets the options for the zoom change if it occurs.
*/
zoom?: ZoomOptions;
/**
* An equivalent of passing animate to both zoom and pan options (see below).
*/
animate?: boolean;
/**
* If true, it will delay moveend event so that it doesn't happen many times in a row.
*/
debounceMoveend?: boolean;
}
}
/**
* Forces Leaflet to use the Canvas back-end (if available) for vector layers
* instead of SVG. This can increase performance considerably in some cases
+28
View File
@@ -0,0 +1,28 @@
/// <reference path="level-sublevel.d.ts" />
import levelup = require('levelup');
import sublevel = require('level-sublevel');
var db = sublevel(levelup('./tmp/sublevel-example'));
var sub = db.sublevel('stuff');
db.put('foo', 'bar', err => {});
sub.put('foo', 'bar', err => {});
db.pre((ch, add) => {
add({
key: ''+Date.now(),
value: ch.key,
type: 'put',
prefix: sub
})
});
var sub1 = db.sublevel('SUB_1');
var sub2 = db.sublevel('SUM_2');
sub1.batch([
{ key: 'key', value: 'Value', type: 'put' },
{ key: 'key', value: 'Value', type: 'put', prefix: sub2 }
], err => { if (err) throw err; });
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for level-sublevel
// Project: https://github.com/dominictarr/level-sublevel
// Definitions by: Bas Pennings <https://github.com/basp/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../levelup/levelup.d.ts" />
interface Hook {
(ch: any, add: (op: Batch|boolean) => void): void;
}
interface Batch {
prefix?: Sublevel;
}
interface Sublevel extends LevelUp {
sublevel(key: string): Sublevel;
pre(hook: Hook): Function;
}
declare module "level-sublevel" {
function sublevel(levelup: LevelUp): Sublevel;
export = sublevel;
}
+2 -2
View File
@@ -22,8 +22,8 @@ interface LevelUp {
del(key: any, options ?: { keyEncoding?: string; sync?: boolean }, callback ?: (error: any) => any): void;
batch(array: Batch[], options?: { keyEncoding?: string; valueEncoding?: string; sync?: boolean }, callback?: (error?: any)=>any);
batch(array: Batch[], callback?: (error?: any)=>any);
batch(array: Batch[], options?: { keyEncoding?: string; valueEncoding?: string; sync?: boolean }, callback?: (error?: any)=>any): void;
batch(array: Batch[], callback?: (error?: any)=>any): void;
batch():LevelUpChain;
isOpen():boolean;
isClosed():boolean;
+6 -19
View File
@@ -1,13 +1,6 @@
/// <reference path="localForage.d.ts" />
declare var localForage: lf.ILocalForage<string>;
declare var callback: lf.ICallback<string>;
declare var iterateCallback: lf.IIterateCallback<string>;
declare var errorCallback: lf.IErrorCallback;
declare var keyCallback: lf.IKeyCallback;
declare var keysCallback: lf.IKeysCallback;
declare var numberCallback: lf.INumberCallback;
declare var promise: lf.IPromise<string>;
declare var localForage: LocalForage;
() => {
localForage.clear((err: any) => {
@@ -25,7 +18,7 @@ declare var promise: lf.IPromise<string>;
var newNumber: number = num;
});
localForage.key(0,(err: any, value: string) => {
localForage.key(0, (err: any, value: string) => {
var newError: any = err;
var newValue: string = value;
});
@@ -40,9 +33,8 @@ declare var promise: lf.IPromise<string>;
var newStr: string = str
});
localForage.getItem("key").then((err: any, str: string) => {
var newError: any = err;
var newStr: string = str
localForage.getItem<string>("key").then((str: string) => {
var newStr: string = str;
});
localForage.setItem("key", "value",(err: any, str: string) => {
@@ -50,8 +42,7 @@ declare var promise: lf.IPromise<string>;
var newStr: string = str
});
localForage.setItem("key", "value").then((err: any, str: string) => {
var newError: any = err;
localForage.setItem("key", "value").then((str: string) => {
var newStr: string = str;
});
@@ -59,10 +50,6 @@ declare var promise: lf.IPromise<string>;
var newError: any = err;
});
localForage.removeItem("key").then((err: any, str: string) => {
var newError: any = err;
var newStr: string = str
localForage.removeItem("key").then(() => {
});
promise.then(callback);
}
+73 -65
View File
@@ -3,71 +3,79 @@
// Definitions by: yuichi david pichsenmeister <https://github.com/3x14159265>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module lf {
interface ILocalForage<T> {
/**
* Removes every key from the database, returning it to a blank slate.
*/
clear(callback: IErrorCallback): void
/**
* Iterate over all value/key pairs in datastore.
*/
iterate(iterateCallback: IIterateCallback<T>): void
/**
* Get the name of a key based on its ID.
*/
key(keyIndex: number, callback: IKeyCallback): void
/**
* Get the list of all keys in the datastore.
*/
keys(callback: IKeysCallback): void;
/**
* Gets the number of keys in the offline store (i.e. its length).
*/
length(callback: INumberCallback): void
/**
* Gets an item from the storage library and supplies the result to a callback.
* If the key does not exist, getItem() will return null.
*/
getItem(key: string, callback: ICallback<T>): void
getItem(key: string): IPromise<T>
/**
* Saves data to an offline store.
*/
setItem(key: string, value: T, callback: ICallback<T>): void
setItem(key: string, value: T): IPromise<T>
/**
* Removes the value of a key from the offline store.
*/
removeItem(key: string, callback: IErrorCallback): void
removeItem(key: string): IPromise<T>
}
/// <reference path="../es6-promise/es6-promise.d.ts" />
interface ICallback<T> {
(err: any, value: T): void
}
interface LocalForageOptions {
driver?: LocalForageDriver | LocalForageDriver[];
name?: string;
size?: number;
storeName?: string;
version?: string;
description?: string;
}
interface IIterateCallback<T> {
(value: T, key: string, iterationNumber: number): void
}
interface LocalForageDriver {
_driver: string;
_initStorage(options: LocalForageOptions): void;
_support: boolean | Promise<boolean>;
clear(callback: (err: any) => void): void;
getItem(key: string, callback: (err: any, value: any) => void): void;
key(keyIndex: number, callback: (err: any, key: string) => void): void;
keys(callback: (err: any, keys: string[]) => void): void;
length(callback: (err: any, numberOfKeys: number) => void): void;
removeItem(key: string, callback: (err: any) => void): void;
setItem(key: string, value: any, callback: (err: any, value: any) => void): void;
}
interface IErrorCallback {
(err: any): void
}
interface IKeyCallback {
(err: any, keyName: string): void
}
interface IKeysCallback {
(err: any, keys: Array<string>): void
}
interface INumberCallback {
(err: any, numberOfKeys: number): void
}
interface IPromise<T> {
then(callback: ICallback<T>): void
}
}
interface LocalForage {
LOCALSTORAGE: string;
WEBSQL: string;
INDEXEDDB: string;
config(options: LocalForageOptions): void;
driver(): LocalForageDriver;
setDriver(driver: string | string[]): Promise<void>;
setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void;
defineDriver(driver: LocalForageDriver): Promise<void>;
defineDriver(driver: LocalForageDriver, callback: () => void, errorCallback: (error: any) => void): void;
getItem<T>(key: string): Promise<T>;
getItem<T>(key: string, callback: (err: any, value: T) => void): void;
setItem<T>(key: string, value: T): Promise<T>;
setItem<T>(key: string, value: T, callback: (err: any, value: T) => void): void;
removeItem(key: string): Promise<void>;
removeItem(key: string, callback: (err: any) => void): void;
clear(): Promise<void>;
clear(callback: (err: any) => void): void;
length(): Promise<number>;
length(callback: (err: any, numberOfKeys: number) => void): void;
key(keyIndex: number): Promise<string>;
key(keyIndex: number, callback: (err: any, key: string) => void): void;
keys(): Promise<string[]>;
keys(callback: (err: any, keys: string[]) => void): void;
iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise<any>;
iterate(iteratee: (value: any, key: string, iterationNumber: number) => any,
callback: (err: any, result: any) => void): void;
}
+310 -52
View File
@@ -135,8 +135,6 @@ result = <number>_([1, 2, 3, 4]).pop();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).push(5, 6, 7);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).reverse();
result = <number>_([1, 2, 3, 4]).shift();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).slice(1, 2);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).slice(2);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sort((a, b) => 1);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
@@ -172,8 +170,43 @@ result = <_.LoDashArrayWrapper<number[]>>_([1, 2, 3, 4]).chunk(2);
result = <any[]>_.compact([0, 1, false, 2, '', 3]);
result = <_.LoDashArrayWrapper<any>>_([0, 1, false, 2, '', 3]).compact();
result = <number[]>_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4, 5]).difference([5, 2, 10]);
// _.difference
{
let testDifferenceArray: TResult[];
let testDifferenceList: _.List<TResult>;
let result: TResult[];
result = _.difference<TResult>(testDifferenceArray);
result = _.difference<TResult>(testDifferenceArray, testDifferenceArray);
result = _.difference<TResult>(testDifferenceArray, testDifferenceList, testDifferenceArray);
result = _.difference<TResult>(testDifferenceArray, testDifferenceArray, testDifferenceList, testDifferenceArray);
result = _.difference<TResult>(testDifferenceList);
result = _.difference<TResult>(testDifferenceList, testDifferenceList);
result = _.difference<TResult>(testDifferenceList, testDifferenceArray, testDifferenceList);
result = _.difference<TResult>(testDifferenceList, testDifferenceList, testDifferenceArray, testDifferenceList);
result = _(testDifferenceArray).difference().value();
result = _(testDifferenceArray).difference(testDifferenceArray).value();
result = _(testDifferenceArray).difference(testDifferenceList, testDifferenceArray).value();
result = _(testDifferenceArray).difference(testDifferenceArray, testDifferenceList, testDifferenceArray).value();
result = _(testDifferenceList).difference<TResult>().value();
result = _(testDifferenceList).difference<TResult>(testDifferenceList).value();
result = _(testDifferenceList).difference<TResult>(testDifferenceArray, testDifferenceList).value();
result = _(testDifferenceList).difference<TResult>(testDifferenceList, testDifferenceArray, testDifferenceList).value();
}
// _.drop
{
let testDropArray: TResult[];
let testDropList: _.List<TResult>;
let result: TResult[];
result = _.drop<TResult>(testDropArray);
result = _.drop<TResult>(testDropArray, 42);
result = _.drop<TResult>(testDropList);
result = _.drop<TResult>(testDropList, 42);
result = _(testDropArray).drop().value();
result = _(testDropArray).drop(42).value();
result = _(testDropList).drop<TResult>().value();
result = _(testDropList).drop<TResult>(42).value();
}
result = <number[]>_.rest([1, 2, 3]);
result = <number[]>_.rest([1, 2, 3], 2);
@@ -181,12 +214,6 @@ result = <number[]>_.rest([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.rest(foodsOrganic, 'test');
result = <IFoodType[]>_.rest(foodsType, { 'type': 'value' });
result = <number[]>_.drop([1, 2, 3]);
result = <number[]>_.drop([1, 2, 3], 2);
result = <number[]>_.drop([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.drop(foodsOrganic, 'test');
result = <IFoodType[]>_.drop(foodsType, { 'type': 'value' });
result = <number[]>_.tail([1, 2, 3])
result = <number[]>_.tail([1, 2, 3], 2)
result = <number[]>_.tail([1, 2, 3], (num) => num < 3)
@@ -282,15 +309,29 @@ result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2);
result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
result = <number>_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
result = <number[]>_.initial([1, 2, 3]);
result = <number[]>_.initial([1, 2, 3], 2);
result = <number[]>_.initial([1, 2, 3], function (num) {
return num > 1;
});
result = <IFoodOrganic[]>_.initial(foodsOrganic, 'organic');
result = <IFoodType[]>_.initial(foodsType, { 'type': 'vegetable' });
//_.initial
{
let testInitalArray: TResult[];
let testInitalList: _.List<TResult>;
let result: TResult[];
result = _.initial<TResult>(testInitalArray);
result = _.initial<TResult>(testInitalList);
result = _(testInitalArray).initial().value();
result = _(testInitalList).initial<TResult>().value();
}
result = <number[]>_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// _.intersection
{
let testIntersectionArray: TResult[];
let testIntersectionList: _.List<TResult>;
let result: TResult[];
result = _.intersection<TResult>(testIntersectionArray, testIntersectionList);
result = _.intersection<TResult>(testIntersectionList, testIntersectionArray, testIntersectionList);
result = _(testIntersectionArray).intersection<TResult>(testIntersectionArray).value();
result = _(testIntersectionArray).intersection<TResult>(testIntersectionList, testIntersectionArray).value();
result = _(testIntersectionList).intersection<TResult>(testIntersectionArray).value();
result = _(testIntersectionList).intersection<TResult>(testIntersectionList, testIntersectionArray).value();
}
result = <number>_.last([1, 2, 3]);
result = <number>_([1, 2, 3]).last();
@@ -298,6 +339,57 @@ result = <number>_([1, 2, 3]).last();
result = <number>_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
result = <number>_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
// _.pull
{
let testPullArray: TResult[];
let testPullValue: TResult;
let result: TResult[];
result = _.pull<TResult>(testPullArray);
result = _.pull<TResult>(testPullArray, testPullValue);
result = _.pull<TResult>(testPullArray, testPullValue, testPullValue);
result = _.pull<TResult>(testPullArray, testPullValue, testPullValue, testPullValue);
result = _(testPullArray).pull().value();
result = _(testPullArray).pull(testPullValue).value();
result = _(testPullArray).pull(testPullValue, testPullValue).value();
result = _(testPullArray).pull(testPullValue, testPullValue, testPullValue).value();
}
{
let testPullList: _.List<TResult>;
let testPullValue: TResult;
let result: _.List<TResult>;
result = _.pull<TResult>(testPullList);
result = _.pull<TResult>(testPullList, testPullValue);
result = _.pull<TResult>(testPullList, testPullValue, testPullValue);
result = _.pull<TResult>(testPullList, testPullValue, testPullValue, testPullValue);
result = _(testPullList).pull<TResult>().value();
result = _(testPullList).pull<TResult>(testPullValue).value();
result = _(testPullList).pull<TResult>(testPullValue, testPullValue).value();
result = _(testPullList).pull<TResult>(testPullValue, testPullValue, testPullValue).value();
}
// _.pullAt
{
let testPullAtArray: TResult[];
let testPullAtList: _.List<TResult>;
let result: TResult[];
result = _.pullAt<TResult>(testPullAtArray);
result = _.pullAt<TResult>(testPullAtArray, 1);
result = _.pullAt<TResult>(testPullAtArray, [2, 3], 1);
result = _.pullAt<TResult>(testPullAtArray, 4, [2, 3], 1);
result = _.pullAt<TResult>(testPullAtList);
result = _.pullAt<TResult>(testPullAtList, 1);
result = _.pullAt<TResult>(testPullAtList, [2, 3], 1);
result = _.pullAt<TResult>(testPullAtList, 4, [2, 3], 1);
result = _(testPullAtArray).pullAt().value();
result = _(testPullAtArray).pullAt(1).value();
result = _(testPullAtArray).pullAt([2, 3], 1).value();
result = _(testPullAtArray).pullAt(4, [2, 3], 1).value();
result = _(testPullAtList).pullAt<TResult>().value();
result = _(testPullAtList).pullAt<TResult>(1).value();
result = _(testPullAtList).pullAt<TResult>([2, 3], 1).value();
result = _(testPullAtList).pullAt<TResult>(4, [2, 3], 1).value();
}
result = <_.Dictionary<any>>_.zipObject(['moe', 'larry'], [30, 40]);
result = <_.LoDashObjectWrapper<_.Dictionary<any>>>_(['moe', 'larry']).zipObject([30, 40]);
result = <_.Dictionary<any>>_.object(['moe', 'larry'], [30, 40]);
@@ -307,14 +399,23 @@ result = <_.LoDashObjectWrapper<_.Dictionary<any>>>_([['moe', 30], ['larry', 40]
result = <_.Dictionary<any>>_.object([['moe', 30], ['larry', 40]]);
result = <_.LoDashObjectWrapper<_.Dictionary<any>>>_([['moe', 30], ['larry', 40]]).object();
result = <number[]>_.pull([1, 2, 3, 1, 2, 3], 2, 3);
result = <number[]>_.pullAt([1, 2, 3, 1, 2, 3], 2, 3);
result = <number[]>_.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; });
result = <IFoodOrganic[]>_.remove(foodsOrganic, 'organic');
result = <IFoodType[]>_.remove(foodsType, { 'type': 'vegetable' });
var typedResult: IFoodType[] = _.remove([ <IFoodType>{ name: 'apple' }, <IFoodType>{ name: 'orange' }], <IFoodType>{ name: 'orange' });
// _.slice
{
let testSliceArray: TResult[];
let result: TResult[];
result = _.slice(testSliceArray);
result = _.slice(testSliceArray, 42);
result = _.slice(testSliceArray, 42, 42);
result = _(testSliceArray).slice().value();
result = _(testSliceArray).slice(42).value();
result = _(testSliceArray).slice(42, 42).value();
}
result = <number>_.sortedIndex([20, 30, 50], 40);
result = <number>_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
var sortedIndexDict: { wordToNumber: { [idx: string]: number } } = {
@@ -327,6 +428,21 @@ result = <number>_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function
return this.wordToNumber[word];
}, sortedIndexDict);
// _.takeRight
{
let testTakeRightArray: TResult[];
let testTakeRightList: _.List<TResult>;
let result: TResult[];
result = _.takeRight<TResult>(testTakeRightArray);
result = _.takeRight<TResult>(testTakeRightArray, 42);
result = _.takeRight<TResult>(testTakeRightList);
result = _.takeRight<TResult>(testTakeRightList, 42);
result = _(testTakeRightArray).takeRight().value();
result = _(testTakeRightArray).takeRight(42).value();
result = _(testTakeRightList).takeRight<TResult>().value();
result = _(testTakeRightList).takeRight<TResult>(42).value();
}
result = <number[]>_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
result = <number[]>_([1, 2, 3]).union([101, 2, 1, 10], [2, 1]).value();
@@ -363,7 +479,46 @@ result = <string[]>_(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) {
result = <number[]>_([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value();
result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value();
result = <number[]>_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
// _.unzipWith
{
let testUnzipWithArray: (number[]|_.List<number>)[];
let testUnzipWithList: _.List<number[]|_.List<number>>;
let testUnzipWithIterator: {(prev: TResult, curr: number, index?: number, list?: number[]): TResult};
let result: TResult[];
result = _.unzipWith<number, TResult>(testUnzipWithArray);
result = _.unzipWith<number, TResult>(testUnzipWithArray, testUnzipWithIterator);
result = _.unzipWith<number, TResult>(testUnzipWithArray, testUnzipWithIterator, any);
result = _.unzipWith<number, TResult>(testUnzipWithList);
result = _.unzipWith<number, TResult>(testUnzipWithList, testUnzipWithIterator);
result = _.unzipWith<number, TResult>(testUnzipWithList, testUnzipWithIterator, any);
result = _(testUnzipWithArray).unzipWith<number, TResult>(testUnzipWithIterator).value();
result = _(testUnzipWithArray).unzipWith<number, TResult>(testUnzipWithIterator, any).value();
result = _(testUnzipWithList).unzipWith<number, TResult>(testUnzipWithIterator).value();
result = _(testUnzipWithList).unzipWith<number, TResult>(testUnzipWithIterator, any).value();
}
// _.without
{
let testWithoutArray: number[];
let testWithoutList: _.List<number>;
let result: number[];
result = _.without<number>(testWithoutArray);
result = _.without<number>(testWithoutArray, 1);
result = _.without<number>(testWithoutArray, 1, 2);
result = _.without<number>(testWithoutArray, 1, 2, 3);
result = _.without<number>(testWithoutList);
result = _.without<number>(testWithoutList, 1);
result = _.without<number>(testWithoutList, 1, 2);
result = _.without<number>(testWithoutList, 1, 2, 3);
result = _(testWithoutArray).without().value();
result = _(testWithoutArray).without(1).value();
result = _(testWithoutArray).without(1, 2).value();
result = _(testWithoutArray).without(1, 2, 3).value();
result = _(testWithoutList).without<number>().value();
result = _(testWithoutList).without<number>(1).value();
result = _(testWithoutList).without<number>(1, 2).value();
result = _(testWithoutList).without<number>(1, 2, 3).value();
}
// _.xor
var testXorArray: number[];
@@ -439,6 +594,46 @@ result = <number[]>_([1, 2]).zipWith<number>([1, 2], [1, 2], [1, 2], [1, 2], [1,
result = _([1, 2, 3]).thru<number>((value: number[]) => value, any);
}
// _.prototype.commit
{
let result: _.LoDashWrapper<number>;
result = _(42).commit();
}
{
let result: _.LoDashArrayWrapper<any>;
result = _<any>([]).commit();
}
{
let result: _.LoDashObjectWrapper<any>;
result = _({}).commit();
}
// _.prototype.plant
{
let result: _.LoDashWrapper<number>;
result = _(any).plant(42);
}
{
let result: _.LoDashStringWrapper;
result = _(any).plant('');
}
{
let result: _.LoDashWrapper<boolean>;
result = _(any).plant(true);
}
{
let result: _.LoDashNumberArrayWrapper;
result = _(any).plant([42]);
}
{
let result: _.LoDashArrayWrapper<any>;
result = _(any).plant<any>([]);
}
{
let result: _.LoDashObjectWrapper<{}>;
result = _(any).plant<{}>({});
}
/**************
* Collection *
**************/
@@ -1552,11 +1747,14 @@ result = <boolean>_({}).has(42);
result = <boolean>_({}).has(true);
result = <boolean>_({}).has(['', 42, true]);
interface FirstSecond {
first: string;
second: string;
// _.invert
{
let result: TResult;
result = _.invert<Object, TResult>({});
result = _.invert<Object, TResult>({}, true);
result = _({}).invert<TResult>().value();
result = _({}).invert<TResult>(true).value();
}
result = <FirstSecond>_.invert({ 'first': 'moe', 'second': 'larry' });
// _.isEqual (alias: _.eq)
result = <boolean>_.isEqual(1, 1);
@@ -1664,9 +1862,27 @@ interface TestPickFn {
result = _({}).pick<TResult>(testPickFn, any).value();
}
// _.result
{
let testResultPath: number|string|boolean|Array<number|string|boolean>;
let testResultDefaultValue: TResult;
let result: TResult;
result = _.result<{}, TResult>({}, testResultPath);
result = _.result<{}, TResult>({}, testResultPath, testResultDefaultValue);
result = _({}).result<TResult>(testResultPath);
result = _({}).result<TResult>(testResultPath, testResultDefaultValue);
}
// _.set
result = <{ a: { b: { c: number; }}[]}>_.set({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c', 4);
result = <{ a: { b: { c: number; }}[]}>_({ 'a': [{ 'b': { 'c': 3 } }] }).set('a[0].b.c', 4).value();
{
let testSetObject: TResult;
let testSetPath: {toSting(): string};
let result: TResult;
result = _.set(testSetObject, testSetPath, any);
result = _.set(testSetObject, [testSetPath], any);
result = _(testSetObject).set(testSetPath, any).value();
result = _(testSetObject).set([testSetPath], any).value();
}
result = <number[]>_.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r: number[], num: number) {
num *= num;
@@ -1716,8 +1932,6 @@ var testAttempFn: TestAttemptFn;
result = <TResult|Error>_.attempt<TResult>(testAttempFn);
result = <TResult|Error>_(testAttempFn).attempt<TResult>();
var lodash = <typeof _>_.noConflict();
result = <number>_.random(0, 5);
result = <number>_.random(5);
result = <number>_.random(5, true);
@@ -1735,25 +1949,6 @@ result = <void>_<string>([]).noop(true, 'a', 1);
result = <void>_({}).noop(true, 'a', 1);
result = <void>_(any).noop(true, 'a', 1);
var object = {
'cheese': 'crumpets',
'one': 1,
'nested': {
'two': 2
},
'stuff': function () {
return 'nonsense';
}
};
result = <string>_.result(object, 'cheese');
result = <string>_.result(object, 'stuff');
result = _.result<number>(object, 'one');
result = _.result<number>(object, ['nested', 'two'] );
var tempObject = {};
result = <typeof _>_.runInContext(tempObject);
// _.property
interface TestPropertyObject {
a: {
@@ -1941,9 +2136,32 @@ result = <string[]>_.words('fred, barney, & pebbles', /[^, ]+/g);
result = <string[]>_('fred, barney, & pebbles').words();
result = <string[]>_('fred, barney, & pebbles').words(/[^, ]+/g);
/**********
* Utilities *
***********/
/***********
* Utility *
***********/
// _.callback
{
let result: (...args: any[]) => TResult;
result = _.callback<TResult>(Function);
result = _.callback<TResult>(Function, any);
result = _(Function).callback<TResult>().value();
result = _(Function).callback<TResult>(any).value();
}
{
let result: (object: any) => TResult;
result = _.callback<TResult>('');
result = _.callback<TResult>('', any);
result = _('').callback<TResult>().value();
result = _('').callback<TResult>(any).value();
}
{
let result: (object: any) => boolean;
result = _.callback({});
result = _.callback({}, any);
result = _({}).callback().value();
result = _({}).callback(any).value();
}
// _.constant
result = <() => number>_.constant<number>(1);
@@ -1973,6 +2191,29 @@ result = <() => {}>_({}).constant<{}>();
result = _<boolean>([]).identity();
}
// _.iteratee
{
let result: (...args: any[]) => TResult;
result = _.iteratee<TResult>(Function);
result = _.iteratee<TResult>(Function, any);
result = _(Function).iteratee<TResult>().value();
result = _(Function).iteratee<TResult>(any).value();
}
{
let result: (object: any) => TResult;
result = _.iteratee<TResult>('');
result = _.iteratee<TResult>('', any);
result = _('').iteratee<TResult>().value();
result = _('').iteratee<TResult>(any).value();
}
{
let result: (object: any) => boolean;
result = _.iteratee({});
result = _.iteratee({}, any);
result = _({}).iteratee().value();
result = _({}).iteratee(any).value();
}
// _.method
class TestMethod {
a = {
@@ -2012,6 +2253,23 @@ result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())(['a', '0
result = _(testMixinSource).mixin<TResult>(testMixinOptions).value();
}
// _.noConflict
{
let result: typeof _;
result = _.noConflict();
result = _(42).noConflict();
result = _<any>([]).noConflict();
result = _({}).noConflict();
}
// _.runInContext
{
let result: typeof _;
result = _.runInContext();
result = _.runInContext({});
result = _({}).runInContext();
}
// _.uniqueId
result = <string>_.uniqueId();
result = <string>_.uniqueId('');
+502 -263
View File
@@ -258,7 +258,6 @@ declare module _ {
push(...items: T[]): LoDashArrayWrapper<T>;
reverse(): LoDashArrayWrapper<T>;
shift(): T;
slice(start: number, end?: number): LoDashArrayWrapper<T>;
sort(compareFn?: (a: T, b: T) => number): LoDashArrayWrapper<T>;
splice(start: number): LoDashArrayWrapper<T>;
splice(start: number, deleteCount: number, ...items: any[]): LoDashArrayWrapper<T>;
@@ -367,34 +366,57 @@ declare module _ {
//_.difference
interface LoDashStatic {
/**
* Creates an array excluding all values of the provided arrays using strict equality for comparisons
* , i.e. ===.
* @param array The array to process
* @param others The arrays of values to exclude.
* @return Returns a new array of filtered values.
**/
* Creates an array of unique array values not included in the other provided arrays using SameValueZero for
* equality comparisons.
*
* @param array The array to inspect.
* @param values The arrays of values to exclude.
* @return Returns the new array of filtered values.
*/
difference<T>(
array?: Array<T>,
...others: Array<T>[]): T[];
/**
* @see _.difference
**/
difference<T>(
array?: List<T>,
...others: List<T>[]): T[];
array: T[]|List<T>,
...values: (T[]|List<T>)[]
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.difference
**/
difference(
...others: Array<T>[]): LoDashArrayWrapper<T>;
* @see _.difference
*/
difference(...values: (T[]|List<T>)[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.difference
**/
difference(
...others: List<T>[]): LoDashArrayWrapper<T>;
* @see _.difference
*/
difference<TValue>(...values: (TValue[]|List<TValue>)[]): LoDashArrayWrapper<TValue>;
}
//_.drop
interface LoDashStatic {
/**
* Creates a slice of array with n elements dropped from the beginning.
*
* @param array The array to query.
* @param n The number of elements to drop.
* @return Returns the slice of array.
*/
drop<T>(array: T[]|List<T>, n?: number): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.drop
*/
drop(n?: number): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.drop
*/
drop<TResult>(n?: number): LoDashArrayWrapper<TResult>;
}
//_.findIndex
@@ -937,108 +959,52 @@ declare module _ {
//_.initial
interface LoDashStatic {
/**
* Gets all but the last element or last n elements of an array. If a callback is provided
* elements at the end of the array are excluded from the result as long as the callback
* returns truey. The callback is bound to thisArg and invoked with three arguments;
* (value, index, array).
*
* If a property name is provided for callback the created "_.pluck" style callback will
* return the property value of the given element.
*
* If an object is provided for callback the created "_.where" style callback will return
* true for elements that have the properties of the given object, else false.
* @param array The array to query.
* @param n Leaves this many elements behind, optional.
* @return Returns everything but the last `n` elements of `array`.
**/
initial<T>(
array: Array<T>): T[];
* Gets all but the last element of array.
*
* @param array The array to query.
* @return Returns the slice of array.
*/
initial<T>(array: T[]|List<T>): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.initial
**/
initial<T>(
array: List<T>): T[];
* @see _.initial
*/
initial(): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.initial
* @param n The number of elements to exclude.
**/
initial<T>(
array: Array<T>,
n: number): T[];
/**
* @see _.initial
* @param n The number of elements to exclude.
**/
initial<T>(
array: List<T>,
n: number): T[];
/**
* @see _.initial
* @param callback The function called per element
**/
initial<T>(
array: Array<T>,
callback: ListIterator<T, boolean>): T[];
/**
* @see _.initial
* @param callback The function called per element
**/
initial<T>(
array: List<T>,
callback: ListIterator<T, boolean>): T[];
/**
* @see _.initial
* @param pluckValue _.pluck style callback
**/
initial<T>(
array: Array<T>,
pluckValue: string): T[];
/**
* @see _.initial
* @param pluckValue _.pluck style callback
**/
initial<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.initial
* @param whereValue _.where style callback
**/
initial<W, T>(
array: Array<T>,
whereValue: W): T[];
/**
* @see _.initial
* @param whereValue _.where style callback
**/
initial<W, T>(
array: List<T>,
whereValue: W): T[];
* @see _.initial
*/
initial<TResult>(): LoDashArrayWrapper<TResult>;
}
//_.intersection
interface LoDashStatic {
/**
* Creates an array of unique values present in all provided arrays using strict
* equality for comparisons, i.e. ===.
* @param arrays The arrays to inspect.
* @return Returns an array of composite values.
**/
intersection<T>(...arrays: Array<T>[]): T[];
* Creates an array of unique values that are included in all of the provided arrays using SameValueZero for
* equality comparisons.
*
* @param arrays The arrays to inspect.
* @return Returns the new array of shared values.
*/
intersection<T>(...arrays: (T[]|List<T>)[]): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.intersection
**/
intersection<T>(...arrays: List<T>[]): T[];
* @see _.intersection
*/
intersection<TResult>(...arrays: (TResult[]|List<TResult>)[]): LoDashArrayWrapper<TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.intersection
*/
intersection<TResult>(...arrays: (TResult[]|List<TResult>)[]): LoDashArrayWrapper<TResult>;
}
//_.last
@@ -1086,42 +1052,72 @@ declare module _ {
//_.pull
interface LoDashStatic {
/**
* Removes all provided values from the given array using strict equality for comparisons,
* i.e. ===.
* @param array The array to modify.
* @param values The values to remove.
* @return array.
**/
pull<T>(
array: Array<T>,
...values: T[]): T[];
/**
* @see _.pull
**/
pull<T>(
array: List<T>,
...values: T[]): T[];
}
interface LoDashStatic {
/**
* Removes all provided values from the given array using strict equality for comparisons,
* i.e. ===.
* Removes all provided values from array using SameValueZero for equality comparisons.
*
* Note: Unlike _.without, this method mutates array.
*
* @param array The array to modify.
* @param values The values to remove.
* @return array.
**/
pullAt(
array: Array<any>,
...values: any[]): any[];
* @return Returns array.
*/
pull<T>(
array: T[],
...values: T[]
): T[];
/**
* @see _.pull
**/
pullAt(
array: List<any>,
...values: any[]): any[];
*/
pull<T>(
array: List<T>,
...values: T[]
): List<T>;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.pull
*/
pull(...values: T[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.pull
*/
pull<TValue>(...values: TValue[]): LoDashObjectWrapper<List<TValue>>;
}
//_.pullAt
interface LoDashStatic {
/**
* Removes elements from array corresponding to the given indexes and returns an array of the removed elements.
* Indexes may be specified as an array of indexes or as individual arguments.
*
* Note: Unlike _.at, this method mutates array.
*
* @param array The array to modify.
* @param indexes The indexes of elements to remove, specified as individual indexes or arrays of indexes.
* @return Returns the new array of removed elements.
*/
pullAt<T>(
array: T[]|List<T>,
...indexes: (number|number[])[]
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.pullAt
*/
pullAt(...indexes: (number|number[])[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.pullAt
*/
pullAt<TValue>(...indexes: (number|number[])[]): LoDashArrayWrapper<TValue>;
}
//_.remove
@@ -1280,74 +1276,6 @@ declare module _ {
array: List<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
drop<T>(array: Array<T>): T[];
/**
* @see _.rest
**/
drop<T>(array: List<T>): T[];
/**
* @see _.rest
**/
drop<T>(
array: Array<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: Array<T>,
n: number): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
n: number): T[];
/**
* @see _.rest
**/
drop<T>(
array: Array<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
drop<W, T>(
array: Array<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
drop<W, T>(
array: List<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
@@ -1417,6 +1345,33 @@ declare module _ {
whereValue: W): T[];
}
//_.slice
interface LoDashStatic {
/**
* Creates a slice of array from start up to, but not including, end.
*
* @param array The array to slice.
* @param start The start position.
* @param end The end position.
* @return Returns the slice of array.
*/
slice<T>(
array: T[],
start?: number,
end?: number
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.slice
*/
slice(
start?: number,
end?: number
): LoDashArrayWrapper<T>;
}
//_.sortedIndex
interface LoDashStatic {
/**
@@ -1487,6 +1442,35 @@ declare module _ {
whereValue: W): number;
}
//_.takeRight
interface LoDashStatic {
/**
* Creates a slice of array with n elements taken from the end.
*
* @param array The array to query.
* @param n The number of elements to take.
* @return Returns the slice of array.
*/
takeRight<T>(
array: T[]|List<T>,
n?: number
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.takeRight
*/
takeRight(n?: number): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.takeRight
*/
takeRight<TResult>(n?: number): LoDashArrayWrapper<TResult>;
}
//_.union
interface LoDashStatic {
/**
@@ -1852,24 +1836,72 @@ declare module _ {
whereValue: W): LoDashArrayWrapper<T>;
}
//_.unzipWith
interface LoDashStatic {
/**
* This method is like _.unzip except that it accepts an iteratee to specify how regrouped values should be
* combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index,
* group).
*
* @param array The array of grouped elements to process.
* @param iteratee The function to combine regrouped values.
* @param thisArg The this binding of iteratee.
* @return Returns the new array of regrouped elements.
*/
unzipWith<TArray, TResult>(
array: List<List<TArray>>,
iteratee?: MemoIterator<TArray, TResult>,
thisArg?: any
): TResult[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.unzipWith
*/
unzipWith<TArr, TResult>(
iteratee?: MemoIterator<TArr, TResult>,
thisArg?: any
): LoDashArrayWrapper<TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.unzipWith
*/
unzipWith<TArr, TResult>(
iteratee?: MemoIterator<TArr, TResult>,
thisArg?: any
): LoDashArrayWrapper<TResult>;
}
//_.without
interface LoDashStatic {
/**
* Creates an array excluding all provided values using strict equality for comparisons, i.e. ===.
* @param array The array to filter.
* @param values The value(s) to exclude.
* @return A new array of filtered values.
**/
* Creates an array excluding all provided values using SameValueZero for equality comparisons.
*
* @param array The array to filter.
* @param values The values to exclude.
* @return Returns the new array of filtered values.
*/
without<T>(
array: Array<T>,
...values: T[]): T[];
array: T[]|List<T>,
...values: T[]
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.without
**/
without<T>(
array: List<T>,
...values: T[]): T[];
* @see _.without
*/
without(...values: T[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.without
*/
without<TValue>(...values: TValue[]): LoDashArrayWrapper<TValue>;
}
//_.xor
@@ -2056,6 +2088,56 @@ declare module _ {
thisArg?: any): LoDashArrayWrapper<TResult>;
}
// _.prototype.commit
interface LoDashWrapperBase<T, TWrapper> {
/**
* Executes the chained sequence and returns the wrapped result.
*
* @return Returns the new lodash wrapper instance.
*/
commit(): TWrapper;
}
//_.prototype.plant
interface LoDashWrapperBase<T, TWrapper> {
/**
* Creates a clone of the chained sequence planting value as the wrapped value.
* @param value The value to plant as the wrapped value.
* @return Returns the new lodash wrapper instance.
*/
plant(value: number): LoDashWrapper<number>;
/**
* @see _.plant
*/
plant(value: string): LoDashStringWrapper;
/**
* @see _.plant
*/
plant(value: boolean): LoDashWrapper<boolean>;
/**
* @see _.plant
*/
plant(value: number[]): LoDashNumberArrayWrapper;
/**
* @see _.plant
*/
plant<T>(value: T[]): LoDashArrayWrapper<T>;
/**
* @see _.plant
*/
plant<T extends {}>(value: T): LoDashObjectWrapper<T>;
/**
* @see _.plant
*/
plant(value: any): LoDashWrapper<any>;
}
/**************
* Collection *
**************/
@@ -7190,11 +7272,21 @@ declare module _ {
//_.invert
interface LoDashStatic {
/**
* Creates an object composed of the inverted keys and values of the given object.
* @param object The object to invert.
* @return The created inverted object.
**/
invert(object: any): any;
* Creates an object composed of the inverted keys and values of object. If object contains duplicate values,
* subsequent values overwrite property assignments of previous values unless multiValue is true.
*
* @param object The object to invert.
* @param multiValue Allow multiple values per key.
* @return Returns the new inverted object.
*/
invert<T extends {}, TResult extends {}>(object: T, multiValue?: boolean): TResult;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.invert
*/
invert<TResult extends {}>(multiValue?: boolean): LoDashObjectWrapper<TResult>;
}
//_.isEqual
@@ -7540,26 +7632,59 @@ declare module _ {
): LoDashObjectWrapper<TResult>;
}
//_.result
interface LoDashStatic {
/**
* This method is like _.get except that if the resolved value is a function its invoked with the this binding
* of its parent object and its result is returned.
*
* @param object The object to query.
* @param path The path of the property to resolve.
* @param defaultValue The value returned if the resolved value is undefined.
* @return Returns the resolved value.
*/
result<TObject, TResult>(
object: TObject,
path: number|string|boolean|Array<number|string|boolean>,
defaultValue?: TResult
): TResult;
}
interface LoDashWrapperBase<T, TWrapper> {
/**
* @see _.result
*/
result<TResult>(
path: number|string|boolean|Array<number|string|boolean>,
defaultValue?: TResult
): TResult;
}
//_.set
interface LoDashStatic {
/**
* Sets the property value of path on object. If a portion of path does not exist it is created.
* Sets the property value of path on object. If a portion of path does not exist its created.
*
* @param object The object to augment.
* @param path The path of the property to set.
* @param value The value to set.
* @return Returns object.
**/
set<T>(object: T,
path: string|string[],
value: any): T;
*/
set<T>(
object: T,
path: StringRepresentable|StringRepresentable[],
value: any
): T;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.set
**/
set(path: string|string[],
value: any): LoDashObjectWrapper<T>;
*/
set(
path: StringRepresentable|StringRepresentable[],
value: any
): LoDashObjectWrapper<T>;
}
//_.transform
@@ -8117,6 +8242,64 @@ declare module _ {
attempt<TResult>(): TResult|Error;
}
//_.callback
interface LoDashStatic {
/**
* Creates a function that invokes func with the this binding of thisArg and arguments of the created function.
* If func is a property name the created callback returns the property value for a given element. If func is
* an object the created callback returns true for elements that contain the equivalent object properties,
* otherwise it returns false.
*
* @param func The value to convert to a callback.
* @param thisArg The this binding of func.
* @result Returns the callback.
*/
callback<TResult>(
func: Function,
thisArg?: any
): (...args: any[]) => TResult;
/**
* @see _.callback
*/
callback<TResult>(
func: string,
thisArg?: any
): (object: any) => TResult;
/**
* @see _.callback
*/
callback(
func: Object,
thisArg?: any
): (object: any) => boolean;
/**
* @see _.callback
*/
callback<TResult>(): (value: TResult) => TResult;
}
interface LoDashWrapper<T> {
/**
* @see _.callback
*/
callback<TResult>(thisArg?: any): LoDashObjectWrapper<(object: any) => TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.callback
*/
callback(thisArg?: any): LoDashObjectWrapper<(object: any) => boolean>;
/**
* @see _.callback
*/
callback<TResult>(thisArg?: any): LoDashObjectWrapper<(...args: any[]) => TResult>;
}
//_.identity
interface LoDashStatic {
/**
@@ -8148,6 +8331,57 @@ declare module _ {
identity(): T;
}
//_.iteratee
interface LoDashStatic {
/**
* @see _.callback
*/
iteratee<TResult>(
func: Function,
thisArg?: any
): (...args: any[]) => TResult;
/**
* @see _.callback
*/
iteratee<TResult>(
func: string,
thisArg?: any
): (object: any) => TResult;
/**
* @see _.callback
*/
iteratee(
func: Object,
thisArg?: any
): (object: any) => boolean;
/**
* @see _.callback
*/
iteratee<TResult>(): (value: TResult) => TResult;
}
interface LoDashWrapper<T> {
/**
* @see _.callback
*/
iteratee<TResult>(thisArg?: any): LoDashObjectWrapper<(object: any) => TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.callback
*/
iteratee(thisArg?: any): LoDashObjectWrapper<(object: any) => boolean>;
/**
* @see _.callback
*/
iteratee<TResult>(thisArg?: any): LoDashObjectWrapper<(...args: any[]) => TResult>;
}
//_.method
interface LoDashStatic {
/**
@@ -8262,9 +8496,17 @@ declare module _ {
//_.noConflict
interface LoDashStatic {
/**
* Reverts the '_' variable to its previous value and returns a reference to the lodash function.
* @return The lodash function.
**/
* Reverts the _ variable to its previous value and returns a reference to the lodash function.
*
* @return Returns the lodash function.
*/
noConflict(): typeof _;
}
interface LoDashWrapperBase<T, TWrapper> {
/**
* @see _.noConflict
*/
noConflict(): typeof _;
}
@@ -8379,29 +8621,22 @@ declare module _ {
random(min: number, max: number, floating?: boolean): number;
}
//_.result
interface LoDashStatic {
/**
* Resolves the value of property on object. If property is a function it will be invoked with
* the this binding of object and its result returned, else the property value is returned. If
* object is false then undefined is returned.
* @param object The object to query.
* @param path The path of the property to resolve.
* @param defaultValue The value returned if the resolved value is undefined.
* @return The resolved value.
**/
result<T>(object: any, path: string|string[], defaultValue?: T): T;
}
//_.runInContext
interface LoDashStatic {
/**
* Create a new lodash function using the given context object.
* @param context The context object
* @returns The lodash function.
**/
runInContext(context: any): typeof _;
* Create a new pristine lodash function using the given context object.
*
* @param context The context object.
* @return Returns a new lodash function.
*/
runInContext(context?: Object): typeof _;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.runInContext
*/
runInContext(): typeof _;
}
//_.times
@@ -8489,10 +8724,10 @@ declare module _ {
}
interface MemoVoidIterator<T, TResult> {
(prev: TResult, curr: T, indexOrKey: any, list?: T[]): void;
(prev: TResult, curr: T, indexOrKey?: any, list?: T[]): void;
}
interface MemoIterator<T, TResult> {
(prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult;
(prev: TResult, curr: T, indexOrKey?: any, list?: T[]): TResult;
}
/*
interface MemoListIterator<T, TResult> {
@@ -8514,6 +8749,10 @@ declare module _ {
interface Dictionary<T> {
[index: string]: T;
}
interface StringRepresentable {
toString(): string;
}
}
declare module "lodash" {
+5 -1
View File
@@ -1,4 +1,4 @@
/// <reference path="log4javascript.d.ts" />
/// <reference path="./log4javascript.d.ts" />
function aSimpleLoggingMessageString() {
var log = log4javascript.getDefaultLogger();
@@ -47,4 +47,8 @@ function changingTheFormatOfLogMessages() {
var popUpAppender = new log4javascript.PopUpAppender();
var layout = new log4javascript.PatternLayout("[%-5p] %m");
popUpAppender.setLayout(layout);
}
function configureLogLog() {
log4javascript.logLog.setQuietMode(true);
}
+34 -26
View File
@@ -1051,38 +1051,46 @@ declare module log4javascript {
// #region log4javascript error handling
/**
* Sets whether LogLog is in quiet mode or not. In quiet mode, no messages sent to LogLog have any visible effect. By default,
* quiet mode is switched off.
* @param quietMode Whether to turn quiet mode on or off.
* log4javascript has a single rudimentary logger-like object of its own to handle messages generated by log4javascript itself.
* This logger is called logLog and is accessed via log4javascript.logLog.
*/
export function setQuietMode(quietMode: boolean): void;
export namespace logLog {
/**
* Sets how many errors LogLog will display alerts for. By default, only the first error encountered generates an alert to the
* user. If you turn all errors on by supplying true to this method then all errors will generate alerts.
* @param showAllErrors Whether to show all errors or just the first.
*/
export function setAlertAllErrors(alertAllErrors: boolean): void;
/**
* Sets whether logLog is in quiet mode or not. In quiet mode, no messages sent to logLog have any visible effect. By default,
* quiet mode is switched off.
* @param quietMode Whether to turn quiet mode on or off.
*/
export function setQuietMode(quietMode: boolean): void;
/**
* Logs a debugging message to an in-memory list.
*/
export function debug(message: string, exception?: Error): void;
/**
* Sets how many errors logLog will display alerts for. By default, only the first error encountered generates an alert to the
* user. If you turn all errors on by supplying true to this method then all errors will generate alerts.
* @param showAllErrors Whether to show all errors or just the first.
*/
export function setAlertAllErrors(alertAllErrors: boolean): void;
/**
* Displays an alert of all debugging messages.
*/
export function displayDebug(): void;
/**
* Logs a debugging message to an in-memory list.
*/
export function debug(message: string, exception?: Error): void;
/**
* Currently has no effect.
*/
export function warn(message: string, exception?: Error): void;
/**
* Displays an alert of all debugging messages.
*/
export function displayDebug(): void;
/**
* Generates an alert to the user if and only if the error is the first one encountered and setAlertAllErrors(true) has not been called.
*/
export function error(message: string, exception?: Error): void;
/**
* Currently has no effect.
*/
export function warn(message: string, exception?: Error): void;
/**
* Generates an alert to the user if and only if the error is the first one encountered and setAlertAllErrors(true) has not been called.
*/
export function error(message: string, exception?: Error): void;
}
// #endregion
}
+1 -1
View File
@@ -21,7 +21,7 @@ declare module L.mapbox {
function map(element: string, id: string, options?: MapOptions): L.mapbox.Map;
function map(element: string, tilejson: any, options?: MapOptions): L.mapbox.Map;
interface MapOptions extends L.MapOptions {
interface MapOptions extends L.Map.MapOptions {
featureLayer? : FeatureLayerOptions;
gridLayer? : any;
tileLayer? : TileLayerOptions;
+123
View File
@@ -0,0 +1,123 @@
/// <reference path="meshblu.d.ts" />
import Meshblu = require('meshblu');
var UUID = "26de691f-8068-4cdc-907a-4cb5961a1aba";
var TOKEN = "4cb5961a1aba26de691f80684cdc907a";
var meshblu = Meshblu.createConnection({
uuid: UUID,
token: TOKEN
});
meshblu.data({
uuid: UUID,
online: true,
x: -53,
y: 234
}, function(result) {
console.log(result);
});
meshblu.device({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.devices({
color: "green"
}, function(result) {
console.log(result);
});
meshblu.generateAndStoreToken({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.getdata({
uuid: UUID,
start: "2015-04-23T18:25:43.511Z",
finish: "2015-04-24T18:25:43.511Z",
limit: 10
}, function(result) {
console.log(result);
});
meshblu.identify();
meshblu.message({
devices: [UUID],
topic: "status",
payload: {
online: true
}
}, function(result) {
console.log(result);
});
meshblu.register({
type: "drone"
}, function(result) {
console.log(result);
});
meshblu.revokeToken({
uuid: UUID,
token: TOKEN
}, function(result) {
console.log(result);
});
meshblu.subscribe({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.subscribe({
uuid: UUID,
types: ["sent", "received"]
}, function(result) {
console.log(result);
});
meshblu.subscribe({
uuid: UUID,
types: ["sent", "received"],
topics: ["device*", "-*status"]
}, function(result) {
console.log(result);
});
meshblu.unsubscribe({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.unsubscribe({
uuid: UUID,
types: ["sent", "broadcast"]
}, function(result) {
console.log(result);
});
meshblu.update({
uuid: UUID,
color: "blue"
}, function(result) {
console.log(result);
});
meshblu.whoami({}, function(result) {
console.log(result);
});
meshblu.unregister({
uuid: UUID
}, function(result) {
console.log(result);
});
+281
View File
@@ -0,0 +1,281 @@
// Type definitions for meshblu.js 1.30.1
// Project: https://github.com/octoblu/meshblu-npm
// Definitions by: Felipe Nipo <https://github.com/fnipo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path='../node/node.d.ts' />
declare module 'meshblu' {
var Meshblu: MeshbluStatic;
export = Meshblu;
}
interface MeshbluStatic {
/**
* Establish a secure socket.io connection to Meshblu.
* @param opt
* @returns A Meshblu Connection.
*/
createConnection(opt: Meshblu.ConnectionOptions): Meshblu.Connection;
}
declare module Meshblu {
interface Connection {
/**
* Authenticate with Meshblu.
* @returns This Connection.
*/
identify(): Connection;
/**
* @param data {string|number|object|array|Buffer} - data for signing.
*/
sign(data: any): string;
/**
* @param message {string|number|object|array|Buffer} - signed data.
* @param signature
* @returns {*}
*/
verify(message: any, signature: any): any;
/**
* @param uuid
* @param message {string|number|object|array|Buffer} - data for encrypting.
* @param options
* @param fn The callback to be called. It should take one parameter, result,
* which is an object containing a property "error".
* @returns This Connection.
*/
encryptMessage(uuid: string, message: any, options: Meshblu.ConnectionOptions, fn:(result: any) => void): Connection;
/**
* Send a meshblu message.
* @param payload An array of devices UUIDs.
* @param fn The callback to be called. It should take one parameter, result,
* which is an object containing a property "error".
* @returns This Connection.
*/
message(payload: MessagePayload, fn:(result: any) => void): Connection;
/**
* Update a device record.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
update(data: UpdateData, fn:(result: UpdateSuccess) => void): Connection;
/**
* Register a new device record.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
register(data: RegisterData, fn:(result: RegisterResponse) => void): Connection;
/**
* Removes a device record.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
unregister(data: Device, fn:(result: Device) => void): Connection;
/**
* Get my device info.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
whoami(data: any, fn:(result: DeviceResponse) => void): Connection;
/**
* Find a Meshblu device.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
device(data: Device, fn:(result: DeviceResponse) => void): Connection
/**
* Find Meshblu devices.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
devices(data: Color, fn:(result: DeviceResponse[]) => void): Connection
/**
* Returns device messages as they are sent and received.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
subscribe(data: SubscribeData, fn:(result: any) => void): Connection
/**
* Cancels device subscription.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
unsubscribe(data: UnsubscribeData, fn:(result: any) => void): Connection
/**
* Send a meshblu data message.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
data(data: DataInput, fn:(result: any) => void): Connection
/**
* Get a meshblu data for a device.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
* @returns This Connection.
*/
getdata(data: GetDataInput, fn:(result: any) => void): Connection
/**
* Generate a new session token for a device.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
*/
generateAndStoreToken(data: Device, fn:(result: ConnectionOptions) => void): void
/**
* Remove a session token from a device.
* @param data
* @param fn The callback to be called. It should take one parameter, result.
*/
revokeToken(data: ConnectionOptions, fn:(result: Device) => void): void
/**
*
* @param uuid
* @param fn The callback to be called. It should take one parameter, err,
* which will be null if there was no problem, and one parameter, publicKey,
* of type NodeRSA.
*/
getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void;
/*
* Lack of documentation about these api functions.
*/
send(text: string): Connection;
bufferedSocketEmit(): void;
parseUrl(serverUrl: string, port: string): string;
generateKeyPair(): KeyPair;
setPrivateKey(privateKey: string): void;
setup(): Connection;
connect(): void;
reconnect(): void;
claimdevice(data: Device, fn:(result: Device) => void): Connection;
mydevices(data: any, fn:(result: any) => void): Connection
status(data: any): Connection
authenticate(data: any, fn:(result: any) => void): Connection
events(data: any, fn:(result: any) => void): Connection
localdevices(fn:(result: any) => void): Connection
unclaimeddevices(data: any, fn:(result: any) => void): Connection
textBroadcast(data: any): Connection
directText(data: any): Connection
subscribeText(data: any, fn:(result: any) => void): Connection
unsubscribeText(data: any, fn:(result: any) => void): Connection
close(fn:(result: any) => void): Connection
resetToken(data: any, fn:(result: any) => void): void
}
/**
* Contains the primary means of identifying a device.
*/
interface ConnectionOptions {
uuid: string;
token: string;
}
interface KeyPair {
privateKey: string;
publicKey: string;
}
interface MessagePayload {
devices: string[];
topic: string;
payload: any;
qos?: number;
}
interface UpdateData {
uuid: string;
color: string;
}
interface UpdateSuccess {
uuid: string;
token: string;
status: string;
}
interface RegisterData {
type: string;
}
interface RegisterResponse {
uuid: string;
token: string;
type: string;
}
interface Device {
uuid: string;
}
interface DeviceResponse {
uuid: string;
online: boolean;
color: string;
}
interface Color {
color: string;
}
interface SubscribeData {
uuid: string;
types?: string[];
topics?: string[];
}
interface UnsubscribeData {
uuid: string;
types?: string[];
}
interface DataInput {
uuid: string;
online: boolean;
x: number;
y: number;
}
interface GetDataInput {
uuid: string;
start: string;
finish: string;
limit: number;
}
interface IdentifySuccess {
uuid: string;
token: string;
status: string;
}
}
+81
View File
@@ -0,0 +1,81 @@
/// <reference path="msportalfx-test.d.ts" />
import testFx = require('MsPortalFx-Test');
var galleryPackageName = "My.Package";
var bladeTitle = "A Service";
var resourceProvider = 'My.Provider';
var resourceType = 'myResourceType';
var resourceName = 'myResource';
var userName = 'johndoe@johndoe.com';
var password = '123';
var resourceId = '/subscriptions/123/resourceGroups/456/providers/My.Provider/myResourceType/myResource';
var extensionName = 'LocalExtension';
var label = 'Field label';
var extensionUrl = 'https://localhost:44300/';
var voidPromise: Q.Promise<void>;
var boolPromise: Q.Promise<boolean>;
var anyPromise: Q.Promise<any>;
var summaryBlade = new testFx.Blades.Blade(resourceName);
function TestPortal() {
testFx.portal.portalContext.signInEmail = userName;
testFx.portal.portalContext.signInPassword = password;
testFx.portal.portalContext.features = [{ name: "greatfeature", value: "true" }];
testFx.portal.portalContext.testExtensions = [{ name: extensionName, uri: extensionUrl }];
anyPromise = testFx.portal.waitForElementLocated(summaryBlade.getLocator(), 30000);
anyPromise = testFx.portal.quit();
var createBladePromise = testFx.portal.openGalleryCreateBlade(galleryPackageName, bladeTitle, 20000);
var browseResourcePromise = testFx.portal.openBrowseBlade(resourceProvider, resourceType, bladeTitle, 20000);
var bladePromise = testFx.portal.openResourceBlade(resourceId, summaryBlade.title, 20000)
var stringPromise = testFx.portal.takeScreenshot("TestPortal");
var stringArrayPromise = testFx.portal.getBrowserLogs(testFx.LogLevel.All);
}
function TestBlades() {
var blade = new testFx.Blades.Blade(resourceName);
blade.clickCommand('Delete');
var createBlade = new testFx.Blades.CreateBlade(bladeTitle);
voidPromise = createBlade.actionBar.clickCreate();
voidPromise = createBlade.actionBar.clickDelete();
var browseBlade = new testFx.Blades.BrowseResourceBlade(bladeTitle);
voidPromise = browseBlade.selectResource(resourceName);
var pickerBlade = new testFx.Blades.PickerBlade(bladeTitle);
pickerBlade.pickItem('abc');
}
function TestParts() {
var part = new testFx.Parts.Part(summaryBlade.getLocator(), "Roles");
voidPromise = part.click();
boolPromise = part.isSelected();
boolPromise = part.waitUntilLoaded();
boolPromise = part.isLoaded();
var resourceSummary = new testFx.Parts.ResourceSummaryPart(summaryBlade.getLocator());
var count = resourceSummary.properties.length;
}
function TestControls() {
var selector = new testFx.Controls.SelectorField(summaryBlade.getLocator(), label);
voidPromise = selector.openPicker();
var creatorAndSelector = new testFx.Controls.CreatorAndSelectorField(summaryBlade.getLocator(), label, label);
var creatorAndSelectorPromise = creatorAndSelector.clickCreateNew();
creatorAndSelectorPromise = creatorAndSelector.enterNewValue('XYZ');
var textField = new testFx.Controls.TextField(summaryBlade.getLocator(), "Resource name");
var textFieldPromise = textField.sendKeys(resourceName);
}
function TestActionBars() {
var bar = new testFx.ActionBars.ActionBar(summaryBlade.getLocator());
voidPromise = bar.clickCreate();
voidPromise = bar.clickDelete();
}
+224
View File
@@ -0,0 +1,224 @@
// Type definitions for msportalfx-test
// Project: https://msazure.visualstudio.com/DefaultCollection/AzureUX/_git/portalfx-msportalfx-test
// Definitions by: Julio Casal <https://github.com/julioct>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../q/Q.d.ts" />
declare module MsPortalTestFx {
export module Locators {
export class Locator {
seleniumLocator: any;
findElements(context: any): any;
toString(): string;
}
export class ContentLocator extends Locator {
locators: Array<Locator>;
constructor(innerLocators: Locator[]);
findElements(context: any): any;
toString(): string;
}
export class ChainedLocator extends Locator {
locators: Array<Locator>;
constructor(innerLocators: Locator[]);
findElements(context: any): any;
toString(): string;
}
export class By {
static className(value: string): Locator;
static css(value: string): Locator;
static id(value: string): Locator;
static js(script: any, ...var_args: any[]): Locator;
static linkText(value: string): Locator;
static name(value: string): Locator;
static partialLinkText(value: string): Locator;
static tagName(value: string): Locator;
static xpath(value: string): Locator;
static chained(...values: Locator[]): Locator;
static content(...values: Locator[]): Locator;
}
}
export module ActionBars {
export class ActionBar extends MsPortalTestFx.PortalElement {
constructor(parentLocator?: Locators.Locator);
clickCreate(): Q.Promise<void>;
clickDelete(): Q.Promise<void>;
}
}
export module Blades {
export class Blade extends MsPortalTestFx.PortalElement {
public title: string;
constructor(title: string);
clickCommand(commandText: string): Q.Promise<Blade>;
}
export class CreateBlade extends Blade {
public actionBar: ActionBars.ActionBar;
}
export class BrowseResourceBlade extends Blade {
constructor(title: string);
selectResource(resourceName: string): Q.Promise<void>;
filterItems(filter: string): Q.Promise<BrowseResourceBlade>;
}
export class PickerBlade extends Blade {
constructor(title: string);
pickItem(item: string): Q.Promise<void>;
}
}
export module Controls {
export class FormElement extends MsPortalTestFx.PortalElement {
protected label: string;
constructor(baseLocator: Locators.Locator, parentLocator?: Locators.Locator, label?: string);
}
export class CheckBoxField extends FormElement {
constructor(parentLocator?: Locators.Locator, label?: string);
}
export class SelectorField extends FormElement {
constructor(parentLocator?: Locators.Locator, label?: string);
openPicker(): Q.Promise<void>;
}
export class CreatorAndSelectorField extends FormElement {
constructor(parentLocator?: Locators.Locator, selectModeLabel?: string, createModeLabel?: string);
openPicker(): Q.Promise<void>;
clickCreateNew(): Q.Promise<CreatorAndSelectorField>;
enterNewValue(...var_args: string[]): Q.Promise<CreatorAndSelectorField>;
}
export class GridCell extends MsPortalTestFx.PortalElement {
constructor(text: string, parentLocator?: Locators.Locator);
getLocator(): Locators.Locator;
}
export class TextField extends FormElement {
constructor(parentLocator?: Locators.Locator, label?: string, baseLocator?: Locators.Locator);
sendKeys(...var_args: string[]): Q.Promise<TextField>;
}
export class ResourceFilterTextField extends TextField {
constructor(parentLocator?: Locators.Locator);
}
}
export module Parts {
export class Part extends MsPortalTestFx.PortalElement {
public innerText: string;
constructor(parentLocator?: Locators.Locator, innerText?: string, baseLocator?: Locators.Locator);
isSelected(): Q.Promise<boolean>;
isLoaded(): Q.Promise<boolean>;
waitUntilLoaded(timeout?: number): Q.Promise<boolean>;
}
export class PartProperty extends MsPortalTestFx.PortalElement {
public name: string;
constructor(name: string, parentLocator?: Locators.Locator);
getValue(): Q.Promise<string>;
}
export class ResourceSummaryPart extends Part {
public properties: Array<PartProperty>;
public resourceGroupProperty: PartProperty;
constructor(parentLocator?: Locators.Locator);
}
export class Tile extends MsPortalTestFx.PortalElement {
public progressLocator: Locators.Locator;
constructor(parentLocator?: Locators.Locator);
}
}
export class PortalElement {
protected baseLocator: Locators.Locator;
protected parentLocator: Locators.Locator;
constructor(baseLocator: Locators.Locator, parentLocator?: Locators.Locator);
getLocator(): Locators.Locator;
click(): Q.Promise<void>;
getAttribute(attributeName: string): Q.Promise<string>;
}
export interface TestExtension {
name: string;
uri: string;
}
export interface Feature {
name: string;
value: string;
}
export interface PortalContext {
capabilities: {
browserName: string;
chromeOptions: {
args: string[]
}
},
chromeDriverPath?: string,
portalUrl: string;
signInUrl?: string;
signInEmail?: string;
signInPassword?: string;
features?: Feature[];
testExtensions?: TestExtension[];
}
export enum LogLevel {
All,
Debug,
Info,
Warning,
Severe,
Off
}
export class Portal {
portalContext: PortalContext;
click(locator: Locators.Locator): Q.Promise<void>;
sendKeys(locator: Locators.Locator, ...var_args: string[]): Q.Promise<void>
getText(locator: Locators.Locator): Q.Promise<string>;
openGalleryCreateBlade(galleryPackageName: string, bladeTitle: string, timeout?: number): Q.Promise<Blades.CreateBlade>;
openBrowseBlade(resourceProvider: string, resourceType: string, bladeTitle: string, timeout?: number): Q.Promise<Blades.BrowseResourceBlade>;
openResourceBlade(resourceId: string, bladeTitle: string, timeout?: number): Q.Promise<Blades.Blade>;
navigateToDeepLink(deepLink: string, timeout?: number): Q.Promise<any>;
getAttribute(locator: Locators.Locator, attributeName: string, timeout?: number): Q.Promise<string>;
waitForElementNotVisible(locator: Locators.Locator, timeout?: number): Q.Promise<boolean>;
waitUntilElementContainsAttribute(locator: Locators.Locator, attributeName: string, attributeValue: string, timeout?: number): Q.Promise<any>;
waitForElementLocated(locator: Locators.Locator, timeout?: number): Q.Promise<any>;
takeScreenshot(filePrefix?: string): Q.Promise<string>;
goHome(timeout?: number): Q.Promise<void>;
getBrowserLogs(level: LogLevel): Q.Promise<string[]>;
applyFeature(name: string, value: string): void;
executeScript<T>(script: string): Q.Promise<T>;
quit(): Q.Promise<any>;
}
export class SplashScreen extends PortalElement {
clickUntrustedExtensionsOkButton(): Q.Promise<void>;
}
export var portal: Portal;
}
declare module "MsPortalFx-Test" {
export = MsPortalTestFx;
}
+67 -1
View File
@@ -71,8 +71,74 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
console.error('Error happened calling Query: ' + err.name + " " + err.message);
}
else {
console.info(requestStoredProcedureWithOutput.parameters.output.value);
console.info(requestStoredProcedureWithOutput.parameters['output'].value);
}
});
}
});
function test_table() {
var table = new sql.Table('#temp_table');
table.create = true;
table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
table.columns.add('type', sql.Int, { nullable: false });
table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });
table.rows.add('name', 42, 3.50);
table.rows.add('name2', 7, 3.14);
}
function test_promise_returns() {
// Methods return a promises if the callback is omitted.
var connection: sql.Connection = new sql.Connection(config);
connection.connect().then(() => { });
connection.close().then(() => { });
var preparedStatment = new sql.PreparedStatement(connection);
preparedStatment.prepare("SELECT @myValue").then(() => { });
preparedStatment.execute({ myValue: 1 }).then((recordSet) => { });
preparedStatment.unprepare().then(() => { });
var transaction = new sql.Transaction(connection);
transaction.begin().then(() => { });
transaction.commit().then(() => { });
transaction.rollback().then(() => { });
var request = new sql.Request();
request.batch('create procedure #temporary as select * from table').then((recordset) => { });
request.bulk(new sql.Table("table_name")).then(() => { });
request.query('SELECT 1').then((recordset) => { });
request.execute('procedure_name').then((recordset) => { });
}
function test_request_constructor() {
// Request can be constructed with a connection, preparedStatment, transaction or no arguments
var connection: sql.Connection = new sql.Connection(config);
var preparedStatment = new sql.PreparedStatement(connection);
var transaction = new sql.Transaction(connection);
var request1 = new sql.Request(connection);
var request2 = new sql.Request(preparedStatment);
var request3 = new sql.Request(transaction);
var request4 = new sql.Request();
}
function test_classes_extend_eventemitter() {
var connection: sql.Connection = new sql.Connection(config);
var transaction = new sql.Transaction();
var request = new sql.Request();
var preparedStatment = new sql.PreparedStatement();
connection.on('connect', () => { });
transaction.on('begin', () => { });
transaction.on('commit', () => { });
transaction.on('rollback', () => { });
request.on('done', () => { });
request.on('error', () => { });
preparedStatment.on('error', () => { })
}
+208 -62
View File
@@ -1,53 +1,131 @@
// Type definitions for mssql
// Type definitions for mssql v2.2.0
// Project: https://www.npmjs.com/package/mssql
// Definitions by: COLSA Corporation <http://www.colsa.com/>
// Definitions by: COLSA Corporation <http://www.colsa.com/>, Ben Farr <https://github.com/jaminfarr>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "mssql" {
import events = require('events');
export var Date: any;
export var DateTime: any;
export var DateTime2: any;
export var DateTimeOffset: any;
export var SmallDateTime: any;
export var Time: any;
export var Char: any;
export var VarChar:any;
export var NChar: any;
export var NVarChar: any;
export var Text:any;
export var NText:any;
export var Xml: any;
export var TinyInt:any;
export var SmallInt:any;
export var Int: any;
export var BigInt:any;
export var Decimal:any;
export var Float:any;
export var Real:any;
export var SmallMoney:any;
export var Money:any;
export var Numeric:any;
export var Bit: any;
export var Binary: any;
export var VarBinary: any;
export var TVP: any;
export var UniqueIdentifier: any;
export var Image: any;
export var UDT: any;
export var Geography: any;
export var Geometry: any;
type sqlTypeWithNoParams = { type: sqlTypeFactoryWithNoParams }
type sqlTypeWithLength = { type: sqlTypeFactoryWithLength, length: number }
type sqlTypeWithScale = { type: sqlTypeFactoryWithScale, scale: number }
type sqlTypeWithPrecisionScale = { type: sqlTypeFactoryWithPrecisionScale, precision: number, scale: number }
type sqlTypeWithTvpType = { type: sqlTypeFactoryWithTvpType, tvpType: any }
export interface options {
type sqlTypeFactoryWithNoParams = () => sqlTypeWithNoParams;
type sqlTypeFactoryWithLength = (length?: number) => sqlTypeWithLength;
type sqlTypeFactoryWithScale = (scale?: number) => sqlTypeWithScale;
type sqlTypeFactoryWithPrecisionScale = (precision?: number, scale?: number) => sqlTypeWithPrecisionScale;
type sqlTypeFactoryWithTvpType = (tvpType: any) => sqlTypeWithTvpType;
export var VarChar: sqlTypeFactoryWithLength;
export var NVarChar: sqlTypeFactoryWithLength;
export var Text: sqlTypeFactoryWithNoParams;
export var Int: sqlTypeFactoryWithNoParams;
export var BigInt: sqlTypeFactoryWithNoParams;
export var TinyInt: sqlTypeFactoryWithNoParams;
export var SmallInt: sqlTypeFactoryWithNoParams;
export var Bit: sqlTypeFactoryWithNoParams;
export var Float: sqlTypeFactoryWithNoParams;
export var Numeric: sqlTypeFactoryWithPrecisionScale;
export var Decimal: sqlTypeFactoryWithPrecisionScale;
export var Real: sqlTypeFactoryWithNoParams;
export var Date: sqlTypeFactoryWithNoParams;
export var DateTime: sqlTypeFactoryWithNoParams;
export var DateTime2: sqlTypeFactoryWithScale;
export var DateTimeOffset: sqlTypeFactoryWithScale;
export var SmallDateTime: sqlTypeFactoryWithNoParams;
export var Time: sqlTypeFactoryWithScale;
export var UniqueIdentifier: sqlTypeFactoryWithNoParams;
export var SmallMoney: sqlTypeFactoryWithNoParams;
export var Money: sqlTypeFactoryWithNoParams;
export var Binary: sqlTypeFactoryWithNoParams;
export var VarBinary: sqlTypeFactoryWithLength;
export var Image: sqlTypeFactoryWithNoParams;
export var Xml: sqlTypeFactoryWithNoParams;
export var Char: sqlTypeFactoryWithLength;
export var NChar: sqlTypeFactoryWithLength;
export var NText: sqlTypeFactoryWithNoParams;
export var TVP: sqlTypeFactoryWithTvpType;
export var UDT: sqlTypeFactoryWithNoParams;
export var Geography: sqlTypeFactoryWithNoParams;
export var Geometry: sqlTypeFactoryWithNoParams;
export var TYPES: {
VarChar: sqlTypeFactoryWithLength;
NVarChar: sqlTypeFactoryWithLength;
Text: sqlTypeFactoryWithNoParams;
Int: sqlTypeFactoryWithNoParams;
BigInt: sqlTypeFactoryWithNoParams;
TinyInt: sqlTypeFactoryWithNoParams;
SmallInt: sqlTypeFactoryWithNoParams;
Bit: sqlTypeFactoryWithNoParams;
Float: sqlTypeFactoryWithNoParams;
Numeric: sqlTypeFactoryWithPrecisionScale;
Decimal: sqlTypeFactoryWithPrecisionScale;
Real: sqlTypeFactoryWithNoParams;
Date: sqlTypeFactoryWithNoParams;
DateTime: sqlTypeFactoryWithNoParams;
DateTime2: sqlTypeFactoryWithScale;
DateTimeOffset: sqlTypeFactoryWithScale;
SmallDateTime: sqlTypeFactoryWithNoParams;
Time: sqlTypeFactoryWithScale;
UniqueIdentifier: sqlTypeFactoryWithNoParams;
SmallMoney: sqlTypeFactoryWithNoParams;
Money: sqlTypeFactoryWithNoParams;
Binary: sqlTypeFactoryWithNoParams;
VarBinary: sqlTypeFactoryWithLength;
Image: sqlTypeFactoryWithNoParams;
Xml: sqlTypeFactoryWithNoParams;
Char: sqlTypeFactoryWithLength;
NChar: sqlTypeFactoryWithLength;
NText: sqlTypeFactoryWithNoParams;
TVP: sqlTypeFactoryWithTvpType;
UDT: sqlTypeFactoryWithNoParams;
Geography: sqlTypeFactoryWithNoParams;
Geometry: sqlTypeFactoryWithNoParams;
};
export var MAX: number;
export var fix: boolean;
export var Promise: any;
interface IMap extends Array<{js: any, sql: any }> {
register(jstype: any, sql: any): void;
}
export var map: IMap;
export var DRIVERS: string[];
type recordSet = any;
type IIsolationLevel = number;
export var ISOLATION_LEVEL: {
READ_UNCOMMITTED: IIsolationLevel
READ_COMMITTED: IIsolationLevel
REPEATABLE_READ: IIsolationLevel
SERIALIZABLE: IIsolationLevel
SNAPSHOT: IIsolationLevel
}
export interface IOptions {
encrypt: boolean;
}
export interface pool {
export interface IPool {
min: number;
max: number;
idleTimeoutMillis: number;
}
export var pool: IPool;
export interface config {
driver?: string;
user?: string;
@@ -59,18 +137,26 @@ declare module "mssql" {
connectionTimeout?: number;
requestTimeout?: number;
stream?: boolean;
options?: options;
pool?: pool;
options?: IOptions;
pool?: IPool;
}
export class Connection {
export class Connection extends events.EventEmitter {
public connected: boolean;
public connecting: boolean;
public driver: string;
public constructor(config: config, callback?: (err?: any) => void);
public connect(): Promise<void>;
public connect(callback: (err: any) => void): void;
public close(): Promise<void>;
public close(callback: (err: any) => void): void;
}
public connect(callback?: (err?: any) => void): void;
public close(): void;
export class ConnectionError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
class columns {
@@ -78,7 +164,7 @@ declare module "mssql" {
}
class rows {
public add(row: any): void;
public add(...row: any[]): void;
}
export class Table {
@@ -86,37 +172,97 @@ declare module "mssql" {
public columns: columns;
public rows: rows;
public constructor(tableName: string);
}
export class Request {
interface IRequestParameters {
[name: string]: {
name: string;
type: any;
io: number;
value: any;
length: number;
scale: number;
precision: number;
tvpType: any;
}
}
export class Request extends events.EventEmitter {
public connection: Connection;
public transaction: Transaction;
public pstatement: PreparedStatement;
public parameters: IRequestParameters;
public verbose: boolean;
public multiple: boolean;
public canceled: boolean;
public stream: any;
public constructor(connection?: Connection);
public execute(procedure: string, callback?: (err?: any, recordsets?: any, returnValue?: any) => void): void;
public constructor(transaction: Transaction);
public constructor(preparedStatement: PreparedStatement);
public execute(procedure: string): Promise<recordSet>;
public execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
public input(name: string, value: any): void;
public input(name: string, type: any, value: any): void;
public output(name: string, type: any, value?: any): void;
public pipe(stream: any): void;
public query(command: string, callback?: (err?: any, recordset?: any) => void): void;
public batch(batch: string, callback?: (err?: any, recordset?: any) => void): void;
public bulk(table: Table, callback?: (err?: any, rowCount?: any) => void): void;
public pipe(stream: NodeJS.WritableStream): void;
public query(command: string): Promise<void>;
public query(command: string, callback: (err?: any, recordset?: any) => void): void;
public batch(batch: string): Promise<recordSet>;
public batch(batch: string, callback: (err?: any, recordset?: any) => void): void;
public bulk(table: Table): Promise<void>;
public bulk(table: Table, callback: (err: any, rowCount: any) => void): void;
public cancel(): void;
public parameters: any;
}
export class Transaction {
export class RequestError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
export class Transaction extends events.EventEmitter {
public connection: Connection;
public isolationLevel: IIsolationLevel;
public constructor(connection?: Connection);
public begin(isolationLevel?: any, callback?: (err?: any) => void): void;
public begin(callback?: (err?: any) => void): void;
public commit(callback?: (err?: any) => void): void;
public rollback(callback?: (err?: any) => void): void;
public begin(isolationLevel?: IIsolationLevel): Promise<void>;
public begin(isolationLevel?: IIsolationLevel, callback?: (err?: any) => void): void;
public commit(): Promise<void>;
public commit(callback: (err?: any) => void): void;
public rollback(): Promise<void>;
public rollback(callback: (err?: any) => void): void;
}
export class PreparedStatement {
export class TransactionError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
export class PreparedStatement extends events.EventEmitter {
public connection: Connection;
public transaction: Transaction;
public prepared: boolean;
public statement: string;
public parameters: IRequestParameters;
public multiple: boolean;
public stream: any;
public constructor(connection?: Connection);
public input(name: string, type: any): void;
public output(name: string, type: any): void;
public prepare(statement: string, callback?: (err?: any) => void): void;
public execute(values: any, callback?: (err?: any) => void): void;
public unprepare(callback?: (err?: any) => void): void;
public prepare(statement?: string): Promise<void>;
public prepare(statement?: string, callback?: (err?: any) => void): void;
public execute(values: Object): Promise<recordSet>;
public execute(values: Object, callback: (err: any, recordSet: recordSet) => void): void;
public unprepare(): Promise<void>;
public unprepare(callback: (err?: any) => void): void;
}
export class PreparedStatementError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
}
+16
View File
@@ -0,0 +1,16 @@
///<reference path="netmask.d.ts" />
import netmask = require('netmask');
var address: string = '127.0.0.1';
var nm = new netmask.Netmask(address, '255.255.255.0');
var nm2 = new netmask.Netmask('127.0.0.1/255.255.255.0');
if (nm.contains('127.0.0.123')) {}
nm.forEach((ip: string): void => console.log(ip));
var adjacent: netmask.Netmask = nm.next();
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for Netmask 1.0.5
// Project: https://github.com/rs/node-netmask
// Definitions by: Matt Frantz <https://github.com/mhfrantz/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// netmask.d.ts
declare module 'netmask' {
export function long2ip(long: number): string;
export function ip2long(ip: string): number;
export class Netmask {
maskLong: number;
bitmask: number;
netLong: number;
// The number of IP address in the block (eg.: 254)
size: number;
// The address of the network block as a string (eg.: 216.240.32.0)
base: string;
// The netmask as a string (eg.: 255.255.255.0)
mask: string;
// The host mask, the opposite of the netmask (eg.: 0.0.0.255)
hostmask: string;
// The first usable address of the block
first: string;
// The last usable address of the block
last: string;
// The block's broadcast address: the last address of the block (eg.: 192.168.1.255)
broadcast: string;
constructor (netmask: string);
constructor (net: string, mask: string);
// Returns true if the given ip or netmask is contained in the block
contains(ip: string | Netmask | number): boolean;
// Returns the Netmask object for the block which follow this one
next(count?: number): Netmask;
// Evaluate a function on each IP address
forEach(fn: (ip: string, long: number, index: number) => void): void;
// Returns the complete netmask formatted as `base/bitmask`
toString(): string;
}
}
+4
View File
@@ -0,0 +1,4 @@
/// <reference path="ng-flow.d.ts" />
var flowFactory: ng.flow.IFlowFactory;
flowFactory.create(<flowjs.IFlowOptions> {});
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for ng-flow
// Project: https://github.com/flowjs/ng-flow
// Definitions by: Ryan McNamara <https://github.com/ryan10132>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../flowjs/flowjs.d.ts" />
declare module ng.flow {
interface IFlowFactory {
create(options?: flowjs.IFlowOptions): flowjs.IFlow;
}
}
+98
View File
@@ -0,0 +1,98 @@
/// <reference path="./node-cache.d.ts" />
import NodeCache = require('node-cache');
import Options = NodeCacheTypes.Options;
import Stats = NodeCacheTypes.Stats;
import Callback = NodeCacheTypes.Callback;
interface TypeSample {
a: number;
b: string;
c: boolean;
}
{
let options: Options;
let cache: NodeCacheTypes.NodeCache;
cache = new NodeCache();
cache = new NodeCache(options);
}
{
let cache: NodeCache;
let key: string;
let cb: Callback<TypeSample>;
let result: TypeSample;
result = cache.get<TypeSample>(key);
result = cache.get<TypeSample>(key, cb);
}
{
let cache: NodeCache;
let keys: string[];
let cb: Callback<{[key: string]: TypeSample}>;
let result: {[key: string]: TypeSample};
result = cache.mget<TypeSample>(keys);
result = cache.mget<TypeSample>(keys, cb);
}
{
let cache: NodeCache;
let key: string;
let value: TypeSample;
let ttl: number|string;
let cb: Callback<boolean>;
let result: boolean;
result = cache.set<TypeSample>(key, value);
result = cache.set<TypeSample>(key, value, ttl);
result = cache.set<TypeSample>(key, value, ttl, cb);
result = cache.set<TypeSample>(key, value, cb);
}
{
let cache: NodeCache;
let keys: string|string[];
let cb: Callback<number>;
let result: number;
result = cache.del(keys);
result = cache.del(keys, cb);
}
{
let cache: NodeCache;
let key: string;
let ttl: number;
let cb: Callback<boolean>;
let result: boolean;
result = cache.ttl(key);
result = cache.ttl(key, ttl);
result = cache.ttl(key, ttl, cb);
result = cache.ttl(key, cb);
}
{
let cache: NodeCache;
let cb: Callback<string[]>;
let result: string[];
result = cache.keys();
result = cache.keys(cb);
}
{
let cache: NodeCache;
let result: Stats;
result = cache.getStats();
}
{
let cache: NodeCache;
let result: void;
result = cache.flushAll();
}
{
let cache: NodeCache;
let result: void;
result = cache.close();
}
+263
View File
@@ -0,0 +1,263 @@
// Type definitions for node-cache v3.0.0
// Project: https://github.com/tcs-de/nodecache
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module NodeCacheTypes {
interface NodeCache {
/** container for cached data */
data: Data;
/** module options */
options: Options;
/** statistics container */
stats: Stats;
/**
* get a cached key and change the stats
*
* @param key cache key or an array of keys
* @param cb Callback function
*/
get<T>(
key: string,
cb?: Callback<T>
): T;
/**
* get multiple cached keys at once and change the stats
*
* @param keys an array of keys
* @param cb Callback function
*/
mget<T>(
keys: string[],
cb?: Callback<{[key: string]: T}>
): {[key: string]: T};
/**
* set a cached key and change the stats
*
* @param key cache key
* @param value A element to cache. If the option `option.forceString` is `true` the module trys to translate
* it to a serialized JSON
* @param ttl The time to live in seconds.
* @param cb Callback function
*/
set<T>(
key: string,
value: T,
ttl: number|string,
cb?: Callback<boolean>
): boolean;
set<T>(
key: string,
value: T,
cb?: Callback<boolean>
): boolean;
/**
* remove keys
* @param keys cache key to delete or a array of cache keys
* @param cb Callback function
* @returns Number of deleted keys
*/
del(
keys: string|string[],
cb?: Callback<number>
): number;
/**
* reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()`
*/
ttl(
key: string,
ttl: number,
cb?: Callback<boolean>
): boolean;
ttl(
key: string,
cb?: Callback<boolean>,
ttl?: number
): boolean;
/**
* list all keys within this cache
* @param cb Callback function
* @returns An array of all keys
*/
keys(cb?: Callback<string[]>): string[];
/**
* get the stats
*
* @returns Stats data
*/
getStats(): Stats;
/**
* flush the hole data and reset the stats
*/
flushAll(): void;
/**
* This will clear the interval timeout which is set on checkperiod option.
*/
close(): void;
}
interface Data {
[key: string]: WrappedValue<any>;
}
interface Options {
forceString: boolean;
objectValueSize: number;
arrayValueSize: number;
stdTTL: number;
checkperiod: number;
useClones: boolean;
}
interface Stats {
hits: number;
misses: number;
keys: number;
ksize: number;
vsize: number;
}
interface WrappedValue<T> {
// ttl
t: number;
// value
v: T;
}
interface Callback<T> {
(err: any, data: T): void;
}
}
declare module "node-cache" {
import events = require("events");
import Data = NodeCacheTypes.Data;
import Options = NodeCacheTypes.Options;
import Stats = NodeCacheTypes.Stats;
import Callback = NodeCacheTypes.Callback;
class NodeCache extends events.EventEmitter implements NodeCacheTypes.NodeCache {
/** container for cached data */
data: Data;
/** module options */
options: Options;
/** statistics container */
stats: Stats;
constructor(options?: Options);
/**
* get a cached key and change the stats
*
* @param key cache key or an array of keys
* @param cb Callback function
*/
get<T>(
key: string,
cb?: Callback<T>
): T;
/**
* get multiple cached keys at once and change the stats
*
* @param keys an array of keys
* @param cb Callback function
*/
mget<T>(
keys: string[],
cb?: Callback<{[key: string]: T}>
): {[key: string]: T};
/**
* set a cached key and change the stats
*
* @param key cache key
* @param value A element to cache. If the option `option.forceString` is `true` the module trys to translate
* it to a serialized JSON
* @param ttl The time to live in seconds.
* @param cb Callback function
*/
set<T>(
key: string,
value: T,
ttl: number|string,
cb?: Callback<boolean>
): boolean;
set<T>(
key: string,
value: T,
cb?: Callback<boolean>
): boolean;
/**
* remove keys
* @param keys cache key to delete or a array of cache keys
* @param cb Callback function
* @returns Number of deleted keys
*/
del(
keys: string|string[],
cb?: Callback<number>
): number;
/**
* reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()`
*/
ttl(
key: string,
ttl: number,
cb?: Callback<boolean>
): boolean;
ttl(
key: string,
cb?: Callback<boolean>,
ttl?: number
): boolean;
/**
* list all keys within this cache
* @param cb Callback function
* @returns An array of all keys
*/
keys(cb?: Callback<string[]>): string[];
/**
* get the stats
*
* @returns Stats data
*/
getStats(): Stats;
/**
* flush the hole data and reset the stats
*/
flushAll(): void;
/**
* This will clear the interval timeout which is set on checkperiod option.
*/
close(): void;
}
export = NodeCache;
}
+2
View File
@@ -34,6 +34,8 @@ assert.doesNotThrow(() => {
fs.writeFile("thebible.txt",
"Do unto others as you would have them do unto you.",
assert.ifError);
fs.write(1234, "test");
fs.writeFile("Harry Potter",
"\"You be wizzing, Harry,\" jived Dumbledore.",
+27 -29
View File
@@ -9,6 +9,11 @@
* *
************************************************/
interface Error {
stack?: string;
}
// compat for TypeScript 1.5.3
// if you use with --target es3 or --target es5 and use below definitions,
// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3.
@@ -1062,6 +1067,7 @@ declare module "fs" {
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
}
interface FSWatcher extends events.EventEmitter {
@@ -1214,6 +1220,9 @@ declare module "fs" {
export function fsyncSync(fd: number): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
@@ -1671,14 +1680,13 @@ declare module "stream" {
readable: boolean;
constructor(opts?: ReadableOptions);
_read(size: number): void;
read(size?: number): string|Buffer;
read(size?: number): any;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
unshift(chunk: any): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
}
@@ -1691,15 +1699,12 @@ declare module "stream" {
export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
writable: boolean;
constructor(opts?: WritableOptions);
_write(data: Buffer, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
_write(chunk: any, encoding: string, callback: Function): void;
write(chunk: any, cb?: Function): boolean;
write(chunk: any, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
end(chunk: any, cb?: Function): void;
end(chunk: any, encoding?: string, cb?: Function): void;
}
export interface DuplexOptions extends ReadableOptions, WritableOptions {
@@ -1710,15 +1715,12 @@ declare module "stream" {
export class Duplex extends Readable implements NodeJS.ReadWriteStream {
writable: boolean;
constructor(opts?: DuplexOptions);
_write(data: Buffer, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
_write(chunk: any, encoding: string, callback: Function): void;
write(chunk: any, cb?: Function): boolean;
write(chunk: any, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
end(chunk: any, cb?: Function): void;
end(chunk: any, encoding?: string, cb?: Function): void;
}
export interface TransformOptions extends ReadableOptions, WritableOptions {}
@@ -1728,8 +1730,7 @@ declare module "stream" {
readable: boolean;
writable: boolean;
constructor(opts?: TransformOptions);
_transform(chunk: Buffer, encoding: string, callback: Function): void;
_transform(chunk: string, encoding: string, callback: Function): void;
_transform(chunk: any, encoding: string, callback: Function): void;
_flush(callback: Function): void;
read(size?: number): any;
setEncoding(encoding: string): void;
@@ -1737,17 +1738,14 @@ declare module "stream" {
resume(): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
unshift(chunk: any): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
write(chunk: any, cb?: Function): boolean;
write(chunk: any, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
end(chunk: any, cb?: Function): void;
end(chunk: any, encoding?: string, cb?: Function): void;
}
export class PassThrough extends Transform {}
+24 -82
View File
@@ -3,14 +3,13 @@
"version": "0.0.1",
"dependencies": {
"definition-tester": {
"version": "0.2.0",
"from": "definition-tester@0.2.0",
"resolved": "https://registry.npmjs.org/definition-tester/-/definition-tester-0.2.0.tgz",
"version": "0.3.0",
"from": "definition-tester@0.3.0",
"dependencies": {
"bluebird": {
"version": "2.9.34",
"from": "bluebird@>=2.5.3 <3.0.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.9.34.tgz"
"version": "2.10.1",
"from": "bluebird@>=2.10.1 <3.0.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.1.tgz"
},
"definition-header": {
"version": "0.1.0",
@@ -23,9 +22,9 @@
"resolved": "https://registry.npmjs.org/joi/-/joi-4.9.0.tgz",
"dependencies": {
"hoek": {
"version": "2.14.0",
"version": "2.16.3",
"from": "hoek@>=2.2.0 <3.0.0",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.14.0.tgz"
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz"
},
"topo": {
"version": "1.0.3",
@@ -33,9 +32,9 @@
"resolved": "https://registry.npmjs.org/topo/-/topo-1.0.3.tgz"
},
"isemail": {
"version": "1.1.1",
"version": "1.2.0",
"from": "isemail@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/isemail/-/isemail-1.1.1.tgz"
"resolved": "https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz"
},
"moment": {
"version": "2.10.6",
@@ -76,71 +75,9 @@
}
},
"findup-sync": {
"version": "0.2.1",
"from": "findup-sync@>=0.2.1 <0.3.0",
"resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.2.1.tgz",
"dependencies": {
"glob": {
"version": "4.3.5",
"from": "glob@>=4.3.0 <4.4.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-4.3.5.tgz",
"dependencies": {
"inflight": {
"version": "1.0.4",
"from": "inflight@>=1.0.4 <2.0.0",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz",
"dependencies": {
"wrappy": {
"version": "1.0.1",
"from": "wrappy@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz"
}
}
},
"inherits": {
"version": "2.0.1",
"from": "inherits@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
},
"minimatch": {
"version": "2.0.10",
"from": "minimatch@>=2.0.1 <3.0.0",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz",
"dependencies": {
"brace-expansion": {
"version": "1.1.0",
"from": "brace-expansion@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.0.tgz",
"dependencies": {
"balanced-match": {
"version": "0.2.0",
"from": "balanced-match@>=0.2.0 <0.3.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz"
},
"concat-map": {
"version": "0.0.1",
"from": "concat-map@0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
}
}
}
}
},
"once": {
"version": "1.3.2",
"from": "once@>=1.3.0 <2.0.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.3.2.tgz",
"dependencies": {
"wrappy": {
"version": "1.0.1",
"from": "wrappy@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz"
}
}
}
}
}
}
"version": "0.3.0",
"from": "findup-sync@>=0.3.0 <0.4.0",
"resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz"
},
"git-wrapper": {
"version": "0.1.1",
@@ -148,9 +85,9 @@
"resolved": "https://registry.npmjs.org/git-wrapper/-/git-wrapper-0.1.1.tgz"
},
"glob": {
"version": "4.5.3",
"from": "glob@>=4.3.2 <5.0.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz",
"version": "5.0.14",
"from": "glob@>=5.0.14 <6.0.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-5.0.14.tgz",
"dependencies": {
"inflight": {
"version": "1.0.4",
@@ -204,12 +141,17 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz"
}
}
},
"path-is-absolute": {
"version": "1.0.0",
"from": "path-is-absolute@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz"
}
}
},
"lazy.js": {
"version": "0.4.2",
"from": "lazy.js@>=0.4.0 <0.5.0",
"from": "lazy.js@>=0.4.2 <0.5.0",
"resolved": "https://registry.npmjs.org/lazy.js/-/lazy.js-0.4.2.tgz"
},
"manticore": {
@@ -305,9 +247,9 @@
}
},
"typescript": {
"version": "1.6.0-beta",
"from": "typescript@1.6.0-beta",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-1.6.0-beta.tgz"
"version": "1.6.2",
"from": "typescript@1.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-1.6.2.tgz"
}
}
}

Some files were not shown because too many files have changed in this diff Show More