Merge remote-tracking branch 'master/master'

This commit is contained in:
Bogdan I. Bursuc
2015-06-09 08:03:19 +03:00
44 changed files with 15166 additions and 1302 deletions
+2 -2
View File
@@ -150,8 +150,8 @@ declare module angular.material {
A400?: string;
A700?: string;
contrastDefaultColor?: string;
contrastDarkColors?: string;
contrastStrongLightColors?: string;
contrastDarkColors?: string|string[];
contrastLightColors?: string|string[];
}
interface MDThemeHues {
+10 -1
View File
@@ -64,7 +64,16 @@ myApp.config((
controller: function ($scope: MyAppScope) {
$scope.things = ["A", "Set", "Of", "Things"];
}
}).state('index', {
})
.state('list', {
parent: 'state3',
url: "/list",
templateUrl: "partials/state3.list.html",
controller: function ($scope: MyAppScope) {
$scope.things = ["A", "Set", "Of", "Things"];
}
})
.state('index', {
url: "",
views: {
"viewA": { template: "index.viewA" },
+7
View File
@@ -30,6 +30,13 @@ declare module angular.ui {
* Function (injectable), returns the actual controller function or string.
*/
controllerProvider?: Function;
/**
* Specifies the parent state of this state
*/
parent?: string | IState
resolve?: {};
/**
* A url with optional parameters. When a state is navigated or transitioned to, the $stateParams service will be populated with any parameters that were passed.
+12 -3
View File
@@ -2,7 +2,6 @@
// Use Typescript 1.4 style imports
import ng = require("angular2/angular2");
import di = require("angular2/di");
class Service {
@@ -17,11 +16,21 @@ class Cmp {
Cmp.annotations = [
ng.Component({
selector: 'cmp',
injectables: [Service, di.bind(Service2).toValue(null)]
injectables: [Service, ng.bind(Service2).toValue(null)]
}),
ng.View({
template: '{{greeting}} world!',
directives: [ng.For, ng.If]
directives: [ng.NgFor, ng.NgIf]
}),
ng.Directive({
selector: '[tooltip]',
properties: [
'text: tooltip'
],
hostListeners: {
'onmouseenter': 'onMouseEnter()',
'onmouseleave': 'onMouseLeave()'
}
})
];
+4411 -408
View File
File diff suppressed because it is too large Load Diff
+10
View File
@@ -249,6 +249,16 @@ declare module angular {
isString(value: any): boolean;
isUndefined(value: any): boolean;
lowercase(str: string): string;
/**
* Deeply extends the destination object dst by copying own enumerable properties from the src object(s) to dst. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target: var object = angular.merge({}, object1, object2).
*
* Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy.
*
* @param dst Destination object.
* @param src Source object(s).
*/
merge(dst: any, ...src: any[]): any;
/**
* The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
+1 -1
View File
@@ -52,7 +52,7 @@ declare module Backbone {
type PageableGetPageOptions = CollectionFetchOptions|Silenceable;
class PageableCollection<TModel extends Model> extends Collection<Model>{
class PageableCollection<TModel extends Model> extends Collection<TModel>{
fullCollection: Collection<TModel>;
mode: string;
Vendored
+20 -18
View File
@@ -13,7 +13,7 @@ declare module d3 {
* Find the first element that matches the given selector string.
*/
export function select(selector: string): Selection<any>;
/**
* Create a selection from the given node reference.
*/
@@ -86,7 +86,7 @@ declare module d3 {
attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Update<Datum>;
/**
* Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match.
* Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match.
*
* @param name The class list to query.
*/
@@ -476,7 +476,7 @@ declare module d3 {
attr(obj: { [key: string]: Primitive | ((datum: Datum, index: number) => Primitive) }): Selection<Datum>;
/**
* Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match.
* Returns true if the first node in this selection has the given class list. If multiple classes are specified (i.e., "foo bar"), then returns true only if all classes match.
*
* @param name The class list to query.
*/
@@ -928,20 +928,20 @@ declare module d3 {
*/
export function mouse(container: EventTarget): [number, number];
/**
/**
* Given a container element and a touch identifier, determine the x and y coordinates of the touch.
* @param container the container element (e.g., an SVG <svg> element)
* @param identifier the given touch identifier
*/
export function touch(container: EventTarget, identifer: number): [number, number];
/**
/**
* Given a container element, a list of touches, and a touch identifier, determine the x and y coordinates of the touch.
* @param container the container element (e.g., an SVG <svg> element)
* @param identifier the given touch identifier
*/
export function touch(container: EventTarget, touches: TouchList, identifer: number): [number, number];
/**
* Given a container element and an optional list of touches, return the position of every touch relative to the container.
* @param container the container element
@@ -1024,7 +1024,7 @@ declare module d3 {
* Return the min and max simultaneously.
*/
export function extent(array: number[]): [number, number];
/**
* Return the min and max simultaneously.
*/
@@ -1172,7 +1172,7 @@ declare module d3 {
* Calls the function for each key and value pair in the map. The 'this' context is the map itself.
*/
forEach(func: (key: string, value: T) => any): void;
/**
* Is this map empty?
*/
@@ -1495,6 +1495,8 @@ declare module d3 {
clamp(): boolean;
clamp(clamp: boolean): Linear<Range, Output>;
nice(count?: number): Linear<Range, Output>;
ticks(count?: number): number[];
tickFormat(count?: number, format?: string): (n: number) => string;
@@ -1637,7 +1639,7 @@ declare module d3 {
export function category20b<Domain extends { toString(): string }>(): Ordinal<Domain, string>;
export function category20c(): Ordinal<string,string>;
export function category20c<Domain extends { toString(): string }>(): Ordinal<Domain, string>;
interface Ordinal<Domain extends { toString(): string }, Range> {
(x: Domain): Range;
@@ -1728,7 +1730,7 @@ declare module d3 {
range(start: Date, stop: Date, step?: number): Date[];
offset(date: Date, step: Date): Date;
offset(date: Date, step: number): Date;
utc: {
(d: Date): Date;
@@ -1741,7 +1743,7 @@ declare module d3 {
range(start: Date, stop: Date, step?: number): Date[];
offset(date: Date, step: Date): Date;
offset(date: Date, step: number): Date;
}
}
@@ -1768,7 +1770,7 @@ declare module d3 {
export function wednesdayOfYear(d: Date): number;
export function fridayOfYear(d: Date): number;
export function saturdayOfYear(d: Date): number;
export function format(specifier: string): Format;
export module format {
@@ -1935,7 +1937,7 @@ declare module d3 {
minorStep(): [number, number];
minorStep(step: [number, number]): Graticule;
precision(): number;
precision(precision: number): Graticule;
}
@@ -2281,7 +2283,7 @@ declare module d3 {
tension(tension: number): Area<T>;
defined(): (d: T, i: number) => boolean;
defined(): (d: T, i: number) => boolean;
defined(defined: (d: T, i: number) => boolean): Area<T>;
}
module area {
@@ -2332,7 +2334,7 @@ declare module d3 {
tension(tension: number): Radial<T>;
defined(): (d: T, i: number) => boolean;
defined(): (d: T, i: number) => boolean;
defined(defined: (d: T, i: number) => boolean): Radial<T>;
}
}
@@ -2388,7 +2390,7 @@ declare module d3 {
export function symbol<T>(): Symbol<T>;
interface Symbol<T> {
(d: T, i: number): string;
(d: T, i?: number): string;
type(): (d: T, i: number) => string;
type(type: string): Symbol<T>;
@@ -2647,7 +2649,7 @@ declare module d3 {
parseRows<T>(string: string, accessor: (row: string[], index: number) => T): T[];
format(rows: Object[]): string;
formatRows(rows: string[][]): string;
}
@@ -3284,4 +3286,4 @@ interface TouchList { }
declare module 'd3' {
export = d3;
}
}
File diff suppressed because it is too large Load Diff
+1302 -569
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -150,6 +150,10 @@ declare module ExpressValidator {
* Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats
*/
isCreditCard(): Validator;
/**
* Check an input only when the input exists
*/
optional(): Validator;
}
interface Sanitizer {
+4
View File
@@ -58,9 +58,13 @@ fs.createFile(file, errorCallback);
fs.createFileSync(file);
fs.mkdirs(dir, errorCallback);
fs.mkdirs(dir, {}, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirsSync(dir, {});
fs.mkdirp(dir, errorCallback);
fs.mkdirp(dir, {}, errorCallback);
fs.mkdirpSync(dir);
fs.mkdirpSync(dir, {});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
+9 -2
View File
@@ -52,8 +52,10 @@ declare module "fs-extra" {
export function mkdirs(dir: string, callback?: (err: Error) => void): void;
export function mkdirp(dir: string, callback?: (err: Error) => void): void;
export function mkdirsSync(dir: string): void;
export function mkdirpSync(dir: string): void;
export function mkdirs(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void;
export function mkdirp(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void;
export function mkdirsSync(dir: string, options?: MkdirOptions): void;
export function mkdirpSync(dir: string, options?: MkdirOptions): void;
export function outputFile(file: string, data: any, callback?: (err: Error) => void): void;
export function outputFileSync(file: string, data: any): void;
@@ -171,6 +173,11 @@ declare module "fs-extra" {
flag?: string;
}
export interface MkdirOptions {
fs?: any;
mode?: number;
}
export interface ReadStreamOptions {
flags?: string;
encoding?: string;
+12 -1
View File
@@ -104,4 +104,15 @@ var removePropertyEvent: google.maps.Data.RemovePropertyEvent = {
feature: feature,
name: "test",
oldValue: {}
};
};
/***** Overlays *****/
var icon: google.maps.Icon = {
anchor: new google.maps.Point(16, 16),
origin: new google.maps.Point(0, 0),
scaledSize: new google.maps.Size(32, 32),
size: new google.maps.Size(32, 32),
url: "dummy"
}
+202 -10
View File
@@ -397,23 +397,86 @@ declare module google.maps {
}
export interface MarkerOptions {
/** Which animation to play when marker is added to a map. */
animation?: Animation;
/**
* If true, the marker receives mouse and touch events.
* @default true
*/
clickable?: boolean;
/** Mouse cursor to show on hover. */
cursor?: string;
/**
* If true, the marker can be dragged.
* @default false
*/
draggable?: boolean;
flat?: boolean;
/**
* Icon for the foreground.
* If a string is provided, it is treated as though it were an Icon with the string as url.
* @type {(string|Icon|Symbol)}
*/
icon?: any;
/**
* Map on which to display Marker.
* @type {(Map|StreetViewPanorama)}
*/
map?: any;
/**
* Optimization renders many markers as a single static element.
* Optimized rendering is enabled by default.
* Disable optimized rendering for animated GIFs or PNGs, or when each marker must be rendered
* as a separate DOM element (advanced usage only).
*/
optimized?: boolean;
/**
* Marker position. Required.
*/
position?: LatLng;
raiseOnDrag?: boolean;
shadow?: any;
/** Image map region definition used for drag/click. */
shape?: MarkerShape;
/** Rollover text. */
title?: string;
/** If true, the marker is visible. */
visible?: boolean;
/**
* All markers are displayed on the map in order of their zIndex,
* with higher values displaying in front of markers with lower values.
* By default, markers are displayed according to their vertical position on screen,
* with lower markers appearing in front of markers further up the screen.
*/
zIndex?: number;
}
export interface Icon {
/**
* The position at which to anchor an image in correspondence to the location of the marker on the map.
* By default, the anchor is located along the center point of the bottom of the image.
*/
anchor?: Point;
/**
* The position of the image within a sprite, if any.
* By default, the origin is located at the top left corner of the image (0, 0).
*/
origin?: Point;
/**
* The size of the entire image after scaling, if any.
* Use this property to stretch/ shrink an image or a sprite.
*/
scaledSize?: Size;
/**
* The display size of the sprite or image.
* When using sprites, you must specify the sprite size.
* If the size is not provided, it will be set when the image loads.
*/
size?: Size;
/** The URL of the image or sprite sheet. */
url?: string;
}
export class MarkerImage {
constructor (url: string, size?: Size, origin?: Point, anchor?: Point, scaledSize?: Size);
anchor: Point;
@@ -429,22 +492,68 @@ declare module google.maps {
}
export interface Symbol {
/**
* The position of the symbol relative to the marker or polyline.
* The coordinates of the symbol's path are translated left and up by the anchor's x and y coordinates respectively.
* By default, a symbol is anchored at (0, 0).
* The position is expressed in the same coordinate system as the symbol's path.
*/
anchor?: Point;
/**
* The symbol's fill color.
* All CSS3 colors are supported except for extended named colors. For symbol markers, this defaults to 'black'.
* For symbols on polylines, this defaults to the stroke color of the corresponding polyline.
*/
fillColor?: string;
/**
* The symbol's fill opacity.
* @default 0
*/
fillOpacity?: number;
/**
* The symbol's path, which is a built-in symbol path, or a custom path expressed using SVG path notation. Required.
* @type {(SymbolPath|string)}
*/
path?: any;
/**
* The angle by which to rotate the symbol, expressed clockwise in degrees.
* Defaults to 0.
* A symbol in an IconSequence where fixedRotation is false is rotated relative to the angle of the edge on which it lies.
*/
rotation?: number;
/**
* The amount by which the symbol is scaled in size.
* For symbol markers, this defaults to 1; after scaling, the symbol may be of any size.
* For symbols on a polyline, this defaults to the stroke weight of the polyline;
* after scaling, the symbol must lie inside a square 22 pixels in size centered at the symbol's anchor.
*/
scale?: number;
/**
* The symbol's stroke color. All CSS3 colors are supported except for extended named colors.
* For symbol markers, this defaults to 'black'.
* For symbols on a polyline, this defaults to the stroke color of the polyline.
*/
strokeColor?: string;
/**
* The symbol's stroke opacity. For symbol markers, this defaults to 1.
* For symbols on a polyline, this defaults to the stroke opacity of the polyline.
*/
strokeOpacity?: number;
/** The symbol's stroke weight. Defaults to the scale of the symbol.v*/
strokeWeight?: number;
}
/** Built-in symbol paths. */
export enum SymbolPath {
/** A backward-pointing closed arrow. */
BACKWARD_CLOSED_ARROW,
/** A backward-pointing open arrow. */
BACKWARD_OPEN_ARROW,
/** A circle. */
CIRCLE,
/** A forward-pointing closed arrow. */
FORWARD_CLOSED_ARROW,
/** A forward-pointing open arrow. */
FORWARD_OPEN_ARROW
}
@@ -453,13 +562,33 @@ declare module google.maps {
DROP
}
/**
* An overlay that looks like a bubble and is often connected to a marker.
* This class extends MVCObject.
*/
export class InfoWindow extends MVCObject {
constructor (opts?: InfoWindowOptions);
/**
* Creates an info window with the given options.
* An InfoWindow can be placed on a map at a particular position or above a marker,
* depending on what is specified in the options.
* Unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened.
* After constructing an InfoWindow, you must call open to display it on the map.
* The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect.
*/
constructor(opts?: InfoWindowOptions);
/** Closes this InfoWindow by removing it from the DOM structure. */
close(): void;
getContent(): any; // string or Element
getPosition(): LatLng;
getZIndex(): number;
open(map?: Map, anchor?: MVCObject): void;
/**
* Opens this InfoWindow on the given map. Optionally, an InfoWindow can be associated with an anchor.
* In the core API, the only anchor is the Marker class.
* However, an anchor can be any MVCObject that exposes a LatLng position property and optionally
* a Point anchorPoint property for calculating the pixelOffset (see InfoWindowOptions).
* The anchorPoint is the offset from the anchor's position to the tip of the InfoWindow.
*/
open(map?: StreetViewPanorama, anchor?: MVCObject): void;
setContent(content: Node): void;
setContent(content: string): void;
@@ -469,11 +598,40 @@ declare module google.maps {
}
export interface InfoWindowOptions {
/**
* Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML.
* The InfoWindow will be sized according to the content.
* To set an explicit size for the content, set content to be a HTML element with that size.
* @type {(string|Node)}
*/
content?: any;
/**
* Disable auto-pan on open. By default, the info window will pan the map so that it is fully visible when it opens.
*/
disableAutoPan?: boolean;
/**
* Maximum width of the infowindow, regardless of content's width.
* This value is only considered if it is set before a call to open.
* To change the maximum width when changing content, call close, setOptions, and then open.
*/
maxWidth?: number;
/**
* The offset, in pixels, of the tip of the info window from the point on the map
* at whose geographical coordinates the info window is anchored.
* If an InfoWindow is opened with an anchor, the pixelOffset will be calculated from the anchor's anchorPoint property.
*/
pixelOffset?: Size;
/**
* The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead.
*/
position?: LatLng;
/**
* All InfoWindows are displayed on the map in order of their zIndex,
* with higher values displaying in front of InfoWindows with lower values.
* By default, InfoWindows are displayed according to their latitude,
* with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes.
* InfoWindows are always displayed in front of markers.
*/
zIndex?: number;
}
@@ -1356,15 +1514,43 @@ declare module google.maps {
latLng: LatLng;
}
/***** Base *****/
export class LatLng {
constructor (lat: number, lng: number, noWrap?: boolean);
equals(other: LatLng): boolean;
lat(): number;
lng(): number;
toString(): string;
toUrlValue(precision?: number): string;
/* **** Base **** */
/**
* A LatLng is a point in geographical coordinates: latitude and longitude.
*
* * Latitude ranges between -90 and 90 degrees, inclusive.
* Values above or below this range will be clamped to the range [-90, 90].
* This means that if the value specified is less than -90, it will be set to -90.
* And if the value is greater than 90, it will be set to 90.
* * Longitude ranges between -180 and 180 degrees, inclusive.
* Values above or below this range will be wrapped so that they fall within the range.
* For example, a value of -190 will be converted to 170. A value of 190 will be converted to -170.
* This reflects the fact that longitudes wrap around the globe.
*
* Although the default map projection associates longitude with the x-coordinate of the map, and latitude with the y-coordinate,
* the latitude coordinate is always written first, followed by the longitude.
* Notice that you cannot modify the coordinates of a LatLng. If you want to compute another point, you have to create a new one.
*/
export class LatLng {
/**
* Creates a LatLng object representing a geographic point.
* Note the ordering of latitude and longitude.
* @param lat Latitude is specified in degrees within the range [-90, 90].
* @param lng Longitude is specified in degrees within the range [-180, 180].
* @param noWrap Set noWrap to true to enable values outside of this range.
*/
constructor(lat: number, lng: number, noWrap?: boolean);
/** Comparison function. */
equals(other: LatLng): boolean;
/** Returns the latitude in degrees. */
lat(): number;
/** Returns the longitude in degrees. */
lng(): number;
/** Converts to string representation. */
toString(): string;
/** Returns a string of the form "lat,lng". We round the lat/lng values to 6 decimal places by default. */
toUrlValue(precision?: number): string;
}
export class LatLngBounds {
@@ -1383,11 +1569,17 @@ declare module google.maps {
union(other: LatLngBounds): LatLngBounds;
}
export class Point {
constructor (x: number, y: number);
/** A point on a two-dimensional plane. */
constructor(x: number, y: number);
/** The X coordinate */
x: number;
/** The Y coordinate */
y: number;
/** Compares two Points */
equals(other: Point): boolean;
/** Returns a string representation of this Point. */
toString(): string;
}
+96
View File
@@ -0,0 +1,96 @@
/// <reference path="heap.d.ts" />
var numberComparator = (a: number, b: number) => { return a.toString().length - b.toString().length; };
var stringComparator = (a: string, b: string) => { return a.length - b.length; };
// Test constructor
var numberHeap: Heap<number> = new Heap<number>();
numberHeap = new Heap<number>(numberComparator);
var stringHeap: Heap<string> = new Heap<string>();
stringHeap = new Heap<string>(stringComparator);
// Test instance methods
numberHeap.push(0);
stringHeap.push("foo");
numberHeap.insert(0);
stringHeap.insert("foo");
var numberIdentifier: number = numberHeap.pop();
var stringIdentifier: string = stringHeap.pop();
numberIdentifier = numberHeap.replace(1);
stringIdentifier = stringHeap.replace("bar");
numberIdentifier = numberHeap.pushpop(2);
stringIdentifier = stringHeap.pushpop("bar");
numberHeap.heapify();
stringHeap.heapify();
numberHeap.updateItem(2);
stringHeap.updateItem("bar");
var booleanIdentifier: boolean = numberHeap.empty();
booleanIdentifier = stringHeap.empty();
numberIdentifier = numberHeap.size();
numberIdentifier = stringHeap.size();
var numberArray: number[] = numberHeap.toArray();
var stringArray: string[] = stringHeap.toArray();
numberHeap = numberHeap.clone();
numberHeap = numberHeap.copy();
stringHeap = stringHeap.clone();
stringHeap = stringHeap.copy();
// Test static methods
Heap.push(numberArray, 3);
Heap.push(numberArray, 3, numberComparator);
Heap.push(stringArray, "foo");
Heap.push(stringArray, "foo", stringComparator);
numberIdentifier = Heap.pop(numberArray);
numberIdentifier = Heap.pop(numberArray, numberComparator);
stringIdentifier = Heap.pop(stringArray);
stringIdentifier = Heap.pop(stringArray, stringComparator);
numberIdentifier = Heap.replace(numberArray, 1);
numberIdentifier = Heap.replace(numberArray, 1, numberComparator);
stringIdentifier = Heap.replace(stringArray, "foo");
stringIdentifier = Heap.replace(stringArray, "foo", stringComparator);
numberIdentifier = Heap.pushpop(numberArray, 1);
numberIdentifier = Heap.pushpop(numberArray, 1, numberComparator);
stringIdentifier = Heap.pushpop(stringArray, "foo");
stringIdentifier = Heap.pushpop(stringArray, "foo", stringComparator);
Heap.heapify(numberArray);
Heap.heapify(numberArray, numberComparator);
Heap.heapify(stringArray);
Heap.heapify(stringArray, stringComparator);
Heap.updateItem(numberArray, 1);
Heap.updateItem(numberArray, 1, numberComparator);
Heap.updateItem(stringArray, "foo");
Heap.updateItem(stringArray, "foo", stringComparator);
Heap.nlargest(numberArray, 1);
Heap.nlargest(numberArray, 1, numberComparator);
Heap.nlargest(stringArray, 1);
Heap.nlargest(stringArray, 1, stringComparator);
Heap.nsmallest(numberArray, 1);
Heap.nsmallest(numberArray, 1, numberComparator);
Heap.nsmallest(stringArray, 1);
Heap.nsmallest(stringArray, 1, stringComparator);
+84
View File
@@ -0,0 +1,84 @@
// Type definitions for heap 0.2.6
// Project: https://github.com/qiao/heap.js
// Definitions by: Ryan McNamara <https://github.com/ryan10132>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare class Heap<T> {
// Constructor
constructor(cmp?: (a: T, b: T) => number);
// Instance Methods
// Push item onto heap.
push(item: T): void;
insert(item: T): void;
// Pop the smallest item off the heap and return it.
pop(): T;
// Return the smallest item of the heap.
peek(): T;
top(): T;
front(): T;
// Pop and return the current smallest value, and add the new item.
// This is more efficient than pop() followed by push(), and can be more appropriate when using a fixed size heap.
// Note that the value returned may be larger than item!
replace(item: T): T;
// Fast version of a push followed by a pop.
pushpop(item: T): T;
// Rebuild the heap. This method may come handy when the priority of the internal data is being modified.
heapify(): void;
// Update the position of the given item in the heap. This function should be called every time the item is being modified.
updateItem(item: T): void;
// Determine whether the heap is empty.
empty(): boolean;
// Get the number of elements stored in the heap.
size(): number;
// Return the array representation of the heap. (note: the array is a shallow copy of the heap's internal nodes)
toArray(): T[];
// Return a clone of the heap. (note: the internal data is a shallow copy of the original one)
clone(): Heap<T>
copy(): Heap<T>
// Static Methods
// Push item onto array, maintaining the heap invariant.
static push<T>(array: T[], item: T, cmp?: (a: T, b: T) => number): void;
// Pop the smallest item off the array, maintaining the heap invariant.
static pop<T>(array: T[], cmp?: (a: T, b: T) => number): T;
// Pop and return the current smallest value, and add the new item.
// This is more efficient than heappop() followed by heappush(), and can be more appropriate when using a fixed size heap. Note that the value returned may be larger than item!
static replace<T>(array: T[], item: T, cmp?: (a: T, b: T) => number): T;
// Fast version of a heappush followed by a heappop.
static pushpop<T>(array: T[], item: T, cmp?: (a: T, b: T) => number): T;
// Build the heap.
static heapify<T>(array: T[], cmp?: (a: T, b: T) => number): Heap<T>;
// Update the position of the given item in the heap. This function should be called every time the item is being modified.
static updateItem<T>(array: T[], item: T, cmp?: (a: T, b: T) => number): void;
// Find the n largest elements in a dataset.
static nlargest<T>(array: T[], n: number, cmp?: (a: T, b: T) => number): T[];
// Find the n smallest elements in a dataset.
static nsmallest<T>(array: T[], n: number, cmp?: (a: T, b: T) => number): T[];
}
declare module 'heap' {
export = Heap;
}
+18
View File
@@ -665,6 +665,24 @@ describe('i18next', function () {
});
describe('adding resources after initialisation', function () {
var frResource = <IResourceStoreKey>{ 'simple_fr': 'ok_from_fr' };
var enResource = <IResourceStoreKey>{ 'simple_en': 'ok_from_en' };
beforeEach(function (done) {
i18n.init({ resStore: {} },
function (t) { done(); });
});
it('it should use resources for translation added after initialisation', function () {
i18n.addResources('fr', 'translation', frResource);
i18n.addResources('en', 'translation', enResource);
expect(i18n.t('simple_fr', { lng: 'fr' })).to.be('ok_from_fr');
expect(i18n.t('simple_en', { lng: 'en' })).to.be('ok_from_en');
});
});
});
describe('translation functionality', function () {
+5
View File
@@ -67,6 +67,7 @@ interface I18nextOptions {
interface I18nextStatic {
addPostProcessor(name: string, fn: (value: any, key: string, options: any) => string): void;
addResources(language: string, namespace: string, resources: IResourceStoreKey): void;
detectLanguage(): string;
functions: {
extend(target: any, ...objs: any[]): Object;
@@ -130,4 +131,8 @@ declare var i18n: I18nextStatic;
declare module 'i18next' {
export = i18n;
}
declare module 'i18next-client' {
export = i18n;
}
+4
View File
@@ -39,6 +39,10 @@ describe("Jasmine jQuery extension", () => {
expect($('<input type="text" />').focus()).toBeFocused();
//expect($form).toHandle("submit")
//expect($form).toHandleWith("submit", yourSubmitCallback)
expect($('<div></div>')).toBeInDOM();
expect($('<div><span class="some-class"></span></div>')).toContainElement('span.some-class');
expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>');
expect($('<div><ul></ul><h1>header</h1></div>')).toContainText('header')
});
it("Handles HTML Fixtures", () => {
+246 -2
View File
@@ -81,39 +81,283 @@ declare module jasmine {
}
interface Matchers {
/**
* Check if DOM element has class.
*
* @param className Name of the class to check.
*
* @example
* // returns true
* expect($('<div class="some-class"></div>')).toHaveClass("some-class")
*/
toHaveClass(className: string): boolean;
toHaveCss(css): boolean;
/**
* Check if DOM element has the given CSS properties.
*
* @param css Object containing the properties (and values) to check.
*
* @example
* // returns true
* expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({display: "none", margin: "10px"})
*
* @example
* // returns true
* expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({margin: "10px"})
*/
toHaveCss(css: Object): boolean;
/**
* Checks if DOM element is visible.
* Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
*/
toBeVisible(): boolean;
/**
* Check if DOM element is hidden.
* Elements can be hidden for several reasons:
* - They have a CSS display value of none ;
* - They are form elements with type equal to hidden.
* - Their width and height are explicitly set to 0.
* - An ancestor element is hidden, so the element is not shown on the page.
*/
toBeHidden(): boolean;
/**
* Only for tags that have checked attribute
*
* @example
* // returns true
* expect($('<option selected="selected"></option>')).toBeSelected()
*/
toBeSelected(): boolean;
/**
* Only for tags that have checked attribute
* @example
* // returns true
* expect($('<input type="checkbox" checked="checked"/>')).toBeChecked()
*/
toBeChecked(): boolean;
/**
* Checks for child DOM elements or text
*/
toBeEmpty(): boolean;
/**
* Checks if element exists in or out the DOM.
*/
toExist(): boolean;
/**
* Checks if array has the given length.
*
* @param length Expected length
*/
toHaveLength(length: number): boolean;
/**
* Check if DOM element contains an attribute and, optionally, if the value of the attribute is equal to the expected one.
*
* @param attributeName Name of the attribute to check
* @param expectedAttributeValue Expected attribute value
*/
toHaveAttr(attributeName: string, expectedAttributeValue?): boolean;
/**
* Check if DOM element contains a property and, optionally, if the value of the property is equal to the expected one.
*
* @param propertyName Property name to check
* @param expectedPropertyValue Expected property value
*/
toHaveProp(propertyName: string, expectedPropertyValue?): boolean;
/**
* Check if DOM element has the given Id
*
* @param Id Expected identifier
*/
toHaveId(id: string): boolean;
/**
* Check if DOM element has the specified HTML.
*
* @example
* // returns true
* expect($('<div><span></span></div>')).toHaveHtml('<span></span>')
*/
toHaveHtml(html: string): boolean;
/**
* Check if DOM element contains the specified HTML.
*
* @example
* // returns true
* expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')
*/
//toContainHtml(html: string): boolean;
/**
* Check if DOM element has the given Text.
* @param text Accepts a string or regular expression
*
* @example
* // returns true
* expect($('<div>some text</div>')).toHaveText('some text')
*/
toHaveText(text: string): boolean;
/**
* Check if DOM element contains the specified text.
*
* @example
* // returns true
* expect($('<div><ul></ul><h1>header</h1></div>')).toContainText('header')
*/
//toContainText(text: string): boolean;
/**
* Check if DOM element has the given value.
* This can only be applied for element on with jQuery val() can be called.
*
* @example
* // returns true
* expect($('<input type="text" value="some text"/>')).toHaveValue('some text')
*/
toHaveValue(value): boolean;
/**
* Check if DOM element has the given data.
* This can only be applied for element on with jQuery data(key) can be called.
*
*/
toHaveData(key, expectedValue): boolean;
toBe(selector: JQuery): boolean;
/**
* Check if DOM element is matched by the given selector.
*
* @example
* // returns true
* expect($('<div><span class="some-class"></span></div>')).toContain('some-class')
*/
toContain(selector: JQuery): boolean;
/**
* Check if DOM element exists inside the given parent element.
*
* @example
* // returns true
* expect($('<div><span class="some-class"></span></div>')).toContainElement('span.some-class')
*/
toContainElement(selector: string): boolean;
/**
* Check to see if the set of matched elements matches the given selector
*
* @example
* expect($('<span></span>').addClass('js-something')).toBeMatchedBy('.js-something')
*
* @returns {Boolean} true if DOM contains the element
*/
toBeMatchedBy(selector: string): boolean;
/**
* Only for tags that have disabled attribute
* @example
* // returns true
* expect('<input type="submit" disabled="disabled"/>').toBeDisabled()
*/
toBeDisabled(): boolean;
/**
* Check if DOM element is focused
* @example
* // returns true
* expect($('<input type="text" />').focus()).toBeFocused()
*/
toBeFocused(): boolean;
toHandle(event): boolean;
/**
* Checks if DOM element handles event.
*
* @example
* // returns true
* expect($form).toHandle("submit")
*/
toHandle(eventName: string): boolean;
/**
* Assigns a callback to an event of the DOM element.
*
* @param eventName Name of the event to assign the callback to.
* @param eventHandler Callback function to be assigned.
*
* @example
* expect($form).toHandleWith("submit", yourSubmitCallback)
*/
toHandleWith(eventName: string, eventHandler): boolean;
/**
* Checks if event was triggered.
*/
toHaveBeenTriggered(): boolean;
/**
* Checks if the event has been triggered on selector.
* @param selector Selector that should have triggered the event.
*/
toHaveBeenTriggeredOn(selector: string): boolean;
/**
* Checks if the event has been triggered on selector.
* @param selector Selector that should have triggered the event.
* @param args Extra arguments to be passed to jQuery events functions.
*/
toHaveBeenTriggeredOnAndWith(selector: string, ...args: any[]): boolean;
/**
* Checks if event propagation has been prevented.
*/
toHaveBeenPrevented(): boolean;
/**
* Checks if event propagation has been prevented on element with selector.
*
* @param selector Selector that should have prevented the event.
*/
toHaveBeenPreventedOn(selector: string): boolean;
/**
* Checks if event propagation has been stopped.
*
* @example
* // returns true
* var spyEvent = spyOnEvent('#some_element', 'click')
* $('#some_element').click(function (event){event.stopPropagation();})
* $('#some_element').click()
* expect(spyEvent).toHaveBeenStopped()
*/
toHaveBeenStopped(): boolean;
/**
* Checks if event propagation has been stopped by an element with the given selector.
* @param selector Selector of the element that should have stopped the event propagation.
*
* @example
* // returns true
* $('#some_element').click(function (event){event.stopPropagation();})
* $('#some_element').click()
* expect('click').toHaveBeenStoppedOn('#some_element')
*/
toHaveBeenStoppedOn(selector: string): boolean;
/**
* Checks to see if the matched element is attached to the DOM.
* @example
* expect($('#id-name')[0]).toBeInDOM()
*/
toBeInDOM(): boolean;
}
interface JQueryEventSpy {
+3
View File
@@ -143,6 +143,8 @@ result = <string>_('test').value();
result = <number[]>_([1, 2, 3]).value();
result = <_.Dictionary<string>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value();
result = <_.Dictionary<number>>_({ a: 1, b: 2}).mapValues(function(num: number) { return num * 2; }).value();
// /*************
// * Arrays *
// *************/
@@ -292,6 +294,7 @@ result = <number[]>_.range(0);
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' });
result = <number>_.sortedIndex([20, 30, 50], 40);
result = <number>_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
+315 -274
View File
File diff suppressed because it is too large Load Diff
+103
View File
@@ -0,0 +1,103 @@
/// <reference path="lokijs.d.ts" />
import Loki = require("lokijs");
module LokijsTest {
class Ant {
static uniqueId = 1;
id: number;
dob: Date;
health: number; // range [0.0, 1.0]
lengthMm: number; // in millimeters
weightMg: number; // in milligrams
constructor(id: number) {
this.id = id;
}
static createAnt() {
return new Ant(Ant.uniqueId++);
}
}
class QueenAnt extends Ant {
eggsBirthed: number;
constructor(id: number) {
super(id);
}
static createQueenAnt() {
return new QueenAnt(Ant.uniqueId++);
}
}
class AntColony {
ants: LokiCollection<Ant>;
queens: LokiCollection<QueenAnt>;
constructor(ants?: LokiCollection<Ant>, queens?: LokiCollection<QueenAnt>) {
this.ants = ants;
this.queens = queens;
}
}
export class Test {
static runAllTests() {
var lokiInst = new Loki("ant-colony", { autosave: false });
var colony = Test.createAntColony(lokiInst, 250);
var topAnts = colony.ants.addDynamicView("top-ants");
var topAntAry = topAnts.applyFind({ $gt: { health: 0.75 } }).data();
if (colony.ants.binaryIndices["id"] == null) {
throw new Error("missing 'id' binary index");
}
if (lokiInst.getCollection<Ant>("ants") != colony.ants) {
throw new Error("ant collections don't match");
}
var collNames = lokiInst.listCollections().map((coll) => coll.name);
if (collNames.length != 2 || collNames.indexOf("ants") < 0 || collNames.indexOf("queenAnts") < 0) {
throw new Error("collections [" + collNames + "] does not equal expected ['ants', 'queenAnts']");
}
var firstQueenId = (<any>colony.queens.findOne({}))["$loki"];
if (firstQueenId == null || colony.queens.get(firstQueenId) == null) {
throw new Error("queen object's '.$loki' property lookup failed");
}
var anotherColl = new Loki.Collection("anotherCollection");
}
static createAntColony(lokiInst: Loki, antCount: number, queenCount: number = 1) {
var ants = lokiInst.addCollection<Ant>("ants", { indices: "id" });
var queens = lokiInst.addCollection<QueenAnt>("queenAnts", { indices: "id" });
var antColony = new AntColony(ants, queens);
for (var i = 0; i < antCount; i++) {
ants.add(Ant.createAnt());
}
for (var i = 0; i < antCount; i++) {
queens.add(QueenAnt.createQueenAnt());
}
return antColony;
}
}
}
export = LokijsTest;
+1189
View File
File diff suppressed because it is too large Load Diff
+153
View File
@@ -0,0 +1,153 @@
/// <reference path="node-calendar" />
import node_calendar = require('node-calendar');
var cal = new node_calendar.Calendar(node_calendar.SUNDAY);
assert(cal.getfirstweekday() == node_calendar.SUNDAY);
cal.setfirstweekday(node_calendar.MONDAY);
assert(cal.getfirstweekday() == node_calendar.MONDAY);
assert(node_calendar.MONDAY == 0);
assert(node_calendar.TUESDAY == 1);
assert(node_calendar.WEDNESDAY == 2);
assert(node_calendar.THURSDAY == 3);
assert(node_calendar.FRIDAY == 4);
assert(node_calendar.SATURDAY == 5);
assert(node_calendar.SUNDAY == 6);
assert(node_calendar.day_name[node_calendar.MONDAY] == 'Monday');
assert(node_calendar.day_name[node_calendar.TUESDAY] == 'Tuesday');
assert(node_calendar.day_name[node_calendar.WEDNESDAY] == 'Wednesday');
assert(node_calendar.day_name[node_calendar.THURSDAY] == 'Thursday');
assert(node_calendar.day_name[node_calendar.FRIDAY] == 'Friday');
assert(node_calendar.day_name[node_calendar.SATURDAY] == 'Saturday');
assert(node_calendar.day_name[node_calendar.SUNDAY] == 'Sunday');
assert(node_calendar.day_abbr[node_calendar.MONDAY] == 'Mon');
assert(node_calendar.day_abbr[node_calendar.TUESDAY] == 'Tue');
assert(node_calendar.day_abbr[node_calendar.WEDNESDAY] == 'Wed');
assert(node_calendar.day_abbr[node_calendar.THURSDAY] == 'Thu');
assert(node_calendar.day_abbr[node_calendar.FRIDAY] == 'Fri');
assert(node_calendar.day_abbr[node_calendar.SATURDAY] == 'Sat');
assert(node_calendar.day_abbr[node_calendar.SUNDAY] == 'Sun');
assert(node_calendar.JANUARY == 1);
assert(node_calendar.FEBRUARY == 2);
assert(node_calendar.MARCH == 3);
assert(node_calendar.APRIL == 4);
assert(node_calendar.MAY == 5);
assert(node_calendar.JUNE == 6);
assert(node_calendar.JULY == 7);
assert(node_calendar.AUGUST == 8);
assert(node_calendar.SEPTEMBER == 9);
assert(node_calendar.OCTOBER == 10);
assert(node_calendar.NOVEMBER == 11);
assert(node_calendar.DECEMBER == 12);
assert(node_calendar.month_name[0] == '');
assert(node_calendar.month_name[node_calendar.JANUARY] == 'January');
assert(node_calendar.month_name[node_calendar.FEBRUARY] == 'February');
assert(node_calendar.month_name[node_calendar.MARCH] == 'March');
assert(node_calendar.month_name[node_calendar.APRIL] == 'April');
assert(node_calendar.month_name[node_calendar.MAY] == 'May');
assert(node_calendar.month_name[node_calendar.JUNE] == 'June');
assert(node_calendar.month_name[node_calendar.JULY] == 'July');
assert(node_calendar.month_name[node_calendar.AUGUST] == 'August');
assert(node_calendar.month_name[node_calendar.SEPTEMBER] == 'September');
assert(node_calendar.month_name[node_calendar.OCTOBER] == 'October');
assert(node_calendar.month_name[node_calendar.NOVEMBER] == 'November');
assert(node_calendar.month_name[node_calendar.DECEMBER] == 'December');
assert(node_calendar.month_abbr[0] == '');
assert(node_calendar.month_abbr[node_calendar.JANUARY] == 'Jan');
assert(node_calendar.month_abbr[node_calendar.FEBRUARY] == 'Feb');
assert(node_calendar.month_abbr[node_calendar.MARCH] == 'Mar');
assert(node_calendar.month_abbr[node_calendar.APRIL] == 'Apr');
assert(node_calendar.month_abbr[node_calendar.MAY] == 'May');
assert(node_calendar.month_abbr[node_calendar.JUNE] == 'Jun');
assert(node_calendar.month_abbr[node_calendar.JULY] == 'Jul');
assert(node_calendar.month_abbr[node_calendar.AUGUST] == 'Aug');
assert(node_calendar.month_abbr[node_calendar.SEPTEMBER] == 'Sep');
assert(node_calendar.month_abbr[node_calendar.OCTOBER] == 'Oct');
assert(node_calendar.month_abbr[node_calendar.NOVEMBER] == 'Nov');
assert(node_calendar.month_abbr[node_calendar.DECEMBER] == 'Dec');
cal.itermonthdates(2015, node_calendar.JANUARY).forEach(assertIsDate);
cal.itermonthdays(2014, node_calendar.FEBRUARY).forEach(assertIsNumber);
cal.itermonthdays2(2013, node_calendar.MARCH).forEach(assertDayOfWeekMonth);
cal.iterweekdays().forEach(assertIsNumber);
assertMonthGrid(cal.monthdatescalendar(2012, node_calendar.APRIL), assertIsDate);
assertMonthGrid(cal.monthdays2calendar(2011, node_calendar.MAY), assertDayOfWeekMonth);
assertMonthGrid(cal.monthdayscalendar(2010, node_calendar.JUNE), assertIsNumber);
assertYearGrid(cal.yeardatescalendar(2009, 3), assertIsDate);
assertYearGrid(cal.yeardays2calendar(2008, 2), assertDayOfWeekMonth);
assertYearGrid(cal.yeardayscalendar(2007, 4), assertIsNumber);
node_calendar.setlocale('en_US');
assertIsError(new node_calendar.IllegalDayError());
assertIsError(new node_calendar.IllegalLocaleError());
assertIsError(new node_calendar.IllegalMonthError());
assertIsError(new node_calendar.IllegalTimeError);
assertIsError(new node_calendar.IllegalWeekdayError());
assertIsBoolean(node_calendar.isleap(2000));
assertIsNumber(node_calendar.weekday(2015, node_calendar.JULY, 7));
assertIsNumber(node_calendar.leapdays(2000, 2010));
node_calendar.monthrange(2015, node_calendar.JANUARY).forEach(assertIsNumber);
var timegmt:[number,number,number,number,number,number] = [2014, node_calendar.JULY, 7, 12, 41, 59];
assertIsNumber(node_calendar.timegm(timegmt));
// FUNCTIONS ------------------------------------------------------------------
function assertIsDate(d: Date) {
assert(d instanceof Date, 'Should be a date');
}
function assertIsNumber(n: number) {
assert(typeof n == 'number', 'Should be a number');
}
function assertIsBoolean(b: boolean) {
assert(typeof b == 'boolean', 'Should be a boolean');
}
function assertDayOfWeekMonth(d: [number, number]) {
assert(d instanceof Array, 'Day of weak/month should be an array');
assert(d.length == 2, 'Day of weak/month array should contain 2 items');
assert(typeof d[0] == 'number', 'Day of month should be a number');
assert(typeof d[1] == 'number', 'Day of week should be a number');
}
function assertWeekRow<T>(row: IWeekRow<T>, assertItemType: (item: T) => void) {
row.forEach(assertItemType);
}
function assertMonthGrid<T>(grid: IMonthGrid<T>, assertItemType: (item: T) => void) {
grid.forEach(wr => assertWeekRow(wr, assertItemType));
}
function assertMonthRow<T>(row: IMonthRow<T>, assertItemType: (item: T) => void) {
row.forEach(mg => assertMonthGrid(mg, assertItemType));
}
function assertYearGrid<T>(grid: IYearGrid<T>, assertItemType: (item: T) => void) {
grid.forEach(mr => assertMonthRow(mr, assertItemType));
}
function assert(condition: boolean, msg?: string): void {
if (condition) return;
throw new Error(msg);
}
function assertIsError(error: Error) {
assert(typeof error.name == 'string', 'Error name should exist and be a string');
assert(typeof error.message == 'string', 'Error message should exist and be a string');
}
+402
View File
@@ -0,0 +1,402 @@
// Type definitions for node-calendar v0.1.4
// Project: https://www.npmjs.com/package/node-calendar
// Definitions by: Luzian Zagadinow <https://github.com/luzianz>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface IWeekRow<T> extends Array<T> {
[dayIndex: number]: T;
}
interface IMonthGrid<T> extends Array<IWeekRow<T>> {
[weekRowIndex: number]: IWeekRow<T>;
}
interface IMonthRow<T> extends Array<IMonthGrid<T>> {
[monthColumnIndex: number]: IMonthGrid<T>;
}
interface IYearGrid<T> extends Array<IMonthRow<T>> {
[monthRowIndex: number]: IMonthRow<T>;
}
/**
* This module allows you to output calendars like the Unix cal program, and provides
* additional useful functions related to the calendar. By default, these calendars
* have Monday as the first day of the week, and Sunday as the last (the European
* convention). Use setfirstweekday() to set the first day of the week to Sunday
* (6) or to any other weekday. Parameters that specify dates are given as integers.
*/
declare module 'node-calendar' {
/** 0 */
export var MONDAY: number;
/** 1 */
export var TUESDAY: number;
/** 2 */
export var WEDNESDAY: number;
/** 3 */
export var THURSDAY: number;
/** 4 */
export var FRIDAY: number;
/** 5 */
export var SATURDAY: number;
/** 6 */
export var SUNDAY: number;
/** 1 */
export var JANUARY: number;
/** 2 */
export var FEBRUARY: number;
/** 3 */
export var MARCH: number;
/** 4 */
export var APRIL: number;
/** 5 */
export var MAY: number;
/** 6 */
export var JUNE: number;
/** 7 */
export var JULY: number;
/** 8 */
export var AUGUST: number;
/** 9 */
export var SEPTEMBER: number;
/** 10 */
export var OCTOBER: number;
/** 11 */
export var NOVEMBER: number;
/** 12 */
export var DECEMBER: number;
/**
* [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]
*/
export var day_name: string[];
/**
* [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ]
*/
export var day_abbr: string[];
/**
* [ '', 'January', 'February', 'March',
* 'April', 'May', 'June', 'July', 'August',
* 'September', 'October', 'November', 'December' ]
*/
export var month_name: string[];
/**
* [ '', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
* 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
*/
export var month_abbr: string[];
/**
* Base calendar class. This class doesn't do any formatting. It simply provides
* data to subclasses.
*/
export class Calendar {
/**
* @param {number} firstweekday
* Numerical day of the week the calendar weeks should start.
* (0=MON, 1=TUE, ...) Default: 0
*/
constructor(firstweekday?: number);
/**
* Numerical day of the week the calendar weeks should start.
* (0=MON, 1=TUE, ...)
*
* @method getfirstweekday
*/
getfirstweekday(): number;
/**
* Numerical day of the week the calendar weeks should start.
* (0=MON, 1=TUE, ...)
*
* @param {number} firstweekday
* Numerical day of the week the calendar weeks should start.
* (0=MON, 1=TUE, ...) Default: 0
*/
setfirstweekday(firstweekday: number): void;
/**
* One week of weekday numbers starting with the configured first one.
*/
iterweekdays(): number[];
/**
* Dates for one month. The array will contain Date values and will always
* iterate through complete weeks, so it will yield dates outside the
* specified month.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} month
* Month for which the calendar should be generated.
*/
itermonthdates(year: number, month: number): Date[];
/**
* Like itermonthdates(), but will yield day numbers. For days outside
* the specified month the day number is 0.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} month
* Month for which the calendar should be generated.
*/
itermonthdays(year: number, month: number): number[];
/**
* Like itermonthdates(), but will yield [day number, weekday number]
* arrays. For days outside the specified month the day number is 0.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} month
* Month for which the calendar should be generated.
*/
itermonthdays2(year: number, month: number): [number, number][];
/**
* A matrix (array of array) representing a month's calendar.
* Each row represents a week; week entries are Date values.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} month
* Month for which the calendar should be generated.
*/
monthdatescalendar(year: number, month: number): IMonthGrid<Date>;
/**
* A matrix representing a month's calendar. Each row represents a week;
* days outside this month are zero.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} month
* Month for which the calendar should be generated.
*/
monthdayscalendar(year: number, month: number): IMonthGrid<number>;
/**
* Return a matrix representing a month's calendar. Each row represents
* a week; week entries are [day number, weekday number] arrays. Day numbers
* outside this month are zero.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} month
* Month for which the calendar should be generated.
*/
monthdays2calendar(year: number, month: number): IMonthGrid<[number, number]>;
/**
* The specified year ready for formatting. The return value is an array
* of month rows. Each month row contains up to width months. Each month
* contains between 4 and 6 weeks and each week contains 1-7 days. Days
* are Date objects.
*
* @param {number} year
* Year for which the calendar should be generated.
*
* @param {number} width
* The number of months to include in each row. Default: 3
*/
yeardatescalendar(year: number, width?: number): IYearGrid<Date>;
/**
* the specified year ready for formatting (similar to yeardatescalendar()).
* Entries in the week arrays are day numbers. Day numbers outside this
* month are zero.
*
* @param {number} year
* Year for which the calendar should be generated
*
* @param {number} width
* The number of months to include in each row. Default: 3
*/
yeardayscalendar(year: number, width?: number): IYearGrid<number>;
/**
* The specified year ready for formatting (similar to yeardatescalendar()).
* Entries in the week arrays are [day number, weekday number] arrays.
* Day numbers outside this month are zero.
*
* @param {number} year
* Year for which the calendar should be generated
*
* @param {number} width
* The number of months to include in each row. Default: 3
*/
yeardays2calendar(year: number, width?: number): IYearGrid<[number, number]>;
}
/**
* @param {number} year
* Year to test.
*
* @return {boolean}
* true for leap years, false for non-leap years.
*/
export function isleap(year: number): boolean;
/**
* @param {number} y1
* Beginning year in the range to test.
*
* @param {number} y2
* Ending year in the range to test.
*
* @return {number}
* Number of leap years in range (y1...y2). Assumes y1 <= y2.
*/
export function leapdays(y1: number, y2: number): number;
/**
* @param {number} year
* Year for which the range should be calculated.
*
* @param {number} month
* Month for which the range should be calculated.
*
* @throws {IllegalMonthError} if the provided month is invalid.
*
* @return {[number, number]}
* starting weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month.
*/
export function monthrange(year: number, month: number): [number, number];
/**
* Sets the locale for use in extracting month and weekday names.
*
* @param {string} locale
* Locale to set on the calendar object. Default: en_US
*
* @throws {IllegalLocaleError} if the provided locale is invalid.
*/
export function setlocale(locale?: string): void;
/**
* Unrelated but handy function to calculate Unix timestamp from GMT.
*
* @param timegmt {[number, number, number, number, number, number]}
* An array containing the elements from a time structure dataset.
* Format: [tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec]
*
* @throws {IllegalMonthError} if the provided month element is invalid.
*
* @throws {IllegalDayError} if the provided day element is invalid.
*
* @throws {IllegalTimeError} if any of the the provided time elements are invalid.
*
* @return {number}
* Unix timestamp from GMT.
*/
export function timegm(timegmt: [number, number, number, number, number, number]): number;
/**
* @param {number} year
* Year for which the weekday should be calculated.
*
* @param {number} month
* Month for which the weekday should be calculated.
*
* @param {number} day
* Day for which the weekday should be calculated.
*
* @throws {IllegalMonthError} if the provided month element is invalid.
*
* @throws {IllegalDayError} if the provided day element is invalid.
*
* @return {number}
* weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31).
*/
export function weekday(year: number, month: number, day: number): number;
/** Error indicating a nonexistent or unsupported locale specified. */
export class IllegalLocaleError implements Error {
public name: string;
public message: string;
/**
* @param {string} message
* Optional custom error message.
*/
constructor(message?: string)
}
/** Error indicating a day index specified outside of the valid range. */
export class IllegalDayError implements Error {
public name: string;
public message: string;
/**
* @param {string} message
* Optional custom error message.
*/
constructor(message?: string)
}
/** Error indicating a month index specified outside of the expected range (1-12 ~ Jan-Dec). */
export class IllegalMonthError implements Error {
public name: string;
public message: string;
/**
* @param {string} message
* Optional custom error message.
*/
constructor(message?: string)
}
/** Error indicating a time element is outside of the valid range. */
export class IllegalTimeError implements Error {
public name: string;
public message: string;
/**
* @param {string} message
* Optional custom error message.
*/
constructor(message?: string)
}
/** Error indicating a weekday index specified outside of the expected range (0-6 ~ Mon-Sun). */
export class IllegalWeekdayError implements Error {
public name: string;
public message: string;
/**
* @param {string} message
* Optional custom error message.
*/
constructor(message?: string)
}
}
+30
View File
@@ -7,6 +7,7 @@ import zlib = require("zlib");
import url = require('url');
import util = require("util");
import crypto = require("crypto");
import tls = require("tls");
import http = require("http");
import net = require("net");
import dgram = require("dgram");
@@ -68,6 +69,25 @@ fs.readFile('testfile', (err, data) => {
}
});
///////////////////////////////////////////////////////
/// Buffer tests : https://nodejs.org/api/buffer.html
///////////////////////////////////////////////////////
function bufferTests() {
var utf8Buffer = new Buffer('test');
var base64Buffer = new Buffer('','base64');
var octets: Uint8Array = null;
var octetBuffer = new Buffer(octets);
console.log(Buffer.isBuffer(octetBuffer));
console.log(Buffer.isEncoding('utf8'));
console.log(Buffer.byteLength('xyz123'));
console.log(Buffer.byteLength('xyz123', 'ascii'));
var result1 = Buffer.concat([utf8Buffer, base64Buffer]);
var result2 = Buffer.concat([utf8Buffer, base64Buffer], 9999999);
}
////////////////////////////////////////////////////
/// Url tests : http://nodejs.org/api/url.html
////////////////////////////////////////////////////
@@ -143,6 +163,16 @@ function crypto_cipher_decipher_buffer_test() {
assert.deepEqual(clearText2, clearText);
}
////////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html
////////////////////////////////////////////////////
var ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
////////////////////////////////////////////////////
// Make sure .listen() and .close() retuern a Server instance
+284 -7
View File
@@ -61,14 +61,71 @@ declare var SlowBuffer: {
// Buffer class
interface Buffer extends NodeBuffer {}
/**
* Raw data is stored in instances of the Buffer class.
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
*/
declare var Buffer: {
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
*/
new (str: string, encoding?: string): Buffer;
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
*/
new (size: number): Buffer;
new (size: Uint8Array): Buffer;
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
new (array: Uint8Array): Buffer;
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
new (array: any[]): Buffer;
prototype: Buffer;
/**
* Returns true if {obj} is a Buffer
*
* @param obj object to test.
*/
isBuffer(obj: any): boolean;
/**
* Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
*
* @param encoding string to test.
*/
isEncoding(encoding: string): boolean;
/**
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
* This is not the same as String.prototype.length since that returns the number of characters in a string.
*
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
byteLength(string: string, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
* If the list has exactly one item, then the first item of the list is returned.
* If the list has more than one item, then a new Buffer is created.
*
* @param list An array of Buffer objects to concatenate
* @param totalLength Total length of the buffers when concatenated.
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
concat(list: Buffer[], totalLength?: number): Buffer;
};
@@ -251,7 +308,7 @@ declare module NodeJS {
setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
undefined: typeof undefined;
unescape: (str: string) => string;
unescape: (str: string) => string;
gc: () => void;
}
@@ -977,7 +1034,18 @@ declare module "fs" {
close(): void;
}
/**
* Asynchronous rename.
* @param oldPath
* @param newPath
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
/**
* Synchronous rename
* @param oldPath
* @param newPath
*/
export function renameSync(oldPath: string, newPath: string): void;
export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
@@ -1017,15 +1085,71 @@ declare module "fs" {
export function readlinkSync(path: string): string;
export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void;
export function realpathSync(path: string, cache?: {[path: string]: string}): string;
export function realpathSync(path: string, cache?: { [path: string]: string }): string;
/*
* Asynchronous unlink - deletes the file specified in {path}
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
/*
* Synchronous unlink - deletes the file specified in {path}
*
* @param path
*/
export function unlinkSync(path: string): void;
/*
* Asynchronous rmdir - removes the directory specified in {path}
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
/*
* Synchronous rmdir - removes the directory specified in {path}
*
* @param path
*/
export function rmdirSync(path: string): void;
/*
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
/*
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param mode
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
/*
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param mode
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
/*
* Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param mode
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdirSync(path: string, mode?: number): void;
/*
* Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param mode
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdirSync(path: string, mode?: string): void;
export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
export function readdirSync(path: string): string[];
@@ -1050,12 +1174,57 @@ declare module "fs" {
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;
/*
* Asynchronous readFile - Asynchronously reads the entire contents of a file.
*
* @param fileName
* @param encoding
* @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
*/
export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
/*
* Asynchronous readFile - Asynchronously reads the entire contents of a file.
*
* @param fileName
* @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
* @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
*/
export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
/*
* Asynchronous readFile - Asynchronously reads the entire contents of a file.
*
* @param fileName
* @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
* @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
*/
export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void ): void;
/*
* Asynchronous readFile - Asynchronously reads the entire contents of a file.
*
* @param fileName
* @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
*/
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
/*
* Synchronous readFile - Synchronously reads the entire contents of a file.
*
* @param fileName
* @param encoding
*/
export function readFileSync(filename: string, encoding: string): string;
/*
* Synchronous readFile - Synchronously reads the entire contents of a file.
*
* @param fileName
* @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
*/
export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
/*
* Synchronous readFile - Synchronously reads the entire contents of a file.
*
* @param fileName
* @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
*/
export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
@@ -1097,26 +1266,118 @@ declare module "fs" {
declare module "path" {
/**
* A parsed path object generated by path.parse() or consumed by path.format().
*/
export interface ParsedPath {
/**
* The root of the path such as '/' or 'c:\'
*/
root: string;
/**
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
*/
dir: string;
/**
* The file name including extension (if any) such as 'index.html'
*/
base: string;
/**
* The file extension (if any) such as '.html'
*/
ext: string;
/**
* The file name without extension (if any) such as 'index'
*/
name: string;
}
/**
* Normalize a string path, reducing '..' and '.' parts.
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
*
* @param p string path to normalize.
*/
export function normalize(p: string): string;
/**
* Join all arguments together and normalize the resulting path.
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
*
* @param paths string paths to join.
*/
export function join(...paths: any[]): string;
/**
* Join all arguments together and normalize the resulting path.
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
*
* @param paths string paths to join.
*/
export function join(...paths: string[]): string;
/**
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
*
* Starting from leftmost {from} paramter, resolves {to} to an absolute path.
*
* If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
*
* @param pathSegments string paths to join. Non-string arguments are ignored.
*/
export function resolve(...pathSegments: any[]): string;
export function isAbsolute(p: string): boolean;
/**
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
*
* @param path path to test.
*/
export function isAbsolute(path: string): boolean;
/**
* Solve the relative path from {from} to {to}.
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
*
* @param from
* @param to
*/
export function relative(from: string, to: string): string;
/**
* Return the directory name of a path. Similar to the Unix dirname command.
*
* @param p the path to evaluate.
*/
export function dirname(p: string): string;
/**
* Return the last portion of a path. Similar to the Unix basename command.
* Often used to extract the file name from a fully qualified path.
*
* @param p the path to evaluate.
* @param ext optionally, an extension to remove from the result.
*/
export function basename(p: string, ext?: string): string;
/**
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
*
* @param p the path to evaluate.
*/
export function extname(p: string): string;
/**
* The platform-specific file separator. '\\' or '/'.
*/
export var sep: string;
/**
* The platform-specific file delimiter. ';' or ':'.
*/
export var delimiter: string;
export function parse(p: string): ParsedPath;
export function format(pP: ParsedPath): string;
/**
* Returns an object from a path string - the opposite of format().
*
* @param pathString path to evaluate.
*/
export function parse(pathString: string): ParsedPath;
/**
* Returns a path string from an object - the opposite of parse().
*
* @param pathString path to evaluate.
*/
export function format(pathObject: ParsedPath): string;
export module posix {
export function normalize(p: string): string;
@@ -1236,11 +1497,27 @@ declare module "tls" {
cleartext: any;
}
export interface SecureContextOptions {
pfx?: any; //string | buffer
key?: any; //string | buffer
passphrase?: string;
cert?: any; // string | buffer
ca?: any; // string | buffer
crl?: any; // string | string[]
ciphers?: string;
honorCipherOrder?: boolean;
}
export interface SecureContext {
context: any;
}
export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server;
export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream;
export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
export function createSecureContext(details: SecureContextOptions): SecureContext;
}
declare module "crypto" {
+44
View File
@@ -0,0 +1,44 @@
/// <reference path="numbro.d.ts" />
import numbro = require("numbro");
var valueFormat: string = numbro(1000).format('0,0');
// '1,000'
var valueUnformat: number = numbro().unformat('($10,000.00)');
// '-10000'
var value3: Numbro = numbro(1000);
var added: Numbro = value3.add(10);
// 1010
var value4: Numbro = numbro(1000);
var formatValue4a: string = value4.format('0,0');
// '1,000'
var formatValue4b: number = value4.value();
// 1000
var value5: Numbro = numbro();
value5.set(1000);
var value5Num: number = value5.value();
// 1000
var value6: Numbro = numbro(1000);
var value: number = 100;
var difference = value6.difference(value);
// 900
var value7: Numbro = numbro(0);
numbro.zeroFormat('N/A');
var zeroString: string = value7.format('0.0');
// 'N/A'
var a: Numbro = numbro(1000);
var b: Numbro = numbro(a);
var c: Numbro = a.clone();
var aVal: number = a.set(2000).value();
// 2000
var bVal: number = b.value();
// 1000
var cVal: number = c.add(10).value();
// 1010
+43
View File
@@ -0,0 +1,43 @@
/// <reference path="numbro.d.ts" />
var valueFormat: string = numbro(1000).format('0,0');
// '1,000'
var valueUnformat: number = numbro().unformat('($10,000.00)');
// '-10000'
var value3: Numbro = numbro(1000);
var added: Numbro = value3.add(10);
// 1010
var value4: Numbro = numbro(1000);
var formatValue4a: string = value4.format('0,0');
// '1,000'
var formatValue4b: number = value4.value();
// 1000
var value5: Numbro = numbro();
value5.set(1000);
var value5Num: number = value5.value();
// 1000
var value6: Numbro = numbro(1000);
var value: number = 100;
var difference = value6.difference(value);
// 900
var value7: Numbro = numbro(0);
numbro.zeroFormat('N/A');
var zeroString: string = value7.format('0.0');
// 'N/A'
var a: Numbro = numbro(1000);
var b: Numbro = numbro(a);
var c: Numbro = a.clone();
var aVal: number = a.set(2000).value();
// 2000
var bVal: number = b.value();
// 1000
var cVal: number = c.add(10).value();
// 1010
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for Numbro.js
// Project: https://github.com/foretagsplatsen/numbro
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface NumbroLanguage {
delimiters: {
thousands: string;
decimal: string;
};
abbreviations: {
thousand: string;
million: string;
billion: string;
trillion: string;
};
ordinal(num: number): string;
currency: {
symbol: string;
};
}
interface Numbro {
(value?: any): Numbro;
version: string;
isNumbro: boolean;
language(key: string, values?: NumbroLanguage): Numbro;
zeroFormat(format: string): string;
clone(): Numbro;
format(inputString?: string): string;
formatCurrency(inputString?: string): string;
unformat(inputString: string): number;
value(): number;
valueOf(): number;
set (value: any): Numbro;
add(value: any): Numbro;
subtract(value: any): Numbro;
multiply(value: any): Numbro;
divide(value: any): Numbro;
difference(value: any): number;
}
declare var numbro: Numbro;
declare module "numbro" {
export = numbro;
}
+2 -1
View File
@@ -27,7 +27,8 @@ interface Numeral {
language(key: string, values?: NumeralJSLanguage): Numeral;
zeroFormat(format: string): string;
clone(): Numeral;
format(inputString: string): string;
format(inputString?: string): string;
formatCurrency(inputString?: string): string;
unformat(inputString: string): number;
value(): number;
valueOf(): number;
+2
View File
@@ -150,6 +150,8 @@ var classicComponent: React.ClassicComponent<Props, any> =
React.render(classicElement, container);
var domComponent: React.DOMComponent<any> =
React.render(domElement, container);
var modernComponent =
React.render(React.createElement(ModernComponent, props), container);
// Other Top-Level API
var unmounted: boolean = React.unmountComponentAtNode(container);
+18
View File
@@ -0,0 +1,18 @@
/// <reference path="rivets.d.ts" />
Rivets.configure({
// Attribute prefix in templates
prefix: 'rv',
// Preload templates with initial data on bind
preloadData: true,
// Root sightglass interface for keypaths
rootInterface: '.',
// Template delimiters for text bindings
templateDelimiters: ['[[', ']]'],
// Augment the event handler of the on-* binder
handler: function(target:any, event:any, binding:any) {
this.call(target, event, binding.view.models)
}
})
var t = {test: ["hello", "one", "two"]}
Rivets.bind(document.getElementById("para1"), t)
+35
View File
@@ -0,0 +1,35 @@
// Type definitions for rivets
// Project: http://rivetsjs.com/
// Definitions by: Trevor Baron <https://github.com/TrevorDev>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface FinchStatic {
configure(options?: {
/**
* Attribute prefix in templates
*/
prefix?: string;
/**
* Preload templates with initial data on bind
*/
preloadData?: boolean;
/**
* Root sightglass interface for keypaths
*/
rootInterface?: string;
/**
* Template delimiters for text bindings
*/
templateDelimiters?: Array<string>
/**
* Augment the event handler of the on-* binder
*/
handler?: Function;
}):void;
bind(element:any, template:any):void;
}
declare var Rivets: FinchStatic;
declare module "rivets" {
export = Rivets;
}
+2
View File
@@ -589,6 +589,8 @@ declare module Rx {
merge<T>(scheduler: IScheduler, sources: Observable<T>[]): Observable<T>;
merge<T>(scheduler: IScheduler, sources: IPromise<T>[]): Observable<T>;
pairs<T>(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>;
zip<T1, T2, TResult>(first: Observable<T1>, sources: Observable<T2>[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable<TResult>;
zip<T1, T2, TResult>(first: Observable<T1>, sources: IPromise<T2>[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable<TResult>;
zip<T1, T2, TResult>(source1: Observable<T1>, source2: Observable<T2>, resultSelector: (item1: T1, item2: T2) => TResult): Observable<TResult>;
+26 -2
View File
@@ -76,6 +76,10 @@ interface Select2JQueryEventObject extends JQueryEventObject {
val: any;
added: any;
removed: any;
choice: {
id: any;
text: string;
};
}
interface JQuery {
@@ -84,6 +88,26 @@ interface JQuery {
on(events: "change", selector?: string, data?: any, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "change", selector?: string, handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "change", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-opening", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-open", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-close", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-highlight", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-selecting", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-removing", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-removed", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-loaded", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-focus", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-blur", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-opening", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-open", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-close", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-highlight", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-selecting", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-removing", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-removed", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-loaded", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-focus", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
on(events: "select2-blur", handler?: (eventObject: Select2JQueryEventObject) => any): JQuery;
select2(): JQuery;
select2(it: IdTextPair): JQuery;
@@ -141,9 +165,9 @@ interface JQuery {
/**
* Notifies Select2 that a drag and drop sorting operation has finished
*/
select2(method: 'onSortEnd'): JQuery;
select2(method: 'onSortEnd'): JQuery;
select2(method: string): any;
select2(method: string, value: any, trigger?: boolean): any;
select2(options: Select2Options): JQuery;
}
}
+1
View File
@@ -91,5 +91,6 @@ declare module SocketIO {
interface Client {
conn: any;
request: any;
id: string;
}
}
+4
View File
@@ -182,6 +182,10 @@ _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name');
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age');
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, ['name', 'age']);
_.mapObject({ a: 1, b: 2 }, val => val * 2) === _.mapObject({ a: 2, b: 4 }, _.identity);
_.mapObject({ a: 1, b: 2 }, (val, key, o) => o[key] * 2) === _.mapObject({ a: 2, b: 4}, _.identity);
_.mapObject({ x: "string 1", y: "string 2" }, 'length') === _.mapObject({ x: "string 1", y: "string 2"}, _.property('length'));
var iceCream = { flavor: "chocolate" };
_.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" });
+25
View File
@@ -1170,6 +1170,31 @@ interface UnderscoreStatic {
* @return List of all the values on `object`.
**/
values(object: any): any[];
/**
* Like map, but for objects. Transform the value of each property in turn.
* @param object The object to transform
* @param iteratee The function that transforms property values
* @param context The optional context (value of `this`) to bind to
* @return a new _.Dictionary of property values
*/
mapObject<T, U>(object: _.Dictionary<T>, iteratee: (val: T, key: string, object: _.Dictionary<T>) => U, context?: any): _.Dictionary<U>;
/**
* Like map, but for objects. Transform the value of each property in turn.
* @param object The object to transform
* @param iteratee The function that tranforms property values
* @param context The optional context (value of `this`) to bind to
*/
mapObject<T>(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary<T>;
/**
* Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property
* @param object The object to transform
* @param iteratee The property name to retrieve
* @param context The optional context (value of `this`) to bind to
*/
mapObject(object: any, iteratee: string, context?: any): _.Dictionary<any>;
/**
* Convert an object into a list of [key, value] pairs.
+26
View File
@@ -0,0 +1,26 @@
/// <reference path="./xlsx.d.ts" />
import xlsx = require('xlsx');
var options:xlsx.IParsingOptions = {
cellDates:true
};
var workbook = xlsx.readFile('test.xlsx', options);
var otherworkbook = xlsx.readFile('test.xlsx', {type: 'file'});
console.log(workbook.Props.Author);
var firstsheet:string = workbook.SheetNames[0];
var firstworksheet = workbook.Sheets[firstsheet];
console.log(firstworksheet["A1"]);
interface tester {
name:string;
age: number;
}
var jsonvalues:tester[] = xlsx.utils.sheet_to_json<tester>(firstworksheet);
var csv = xlsx.utils.sheet_to_csv(firstworksheet);
var formulae = xlsx.utils.sheet_to_formulae(firstworksheet);
+136
View File
@@ -0,0 +1,136 @@
// Type definitions for xlsx
// Project: https://github.com/SheetJS/js-xlsx
// Definitions by: themauveavenger <https://github.com/themauveavenger/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'xlsx' {
export function readFile(filename:string, opts?:IParsingOptions):IWorkBook;
export function read(data:any, opts?:IParsingOptions):IWorkBook;
export var utils:IUtils;
export interface IProperties {
LastAuthor?:string
Author?:string;
CreatedDate?:Date;
ModifiedDate?:Date
Application?:string;
AppVersion?:string;
Company?:string;
DocSecurity?:string;
Manager?:string;
HyperlinksChanged?: boolean;
SharedDoc?:boolean;
LinksUpToDate?:boolean;
ScaleCrop?:boolean;
Worksheets?:number;
SheetNames?:string[];
}
export interface IParsingOptions {
cellFormula?:boolean;
cellHTML?:boolean;
cellNF?:boolean;
cellStyles?:boolean;
cellDates?:boolean;
sheetStubs?:boolean;
sheetRows?:number;
bookDeps?:boolean;
bookFiles?:boolean;
bookProps?:boolean;
bookSheets?:boolean;
bookVBA?:boolean;
password?:string;
/**
* Possible options: 'binary', 'base64', 'buffer', 'file'
*/
type?:string;
}
export interface IWorkBook {
/**
* A dictionary of the worksheets in the workbook.
* Use SheetNames to reference these.
*/
Sheets:{[sheet:string]:IWorkSheet};
/**
* ordered list of the sheet names in the workbook
*/
SheetNames:string[];
/**
* an object storing the standard properties. wb.Custprops stores custom properties.
* Since the XLS standard properties deviate from the XLSX standard, XLS parsing stores core properties in both places.
*/
Props:IProperties;
}
/**
* object representing the worksheet
*/
export interface IWorkSheet {
[cell:string]:IWorkSheetCell;
}
export interface IWorkSheetCell {
/**
* The Excel Data Type of the cell.
* b Boolean, n Number, e error, s String, d Date
*/
t: string;
/**
* The raw value of the cell.
*/
v: string;
/**
* rich text encoding (if applicable)
*/
r?: string;
/**
* HTML rendering of the rich text (if applicable)
*/
h?: string;
/**
* formatted text (if applicable)
*/
w?: string;
/**
* cell formula (if applicable)
*/
f?: string;
/**
* comments associated with the cell **
*/
c?: string;
/**
* number format string associated with the cell (if requested)
*/
z?: string;
/**
* cell hyperlink object (.Target holds link, .tooltip is tooltip)
*/
l?: string;
/**
* the style/theme of the cell (if applicable)
*/
s?: string;
}
export interface IUtils {
sheet_to_json<T>(worksheet:IWorkSheet):T[];
sheet_to_csv(worksheet:IWorkSheet):any;
sheet_to_formulae(worksheet:IWorkSheet):any;
}
}
+2 -1
View File
@@ -150,10 +150,11 @@ declare module YT {
}
export enum PlayerState {
UNSTARTED,
BUFFERING,
CUED,
ENDED,
PAUSED,
PLAYING
}
}
}