From bd42d78b1beac7245c81683672bffd13c560aba3 Mon Sep 17 00:00:00 2001 From: Bret Little Date: Mon, 1 Apr 2013 21:21:19 -0600 Subject: [PATCH] Add lots of new blank files --- .idea/libraries/Generated_files.xml | 12 +- .idea/misc.xml | 49 -- .idea/workspace.xml | 398 ++++++++--- package.json | 2 + spec/AutoScopeSpec.js | 12 - spec/AutoScopeSpec.js.map | 1 - spec/AutoScopeSpec.ts | 18 - spec/file/FileUtilsSpec.ts | 32 + src/AutoScope.ts | 22 - src/CGClient.ts | 0 src/CGServer.ts | 0 src/Telescope.ts | 41 -- src/controller/Controller.ts | 0 src/controller/dome/Dome.ts | 0 src/controller/telescope/Telescope.ts | 0 src/controller/telescope/ccd/CCD.ts | 0 .../telescope/filterWheel/FilterWheel.ts | 0 src/controller/telescope/focuser/Focuser.ts | 0 src/controller/telescope/mount/Mount.ts | 0 .../weatherStation/WeatherStation.ts | 0 src/controller/webCamera/WebCamera.ts | 0 src/coordinates/CelestialObject.ts | 0 src/coordinates/Coordinates.ts | 0 src/coordinates/Dec.ts | 0 src/coordinates/RightAsc.ts | 0 src/coordinates/Spherical.ts | 0 src/file/File.ts | 0 src/file/FileUtils.ts | 51 ++ src/observation/Image.ts | 0 src/observation/Observation.ts | 0 src/observation/ObservationRun.ts | 0 src/observatoroy/Observatory.ts | 0 src/permissions/org.ts | 0 src/permissions/user.ts | 0 temp.out | 2 + typescript-def/jasmine.d.ts | 2 +- typescript-def/node.d.ts | 1 + typescript-def/numeraljs.d.ts | 42 ++ typescript-def/underscore.d.ts | 673 ++++++++++++++++++ typescript-def/underscore.string.d.ts | 67 ++ 40 files changed, 1194 insertions(+), 231 deletions(-) delete mode 100644 spec/AutoScopeSpec.js delete mode 100644 spec/AutoScopeSpec.js.map delete mode 100644 spec/AutoScopeSpec.ts create mode 100644 spec/file/FileUtilsSpec.ts delete mode 100644 src/AutoScope.ts create mode 100644 src/CGClient.ts create mode 100644 src/CGServer.ts delete mode 100644 src/Telescope.ts create mode 100644 src/controller/Controller.ts create mode 100644 src/controller/dome/Dome.ts create mode 100644 src/controller/telescope/Telescope.ts create mode 100644 src/controller/telescope/ccd/CCD.ts create mode 100644 src/controller/telescope/filterWheel/FilterWheel.ts create mode 100644 src/controller/telescope/focuser/Focuser.ts create mode 100644 src/controller/telescope/mount/Mount.ts create mode 100644 src/controller/weatherStation/WeatherStation.ts create mode 100644 src/controller/webCamera/WebCamera.ts create mode 100644 src/coordinates/CelestialObject.ts create mode 100644 src/coordinates/Coordinates.ts create mode 100644 src/coordinates/Dec.ts create mode 100644 src/coordinates/RightAsc.ts create mode 100644 src/coordinates/Spherical.ts create mode 100644 src/file/File.ts create mode 100644 src/file/FileUtils.ts create mode 100644 src/observation/Image.ts create mode 100644 src/observation/Observation.ts create mode 100644 src/observation/ObservationRun.ts create mode 100644 src/observatoroy/Observatory.ts create mode 100644 src/permissions/org.ts create mode 100644 src/permissions/user.ts create mode 100644 temp.out create mode 100644 typescript-def/numeraljs.d.ts create mode 100644 typescript-def/underscore.d.ts create mode 100644 typescript-def/underscore.string.d.ts diff --git a/.idea/libraries/Generated_files.xml b/.idea/libraries/Generated_files.xml index 7d11121..f2d3451 100644 --- a/.idea/libraries/Generated_files.xml +++ b/.idea/libraries/Generated_files.xml @@ -2,15 +2,21 @@ + + - - + - + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 27d5203..dd02dd5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,54 +4,5 @@ - - - - - - - - - - - - - - - - - - - 1.6 - - - - - - - - - - - - - - diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 193cdee..36ec573 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,40 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - @@ -26,8 +53,12 @@ - + + + + + - - + + - - + + + + - - + + - + - - + + - - + + + + - - + + - + - - + + - - + + + + + - - + + + + + + + + + + + + + @@ -142,28 +191,30 @@ - - + + - + - - + + - - + + + + - - + + - + @@ -187,20 +238,42 @@ + + + + + + + + + + + Abstraction issues + + + + @@ -209,7 +282,7 @@ - + @@ -247,6 +320,34 @@ diff --git a/package.json b/package.json index b0cf7d9..3b4fbe9 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "description": "Bootstrap template for typescript projects", "author": "Bret Little", "dependencies": { + "numeral": "latest", + "underscore": "latest" }, "devDependencies": { "jasmine-node": "latest", diff --git a/spec/AutoScopeSpec.js b/spec/AutoScopeSpec.js deleted file mode 100644 index b453043..0000000 --- a/spec/AutoScopeSpec.js +++ /dev/null @@ -1,12 +0,0 @@ -var AutoScope = require("../src/AutoScope") -describe("AutoScope", function () { - var telescope; - beforeEach(function () { - telescope = new AutoScope.AutoScope(); - }); - it("The telescope should turn on", function () { - telescope.start(); - expect(telescope.isOn()).toBeTruthy(); - }); -}); -//@ sourceMappingURL=AutoScopeSpec.js.map diff --git a/spec/AutoScopeSpec.js.map b/spec/AutoScopeSpec.js.map deleted file mode 100644 index 217cacf..0000000 --- a/spec/AutoScopeSpec.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"AutoScopeSpec.js","sources":["AutoScopeSpec.ts"],"names":["","",""],"mappings":"AAAA,gBAE0B,2BAAkB;AAE5C,QAAQ,CAAC,WAAW,EAAE;IAElBA,IAAIA,SAASA,CAACA;IAEdA,UAAUA,CAACA;QACPC,SAASA,GAAGA,IAAIA,SAASA,CAACA,SAASA,EAAEA;IACzCA,CAACA,CAACD;IAEFA,EAAEA,CAACA,8BAA8BA,EAAEA;QAC/BE,SAASA,CAACA,KAAKA,EAAEA;QACjBA,MAAMA,CAACA,SAASA,CAACA,IAAIA,EAAEA,CAACA,CAACA,UAAUA,EAAEA;IACzCA,CAACA,CAACF;AAENA,CAACA,CAAC;AAAC"} \ No newline at end of file diff --git a/spec/AutoScopeSpec.ts b/spec/AutoScopeSpec.ts deleted file mode 100644 index 6e90821..0000000 --- a/spec/AutoScopeSpec.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -import AutoScope = module("../src/AutoScope"); - -describe("AutoScope", () => { - - var telescope; - - beforeEach(() => { - telescope = new AutoScope.AutoScope(); - }); - - it("The telescope should turn on", () => { - telescope.start(); - expect(telescope.isOn()).toBeTruthy(); - }); - -}); \ No newline at end of file diff --git a/spec/file/FileUtilsSpec.ts b/spec/file/FileUtilsSpec.ts new file mode 100644 index 0000000..7acfea1 --- /dev/null +++ b/spec/file/FileUtilsSpec.ts @@ -0,0 +1,32 @@ +/// + +import FileUtils = module("../../src/file/FileUtils"); + +describe("File Utils", () => { + + var tempPath = "temp.out", + data = [ + ["some value", "2", "3", 4], + ["test", "3", "dsf"] + ]; + + it("Should write a csv file", () => { + FileUtils.FileUtils.writeCSV(data, tempPath, (err) => { + expect(err).toBeNull(); + }); + }); + + it("Should read a csv file", (done) => { + FileUtils.FileUtils.writeCSV(data, tempPath, () => { + FileUtils.FileUtils.readCSV("temp.out", (err, readObject) => { + expect(readObject).toBeDefined(); + expect(readObject.length).toEqual(2); + expect(readObject[0][2]).toEqual("3"); + expect(readObject[0][3]).toEqual('4'); + expect(readObject[1][2]).toEqual("dsf"); + done(); + }); + }); + }); + +}); \ No newline at end of file diff --git a/src/AutoScope.ts b/src/AutoScope.ts deleted file mode 100644 index fdb32dc..0000000 --- a/src/AutoScope.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Telescope = module('Telescope'); - -export class AutoScope extends Telescope.Telescope { - - constructor(public name: string = "AutoScope Telescope") { - super(name); - } - - start(): AutoScope { - - this.bootup(); - - super.start(); - - return this; - } - - private bootup() { - //Do some work to start the Autoscope telescope - } - -} \ No newline at end of file diff --git a/src/CGClient.ts b/src/CGClient.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/CGServer.ts b/src/CGServer.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/Telescope.ts b/src/Telescope.ts deleted file mode 100644 index 9c08ab6..0000000 --- a/src/Telescope.ts +++ /dev/null @@ -1,41 +0,0 @@ -export interface TelescopeInterface { - start(): TelescopeInterface; - stop(): TelescopeInterface; - isOn(): bool; -} - -export class Telescope implements TelescopeInterface { - - private on: bool; - - constructor(public name: string) { - - } - - start(): Telescope { - this.on = true; - return this; - } - - stop(): Telescope { - this.on = false; - return this; - } - - isOn(): bool { - return this.on; - } - - public static getZenith(date?: Date) : Object { - date = date || new Date(); - return { - declination: Telescope.getCoord(date) - } - } - - private static getCoord(date: Date): number { - return date.getTime(); - } - -} - diff --git a/src/controller/Controller.ts b/src/controller/Controller.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/dome/Dome.ts b/src/controller/dome/Dome.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/telescope/Telescope.ts b/src/controller/telescope/Telescope.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/telescope/ccd/CCD.ts b/src/controller/telescope/ccd/CCD.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/telescope/filterWheel/FilterWheel.ts b/src/controller/telescope/filterWheel/FilterWheel.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/telescope/focuser/Focuser.ts b/src/controller/telescope/focuser/Focuser.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/telescope/mount/Mount.ts b/src/controller/telescope/mount/Mount.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/weatherStation/WeatherStation.ts b/src/controller/weatherStation/WeatherStation.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/controller/webCamera/WebCamera.ts b/src/controller/webCamera/WebCamera.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/coordinates/CelestialObject.ts b/src/coordinates/CelestialObject.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/coordinates/Coordinates.ts b/src/coordinates/Coordinates.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/coordinates/Dec.ts b/src/coordinates/Dec.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/coordinates/RightAsc.ts b/src/coordinates/RightAsc.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/coordinates/Spherical.ts b/src/coordinates/Spherical.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/file/File.ts b/src/file/File.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/file/FileUtils.ts b/src/file/FileUtils.ts new file mode 100644 index 0000000..dab31c9 --- /dev/null +++ b/src/file/FileUtils.ts @@ -0,0 +1,51 @@ +/// +/// + +import fs = module("fs"); +import _ = module("underscore"); + +export class FileUtils { + + /** + * Write an object to a csv file. + * @param obj - A double array, each outer array represents a line in the output csv. Each element of the sub-array + * represents an element in each line of the output csv. + * @param filePath + * @param callback + */ + public static writeCSV(obj: any, filePath: string, callback ?: Function): void { + + var outputString = ""; + + _.each(obj, function(line, i) { + if(i !== 0) outputString += "\r\n"; + + _.each(line, function(el, i) { + outputString += i === 0 ? el : "," + el; + }); + }); + + fs.writeFile(filePath, outputString, callback); + } + + public static readCSV(filePath: string, callback ?: Function): void { + fs.readFile(filePath, (err, data) => { + var lines; + + if(err) callback(err); + + lines = (data+"").split("\r\n"); + + _.each(lines, (line, i) => { + lines[i] = (line+"").split(","); + }); + + callback(null, lines); + + }); + } + + public static writeJSON(obj: Object, filePath: string): void { + + } +} \ No newline at end of file diff --git a/src/observation/Image.ts b/src/observation/Image.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/observation/Observation.ts b/src/observation/Observation.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/observation/ObservationRun.ts b/src/observation/ObservationRun.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/observatoroy/Observatory.ts b/src/observatoroy/Observatory.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/permissions/org.ts b/src/permissions/org.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/permissions/user.ts b/src/permissions/user.ts new file mode 100644 index 0000000..e69de29 diff --git a/temp.out b/temp.out new file mode 100644 index 0000000..8b2a643 --- /dev/null +++ b/temp.out @@ -0,0 +1,2 @@ +some value,2,3,4 +test,3,dsf \ No newline at end of file diff --git a/typescript-def/jasmine.d.ts b/typescript-def/jasmine.d.ts index b676a4f..594a319 100644 --- a/typescript-def/jasmine.d.ts +++ b/typescript-def/jasmine.d.ts @@ -4,7 +4,7 @@ declare function describe(description : string, specDefinitions : () => void ): void; declare function xdescribe(description : string, specDefinitions : () => void ): void; -declare function it(description : string, func : () => void ): void; +declare function it(description : string, func : (done ?: () => void ) => void ): void; declare function xit(description : string, func : () => void ): void; declare function expect(actual: any): jasmine.Matchers; declare function beforeEach(afterEachFunction:() => void ): void; diff --git a/typescript-def/node.d.ts b/typescript-def/node.d.ts index c3f725c..037599d 100644 --- a/typescript-def/node.d.ts +++ b/typescript-def/node.d.ts @@ -787,6 +787,7 @@ import stream = module("stream"); export function readFileSync(filename: string): NodeBuffer; export function readFileSync(filename: string, encoding: string): string; export function writeFile(filename: string, data: any, encoding?: string, callback?: Function): void; + export function writeFile(filename: string, data: any, callback?: Function): void; export function writeFileSync(filename: string, data: any, encoding?: string): void; export function appendFile(filename: string, data: any, encoding?: string, callback?: Function): void; export function appendFileSync(filename: string, data: any, encoding?: string): void; diff --git a/typescript-def/numeraljs.d.ts b/typescript-def/numeraljs.d.ts new file mode 100644 index 0000000..1f2c564 --- /dev/null +++ b/typescript-def/numeraljs.d.ts @@ -0,0 +1,42 @@ +// Type definitions for Numeral.js +// Project: https://github.com/adamwdraper/Numeral-js +// Definitions by: Vincent Bortone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface NumeralJSLanguage { + delimiters: { + thousands: string; + decimal: string; + }; + abbreviations: { + thousand: string; + million: string; + billion: string; + trillion: string; + }; + ordinal(num: number): string; + currency: { + symbol: string; + }; +} + +interface Numeral { + (value?: any): Numeral; + version: string; + isNumeral: bool; + language(key: string, values?: NumeralJSLanguage): Numeral; + zeroFormat(format: string): string; + clone(): Numeral; + format(inputString: string): string; + unformat(inputString: string): number; + value(): number; + valueOf(): number; + set (value: any): Numeral; + add(value: any): Numeral; + subtract(value: any): Numeral; + multiply(value: any): Numeral; + divide(value: any): Numeral; + difference(value: any): number; +} + +declare var numeral: Numeral; \ No newline at end of file diff --git a/typescript-def/underscore.d.ts b/typescript-def/underscore.d.ts new file mode 100644 index 0000000..30633be --- /dev/null +++ b/typescript-def/underscore.d.ts @@ -0,0 +1,673 @@ +/* + Typescipt Underscore 1.4.2-0.9 + (c) 2012 Ãlvaro Vilanova Vidal + Typescipt-Underscore may be freely distributed under the MIT license. + */ + +declare interface UnderscoreVoidListIterator { + (element : any, index : number, list : any[]) : void; +} + +declare interface UnderscoreMemoListIterator { + (memo : any, element : any, index : number, list : any[]) : any; +} + +declare interface UnderscoreListIterator { + (element : any, index : number, list : any[]) : any; +} + +declare interface UnderscoreVoidObjectIterator { + (element : any, key : any, object : any) : void; +} + +declare interface UnderscoreMemoObjectIterator { + (memo : any, element : any, key : any, object : any) : any; +} + +declare interface UnderscoreObjectIterator{ + (element : any, key : any, object : any) : any; +} + +declare interface UnderscorePredicate { + (value : any) : bool; +} + +declare interface UnderscoreIterator { + (value : any) : any; +} + +declare interface UnderscoreTemplateSettings { + evaluate? : RegExp; + interpolate? : RegExp; + escape? : RegExp; +} + +/* Interface for use underscore in functional (chain) style. + range, bindAll, dealy, defer, after, noConflict, times, random, mixin, + uniqueId, chain and template have been removed because they are not very + useful here. + */ +declare interface UnderscoreWrappedObject { + // Collection Functions (Arrays or Objects) + each (iterator : UnderscoreVoidListIterator, context? : any) : UnderscoreWrappedObject; + each (iterator : UnderscoreVoidObjectIterator, context? : any) : UnderscoreWrappedObject; + forEach (iterator : UnderscoreVoidListIterator, context? : any) : UnderscoreWrappedObject; + forEach (iterator : UnderscoreVoidObjectIterator, context? : any) : UnderscoreWrappedObject; + + map (iterator : UnderscoreListIterator, context? : any) : UnderscoreWrappedObject; + map (iterator : UnderscoreObjectIterator, context? : any) : UnderscoreWrappedObject; + collect (iterator : UnderscoreListIterator, context? : any) : UnderscoreWrappedObject; + collect (iterator : UnderscoreObjectIterator, context? : any) : UnderscoreWrappedObject; + + reduce (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : UnderscoreWrappedObject; + reduce (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : UnderscoreWrappedObject; + inject (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : UnderscoreWrappedObject; + inject (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : UnderscoreWrappedObject; + foldl (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : UnderscoreWrappedObject; + foldl (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : UnderscoreWrappedObject; + + reduceRight (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : UnderscoreWrappedObject; + reduceRight (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : UnderscoreWrappedObject; + foldr (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : UnderscoreWrappedObject; + foldr (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : UnderscoreWrappedObject; + + find (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + detect (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + + filter (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + select (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + + where (properties : any) : UnderscoreWrappedObject; + + reject (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + + all (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + every (predicate : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + + any (predicate? : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + some (predicate? : UnderscorePredicate, context? : any) : UnderscoreWrappedObject; + + contains (value : any) : UnderscoreWrappedObject; + include (value : any) : UnderscoreWrappedObject; + + invoke (methodName : string, ...arguments: any[]) : UnderscoreWrappedObject; + + pluck (propertyName : string) : UnderscoreWrappedObject; + + max (iterator? : UnderscoreIterator, context? : any) : UnderscoreWrappedObject; + + min (iterator? : UnderscoreIterator, context? : any) : UnderscoreWrappedObject; + + sortBy (property? : string, context? : any) : UnderscoreWrappedObject; + sortBy (iterator? : UnderscoreIterator, context? : any) : UnderscoreWrappedObject; + + groupBy (property : string) : UnderscoreWrappedObject; + groupBy (iterator : UnderscoreIterator) : UnderscoreWrappedObject; + + countBy (property : string) : UnderscoreWrappedObject; + countBy (iterator : UnderscoreIterator) : UnderscoreWrappedObject; + + shuffle () : UnderscoreWrappedObject; + + toArray () : UnderscoreWrappedObject; + + size () : UnderscoreWrappedObject; + + + // Array Functions + first (n? : number) : UnderscoreWrappedObject; + head (n? : number) : UnderscoreWrappedObject; + take (n? : number) : UnderscoreWrappedObject; + + initial (n? : number) : UnderscoreWrappedObject; + + last (n? : number) : UnderscoreWrappedObject; + + rest (index? : number) : UnderscoreWrappedObject; + tail (index? : number) : UnderscoreWrappedObject; + drop (index? : number) : UnderscoreWrappedObject; + + compact () : UnderscoreWrappedObject; + + flatten (shallow? : bool) : UnderscoreWrappedObject; + + without (...values : any[]) : UnderscoreWrappedObject; + + union (...arrays : any[][]) : UnderscoreWrappedObject; + + intersection (...arrays : any[][]) : UnderscoreWrappedObject; + + difference (...arrays : any[][]) : UnderscoreWrappedObject; + + uniq (isSorted? : bool, UnderscoreIterator? : UnderscoreIterator) : UnderscoreWrappedObject; + unique (isSorted? : bool, UnderscoreIterator? : UnderscoreIterator) : UnderscoreWrappedObject; + + zip (...arrays : any[][]) : UnderscoreWrappedObject; + + object (value? : any) : UnderscoreWrappedObject; + + indexOf (value : any, isSorted? : bool) : UnderscoreWrappedObject; + + lastIndexOf (value : any, fromIndex? : number) : UnderscoreWrappedObject; + + sortedIndex (value : any, UnderscoreIterator? : UnderscoreIterator) : UnderscoreWrappedObject; + + + // Function (uh, ahem) Functions + bind (object : any, ...arguments : any[]) : UnderscoreWrappedObject; + + memoize (hashFunction? : (value : any) => any) : UnderscoreWrappedObject; + + delay ( wait : number, ...arguments : any[]) : UnderscoreWrappedObject; + + defer (...arguments : any[]) : UnderscoreWrappedObject; + + throttle (wait : number) : UnderscoreWrappedObject; + + debounce (wait : number, immediate? : bool) : UnderscoreWrappedObject; + + once () : UnderscoreWrappedObject; + + after (fn : (...args : any[]) => any) : UnderscoreWrappedObject; + + wrap (wrapper : (...args : any[]) => any) : UnderscoreWrappedObject; + + compose (...fns : Function[]) : UnderscoreWrappedObject; + + + // Object Functions + keys () : UnderscoreWrappedObject; + + values () : UnderscoreWrappedObject; + + pairs () : UnderscoreWrappedObject; + + invert () : UnderscoreWrappedObject; + + functions () : UnderscoreWrappedObject; + methods () : UnderscoreWrappedObject; + + extend (...sources : any[]) : UnderscoreWrappedObject; + + pick (...keys : string[]) : UnderscoreWrappedObject; + + omit (...keys : string[]) : UnderscoreWrappedObject; + + defaults (...defaults : any[]) : UnderscoreWrappedObject; + + clone () : UnderscoreWrappedObject; + + tap (interceptor : (...as : any[]) => any) : UnderscoreWrappedObject; + + has (key : any) : UnderscoreWrappedObject; + + isEqual (other : any) : UnderscoreWrappedObject; + + isEmpty () : UnderscoreWrappedObject; + + isElement () : UnderscoreWrappedObject; + + isArray () : UnderscoreWrappedObject; + + isObject () : UnderscoreWrappedObject; + + isArguments () : UnderscoreWrappedObject; + + isFunction () : UnderscoreWrappedObject; + + isString () : UnderscoreWrappedObject; + + isNumber () : UnderscoreWrappedObject; + + isFinite () : UnderscoreWrappedObject; + + isBoolean () : UnderscoreWrappedObject; + + isDate () : UnderscoreWrappedObject; + + isRegExp () : UnderscoreWrappedObject; + + isNaN () : UnderscoreWrappedObject; + + isNull () : UnderscoreWrappedObject; + + isUndefined () : UnderscoreWrappedObject; + + + // Utility Functions + identity () : UnderscoreWrappedObject; + + escape () : UnderscoreWrappedObject; + + result (property : string) : UnderscoreWrappedObject; + + template (data? : any, settings? : any) : (...as : any[]) => UnderscoreWrappedObject; + + value () : any; +} + +/* Interface that enables the use of underscore in a OO Style. + range, bindAll, dealy, defer, after, noConflict, times, random, mixin and + uniqueId have been removed because they are not very useful here. + */ +declare interface UnderscoreOOStatic { + // Collection Functions (Arrays or Objects) + each (iterator : UnderscoreVoidListIterator, context? : any) : void; + each (iterator : UnderscoreVoidObjectIterator, context? : any) : void; + forEach (iterator : UnderscoreVoidListIterator, context? : any) : void; + forEach (iterator : UnderscoreVoidObjectIterator, context? : any) : void; + + map (iterator : UnderscoreListIterator, context? : any) : any[]; + map (iterator : UnderscoreObjectIterator, context? : any) : any[]; + collect (iterator : UnderscoreListIterator, context? : any) : any[]; + collect (iterator : UnderscoreObjectIterator, context? : any) : any[]; + + reduce (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + reduce (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + inject (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + inject (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + foldl (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + foldl (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + + reduceRight (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + reduceRight (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + foldr (iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + foldr (iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + + find (predicate : UnderscorePredicate, context? : any) : any; + detect (predicate : UnderscorePredicate, context? : any) : any; + + filter (predicate : UnderscorePredicate, context? : any) : any; + select (predicate : UnderscorePredicate, context? : any) : any; + + where (properties : any) : any; + + reject (predicate : UnderscorePredicate, context? : any) : any; + + all (predicate : UnderscorePredicate, context? : any) : any; + every (predicate : UnderscorePredicate, context? : any) : any; + + any (predicate? : UnderscorePredicate, context? : any) : any; + some (predicate? : UnderscorePredicate, context? : any) : any; + + contains (value : any) : bool; + include (value : any) : bool; + + invoke (methodName : string, ...arguments: any[]) : any; + + pluck (propertyName : string) : any; + + max (iterator? : UnderscoreIterator, context? : any) : any; + + min (iterator? : UnderscoreIterator, context? : any) : any; + + sortBy (property? : string, context? : any) : any; + sortBy (iterator? : UnderscoreIterator, context? : any) : any; + + groupBy (property : string) : any; + groupBy (iterator : UnderscoreIterator) : any; + + countBy (property : string) : any; + countBy (iterator : UnderscoreIterator) : any; + + shuffle () : any; + + toArray () : any[]; + + size () : number; + + + // Array Functions + first (n? : number) : any; + head (n? : number) : any; + take (n? : number) : any; + + initial (n? : number) : any[]; + + last (n? : number) : any; + + rest (index? : number) : any[]; + tail (index? : number) : any[]; + drop (index? : number) : any[]; + + compact () : any[]; + + flatten (shallow? : bool) : any[]; + + without (...values : any[]) : any[]; + + union (...arrays : any[][]) : any[]; + + intersection (...arrays : any[][]) : any[]; + + difference (...arrays : any[][]) : any[]; + + uniq (isSorted? : bool, UnderscoreIterator? : UnderscoreIterator) : any[]; + unique (isSorted? : bool, UnderscoreIterator? : UnderscoreIterator) : any[]; + + zip (...arrays : any[][]) : any[]; + + object (value? : any) : any; + + indexOf (value : any, isSorted? : bool) : number; + + lastIndexOf (value : any, fromIndex? : number) : number; + + sortedIndex (value : any, UnderscoreIterator? : UnderscoreIterator) : any; + + + // Function (uh, ahem) Functions + bind (object : any, ...arguments : any[]) : (...args : any[]) => any; + + memoize (hashFunction? : (value : any) => any) : (...args : any[]) => any; + + delay ( wait : number, ...arguments : any[]) : void; + + defer (...arguments : any[]) : void; + + throttle (wait : number) : (...args : any[]) => any; + + debounce (wait : number, immediate? : bool) : (...args : any[]) => any; + + once () : (...args : any[]) => any; + + after (fn : (...args : any[]) => any) : (...args : any[]) => any; + + wrap (wrapper : (...args : any[]) => any) : (...args : any[]) => any; + + compose (...fns : Function[]) : (...args : any[]) => any; + + + // Object Functions + keys () : string[]; + + values () : any[]; + + pairs () : any[]; + + invert () : any; + + functions () : string[]; + methods () : string[]; + + extend (...sources : any[]) : any; + + pick (...keys : string[]) : any; + + omit (...keys : string[]) : any; + + defaults (...defaults : any[]) : any; + + clone () : any; + + tap (interceptor : (...as : any[]) => any) : any; + + has (key : any) : bool; + + isEqual (other : any) : bool; + + isEmpty () : bool; + + isElement () : bool; + + isArray () : bool; + + isObject () : bool; + + isArguments () : bool; + + isFunction () : bool; + + isString () : bool; + + isNumber () : bool; + + isFinite () : bool; + + isBoolean () : bool; + + isDate () : bool; + + isRegExp () : bool; + + isNaN () : bool; + + isNull () : bool; + + isUndefined () : bool; + + + // Utility Functions + identity () : any; + + escape () : string; + + result (property : string) : any; + + template (data? : any, settings? : UnderscoreTemplateSettings) : (...as : any[]) => string; + + chain () : UnderscoreWrappedObject; +} + +declare module "underscore" { + // OO-style + export function (arg : any) : UnderscoreOOStatic; + + // Collection Functions (Arrays or Objects) + export function each (list : any[], iterator : UnderscoreVoidListIterator, context? : any) : void; + export function each (object : any, iterator : UnderscoreVoidObjectIterator, context? : any) : void; + export function forEach (list : any[], iterator : UnderscoreVoidListIterator, context? : any) : void; + export function forEach (object : any, iterator : UnderscoreVoidObjectIterator, context? : any) : void; + + export function map (list : any[], iterator : UnderscoreListIterator, context? : any) : any[]; + export function map (object : any, iterator : UnderscoreObjectIterator, context? : any) : any[]; + export function collect (list : any[], iterator : UnderscoreListIterator, context? : any) : any[]; + export function collect (object : any, iterator : UnderscoreObjectIterator, context? : any) : any[]; + + + export function reduce (list : any[], iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + export function reduce (list : any, iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + export function inject (list : any[], iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + export function inject (list : any, iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + export function foldl (list : any[], iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + export function foldl (list : any, iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + + + export function reduceRight (list : any[], iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + export function reduceRight (list : any, iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + export function foldr (list : any[], iterator : UnderscoreMemoListIterator, memo : any, context? : any) : any; + export function foldr (list : any, iterator : UnderscoreMemoObjectIterator, memo : any, context? : any) : any; + + export function find (list : any, predicate : UnderscorePredicate, context? : any) : any; + export function detect (list : any, predicate : UnderscorePredicate, context? : any) : any; + + export function filter (list : any, predicate : UnderscorePredicate, context? : any) : any; + export function select (list : any, predicate : UnderscorePredicate, context? : any) : any; + + export function where (list : any, properties : any) : any; + + export function reject (list : any, predicate : UnderscorePredicate, context? : any) : any; + + export function all (list : any, predicate : UnderscorePredicate, context? : any) : any; + export function every (list : any, predicate : UnderscorePredicate, context? : any) : any; + + export function any (list : any, predicate? : UnderscorePredicate, context? : any) : any; + export function some (list : any, predicate? : UnderscorePredicate, context? : any) : any; + + export function contains (list : any, value : any) : bool; + export function include (list : any, value : any) : bool; + + export function invoke (list : any, methodName : string, ...arguments: any[]) : any; + + export function pluck (list : any, propertyName : string) : any; + + export function max (list : any, UnderscoreIterator? : UnderscoreIterator, context? : any) : any; + + export function min (list : any, UnderscoreIterator? : UnderscoreIterator, context? : any) : any; + + export function sortBy (list : any, property? : string, context? : any) : any; + export function sortBy (list : any, UnderscoreIterator? : UnderscoreIterator, context? : any) : any; + + export function groupBy (list : any, property : string) : any; + export function groupBy (list : any, iterator : UnderscoreIterator) : any; + + export function countBy (list : any, iterator : UnderscoreIterator) : any; + + export function shuffle (list : any) : any; + + export function toArray (list : any) : any[]; + + export function size (list : any) : number; + + + // Array Functions + + export function first (array : any[], n? : number) : any; + export function head (array : any[], n? : number) : any; + export function take (array : any[], n? : number) : any; + + export function initial (array : any[], n? : number) : any[]; + + export function last (array : any[], n? : number) : any; + + export function rest (array : any[], index? : number) : any[]; + export function tail (array : any[], index? : number) : any[]; + export function drop (array : any[], index? : number) : any[]; + + export function compact (array : any[]) : any[]; + + export function flatten (array : any[], shallow? : bool) : any[]; + + export function without (array : any[], ...values : any[]) : any[]; + + export function union (...arrays : any[][]) : any[]; + + export function intersection (...arrays : any[][]) : any[]; + + export function difference (...arrays : any[][]) : any[]; + + export function uniq (array : any[], isSorted? : bool, UnderscoreIterator? : UnderscoreIterator) : any[]; + export function unique (array : any[], isSorted? : bool, UnderscoreIterator? : UnderscoreIterator) : any[]; + + export function zip (...arrays : any[][]) : any[]; + + export function object (list : any, value? : any) : any; + + export function indexOf (array : any[], value : any, isSorted? : bool) : number; + + export function lastIndexOf (array : any[], value : any, fromIndex? : number) : number; + + export function sortedIndex (list : any, value : any, UnderscoreIterator? : UnderscoreIterator) : any; + + export function range (stop : number) : number[]; + export function range (start: number, stop : number, step? : number) : number[]; + + + // Function (uh, ahem) Functions + + export function bind (fn : (...args : any[]) => any, object : any, ...arguments : any[]) : (...args : any[]) => any; + + export function bindAll (object : any, ...methodNames : string[]) : void; + + export function memoize (fn : (...args : any[]) => any, hashFunction? : (value : any) => any) : (...args : any[]) => any; + + export function delay (fn : (...args : any[]) => any, wait : number, ...arguments : any[]) : void; + + export function defer (fn : (...args : any[]) => any, ...arguments : any[]) : void; + + export function throttle (fn : (...args : any[]) => any, wait : number) : (...args : any[]) => any; + + export function debounce (fn : (...args : any[]) => any, wait : number, immediate? : bool) : (...args : any[]) => any; + + export function once (fn : (...args : any[]) => any) : (...args : any[]) => any; + + export function after (count : number, fn : (...args : any[]) => any) : (...args : any[]) => any; + + export function wrap (fn : (...args : any[]) => any, wrapper : (...args : any[]) => any) : (...args : any[]) => any; + + export function compose (...fns : Function[]) : (...args : any[]) => any; + + + // Object Functions + + export function keys (object : any) : string[]; + + export function values (object : any) : any[]; + + export function pairs (object : any) : any[]; + + export function invert (object : any) : any; + + export function functions (object : any) : string[]; + export function methods (object : any) : string[]; + + export function extend (destination : any, ...sources : any[]) : any; + + export function pick (object : any, ...keys : string[]) : any; + + export function omit (object : any, ...keys : string[]) : any; + + export function defaults (object : any, ...defaults : any[]) : any; + + export function clone (object : any) : any; + + export function tap (object : any, interceptor : (...as : any[]) => any) : any; + + export function has (object : any, key : any) : bool; + + export function isEqual (object : any, other : any) : bool; + + export function isEmpty (object : any) : bool; + + export function isElement (object : any) : bool; + + export function isArray (object : any) : bool; + + export function isObject (value : any) : bool; + + export function isArguments (object : any) : bool; + + export function isFunction (object : any) : bool; + + export function isString (object : any) : bool; + + export function isNumber (object : any) : bool; + + export function isFinite (object : any) : bool; + + export function isBoolean (object : any) : bool; + + export function isDate (object : any) : bool; + + export function isRegExp (object : any) : bool; + + export function isNaN (object : any) : bool; + + export function isNull (object : any) : bool; + + export function isUndefined (object : any) : bool; + + + // Utility Functions + + export function noConflict () : any; + + export function identity (value : any) : any; + + export function times (n : number, iterator : (index : number) => void, context? : any) : void; + + export function random (min : number, max : number) : number; + + export function mixin (object : any) : void; + + export function uniqueId (prefix? : string) : any; + + export function escape (str : string) : string; + + export function result (object : any, property : string) : any; + + export function template (templateString : string, data? : any, settings? : UnderscoreTemplateSettings) : (...as : any[]) => string; + export var templateSettings : UnderscoreTemplateSettings; + + export function chain (object : any) : UnderscoreWrappedObject; +} diff --git a/typescript-def/underscore.string.d.ts b/typescript-def/underscore.string.d.ts new file mode 100644 index 0000000..f5aea5a --- /dev/null +++ b/typescript-def/underscore.string.d.ts @@ -0,0 +1,67 @@ +// https://github.com/epeli/underscore.string + +// types grabbed from: https://github.com/alvivi/typescript-underscore-string + +/* + Typescipt Underscore.String 2.3.0-0.1 + (c) 2012 Álvaro Vilanova Vidal + Typescipt-Underscore-String may be freely distributed under the MIT license. + */ +declare module "underscore.string" { + export function numberFormat (n : number, decimals? : number, decimalSeparator? : string, orderSeparator? : string) : string; + export function levenshtein (str1 : string, str2 : string) : number; + export function capitalize (str : string) : string; + export function chop (str : string, step : number) : string[]; + export function clean (str : string) : string; + export function chars (str : string) : string[]; + export function swapCase (str : string) : string; + export function include (str : string, substr : string) : bool; + export function count (str : string, substr : string) : number; + export function escapeHTML (str : string) : string; + export function unescapeHTML (str : string) : string; + export function insert (str : string, index : number, substr : string) : string; + export function isBlank (str : string) : bool; + export function join (separator : string, ...strs : string[]) : string; + export function lines (str : string) : string[]; + export function reverse (str : string) : string; + export function splice (str : string, index : number, howmany : number, substr : string) : string; + export function startsWith (str : string, starts : string) : bool; + export function endsWith (str : string, ends : string) : bool; + export function succ (str : string) : string; + export function titleize (str : string) : string; + export function camelize (str : string) : string; + export function classify (str : string) : string; + export function underscored (str : string) : string; + export function dasherize (str : string) : string; + export function humanize (str : string) : string; + export function trim (str : string, characters? : string) : string; + export function strip (str : string, characters? : string) : string; + export function ltrim (str : string, characters? : string) : string; + export function lstrip (str : string, characters? : string) : string; + export function rtrim (str : string, characters? : string) : string; + export function rstrip (str : string, characters? : string) : string; + export function truncate (str : string, length : number, truncateString? : string) : string; + export function prune (str : string, length : number, pruneString? : string) : string; + export function words (str : string, delimiter : RegExp) : string[]; + export function sprintf (format : string, ...args : any[]) : string; + export function pad (str : string, length : number, padStr? : string, type? : string) : string; + export function lpad (str : string, length : number, padStr? : string) : string; + export function rjust (str : string, length : number, padStr? : string) : string; + export function rpad (str : string, length : number, padStr? : string) : string; + export function ljust (str : string, length : number, padStr? : string) : string; + export function lrpad (str : string, length : number, padStr? : string) : string; + export function center (str : string, length : number, padStr? : string) : string; + export function toNumber (str : string, decimals? : number) : string; + export function strRight (str : string, pattern : string) : string; + export function strRightBack (str : string, pattern : string) : string; + export function strLeft (str : string, pattern : string) : string; + export function strLeftBack (str : string, pattern : string) : string; + export function stripTags (str : string) : string; + export function toSentence (array : any[], delimiter? : string, lastDelimiter? : string) : string; + export function toSentenceSerial (array : any[], delimiter? : string, lastDelimiter? : string) : string; + export function repeat (str : string, count : number, separator? : string) : string; + export function surround (str : string, wrap : string) : string; + export function quote (str : string) : string; + export function q (str : string) : string; + export function slugify (str : string) : string; +} \ No newline at end of file