diff --git a/DynamicBibleIonic/karma.conf.js b/DynamicBibleIonic/karma.conf.js new file mode 100644 index 00000000..7914086a --- /dev/null +++ b/DynamicBibleIonic/karma.conf.js @@ -0,0 +1,48 @@ +module.exports = function (config) +{ + config.set({ + basePath: '', + frameworks: ['jasmine', 'karma-typescript'], + + files: [ + './src/polyfills.ts', + './src/mocks.ts', + './src/**/*.ts', + './src/**/*.spec.ts' + ], + + exclude: [ + ], + + preprocessors: { + './src/polyfills.ts': ['karma-typescript'], + './src/mocks.ts': ['karma-typescript'], + './src/**/*.ts': ['karma-typescript'], + './src/**/*.spec.ts': ['karma-typescript'] + }, + + typescriptPreprocessor: { + options: { + sourceMap: false, + target: 'ES5', + module: 'amd', + noImplicitAny: true, + noResolve: true, + removeComments: true, + concatenateOutput: false + }, + transformPath: function (path) + { + return path.replace(/\.ts$/, '.js'); + } + }, + reporters: ['progress', 'karma-typescript'], + port: 9876, + colors: true, + logLevel: config.LOG_DEBUG, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + concurrency: Infinity + }) +} \ No newline at end of file diff --git a/DynamicBibleIonic/package.json b/DynamicBibleIonic/package.json index 85ec68b7..bf4f7463 100644 --- a/DynamicBibleIonic/package.json +++ b/DynamicBibleIonic/package.json @@ -11,7 +11,8 @@ "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "ionic:build": "ionic-app-scripts build", - "ionic:serve": "ionic-app-scripts serve" + "ionic:serve": "ionic-app-scripts serve", + "test": "karma start karma.conf.js" }, "dependencies": { "@angular/common": "2.2.1", @@ -24,14 +25,21 @@ "@angular/platform-browser-dynamic": "2.2.1", "@angular/platform-server": "2.2.1", "@ionic/storage": "1.1.7", + "@types/jasmine": "^2.5.38", "ionic-angular": "2.0.0-rc.4", "ionic-native": "2.2.11", "ionicons": "3.0.0", + "jasmine-core": "^2.5.2", + "karma": "^1.3.0", + "karma-chrome-launcher": "^2.0.0", + "karma-jasmine": "^1.1.0", + "karma-typescript": "^2.1.5", "rxjs": "5.0.0-beta.12", "zone.js": "0.6.26" }, "devDependencies": { "@ionic/app-scripts": "0.0.47", + "karma": "^1.3.0", "typescript": "2.0.9" }, "cordovaPlugins": [ diff --git a/DynamicBibleIonic/src/Helpers.ts b/DynamicBibleIonic/src/Helpers.ts new file mode 100644 index 00000000..7d0082ef --- /dev/null +++ b/DynamicBibleIonic/src/Helpers.ts @@ -0,0 +1,24 @@ +import { Storage } from '@ionic/storage'; + +export class UserHelpers +{ + constructor(public local: Storage) + { + } + + public validate(u: User, t: User) + { + let updated = false; + for (var k in u) + { + if (t[k] === undefined) + { + t[k] = u[k]; + updated = true; + } + } + if (updated) + this.local.set('profile', JSON.stringify(t)); + } + +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/bible-service.spec.ts b/DynamicBibleIonic/src/bible-service.spec.ts new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/DynamicBibleIonic/src/bible-service.spec.ts @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html index d76ede07..56f3f9e0 100644 --- a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html +++ b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.html @@ -16,13 +16,16 @@

{{item.def.tr}} ({{item.def.sn}}) - {{item.def.p}} - {{item.def.lemma}} -

-

Robinsons Morphalogical Analysis Code

- {{item.rmac.id}}
- +

Cross References

diff --git a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts index 8d1cb09e..b272f384 100644 --- a/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts +++ b/DynamicBibleIonic/src/components/strongs-modal/strongs-modal.ts @@ -1,4 +1,4 @@ -import { EventEmitter, Component, Input, Output } from "@angular/core"; +import { EventEmitter, Component, Output } from "@angular/core"; import { Platform, NavParams, ViewController } from 'ionic-angular'; import { Reference } from '../../Reference.ts'; diff --git a/DynamicBibleIonic/src/components/strongs/strongs.html b/DynamicBibleIonic/src/components/strongs/strongs.html index bcee7563..708748be 100644 --- a/DynamicBibleIonic/src/components/strongs/strongs.html +++ b/DynamicBibleIonic/src/components/strongs/strongs.html @@ -10,17 +10,22 @@

{{item.def.tr}} ({{item.def.sn}}) - {{item.def.p}} - {{item.def.lemma}} -

-

Robinsons Morphalogical Analysis Code

- {{item.rmac.id}}
- +

Cross References

-
-
- {{wrd.w}}: {{makePassage(p.r)}}, -
-
+ +
+
+ {{wrd.w}}: {{makePassage(p.r)}}, +
+
+
\ No newline at end of file diff --git a/DynamicBibleIonic/src/components/strongs/strongs.scss b/DynamicBibleIonic/src/components/strongs/strongs.scss new file mode 100644 index 00000000..d6d560f0 --- /dev/null +++ b/DynamicBibleIonic/src/components/strongs/strongs.scss @@ -0,0 +1,3 @@ +strongs ion-scroll { + height: 250px; +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/components/words/words.scss b/DynamicBibleIonic/src/components/words/words.scss new file mode 100644 index 00000000..e8cfe2aa --- /dev/null +++ b/DynamicBibleIonic/src/components/words/words.scss @@ -0,0 +1,17 @@ + +words ion-scroll { + white-space: nowrap; + height: 250px; +} + +ion-col .button{ + background-color: #fbfbfb; + padding: 9px 6px 9px 6px; + width: 100%; + height: 100%; +} + + +ion-col { + margin-bottom: 0px !important; +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/mocks.ts b/DynamicBibleIonic/src/mocks.ts new file mode 100644 index 00000000..9ca6a322 --- /dev/null +++ b/DynamicBibleIonic/src/mocks.ts @@ -0,0 +1,82 @@ +export class ConfigMock +{ + + public get(): any + { + return ''; + } + + public getBoolean(): boolean + { + return true; + } + + public getNumber(): number + { + return 1; + } +} + +export class FormMock +{ + public register(): any + { + return true; + } +} + +export class NavMock +{ + + public pop(): any + { + return new Promise(function (resolve: Function): void + { + resolve(); + }); + } + + public push(): any + { + return new Promise(function (resolve: Function): void + { + resolve(); + }); + } + + public getActive(): any + { + return { + 'instance': { + 'model': 'something', + }, + }; + } + + public setRoot(): any + { + return true; + } +} + +export class PlatformMock +{ + public ready(): any + { + return new Promise((resolve: Function) => + { + resolve(); + }); + } +} + +export class MenuMock +{ + public close(): any + { + return new Promise((resolve: Function) => + { + resolve(); + }); + } +} \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/search/search.scss b/DynamicBibleIonic/src/pages/search/search.scss index aecf4831..f097f209 100644 --- a/DynamicBibleIonic/src/pages/search/search.scss +++ b/DynamicBibleIonic/src/pages/search/search.scss @@ -28,23 +28,3 @@ body { .card-md h2 { font-size: 2rem; } - -ion-scroll { - white-space: nowrap; - height: 250px; -} - -ion-col { - //border-bottom: 1px solid #cbcbcb !important; -} - -ion-col .button{ - background-color: #fbfbfb; - padding: 9px 6px 9px 6px; - width: 100%; - height: 100%; -} - -ion-col { - margin-bottom: 0px !important; -} \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/search/search.ts b/DynamicBibleIonic/src/pages/search/search.ts index 6dd433ef..05d55163 100644 --- a/DynamicBibleIonic/src/pages/search/search.ts +++ b/DynamicBibleIonic/src/pages/search/search.ts @@ -5,11 +5,9 @@ import {BibleService} from "../../bible-service"; import {LoadingController, ModalController } from "ionic-angular"; import {StrongsService} from "../../strongs-service"; import {WordService} from "../../word-service"; -import {Strongs} from "../../components/strongs/strongs"; -import {Passage} from "../../components/passage/passage.ts"; import {StrongsModal} from "../../components/strongs-modal/strongs-modal.ts"; import {Storage} from '@ionic/storage'; -import {Words} from '../../components/words/words.ts'; +import {UserHelpers} from '../../Helpers'; class Item { @@ -27,7 +25,7 @@ export class SearchPage { searchQuery: string = ""; last: number; - user: User = { strongs_modal: true, clear_search_after_query: true, items: [] }; + user: User = { strongs_modal: true, clear_search_after_query: true, items: [], append_to_bottom: false }; constructor( private strongsService: StrongsService @@ -44,9 +42,9 @@ export class SearchPage if (profile === null) this.local.set('profile', JSON.stringify(this.user)); else - { t = JSON.parse(profile); - } + + new UserHelpers(local).validate(this.user, t); this.initializeItems(t); }).catch(error => @@ -105,6 +103,14 @@ export class SearchPage this.local.set('profile', JSON.stringify(this.user)); } + addItemToList(item) + { + if (this.user.append_to_bottom) + this.user.items.push(item); + else + this.user.items.unshift(item); + } + getItems(search) { try @@ -121,7 +127,7 @@ export class SearchPage if (q.search(/[0-9]/i) === -1) { let result = this.wordService.getResult(q); - this.user.items.unshift({ id: this.last++, data: result, type: "Words", dict: "na" }); + this.addItemToList({ id: this.last++, data: result, type: "Words", dict: "na" }); } else if (q.search(/(H|G)[0-9]/i) !== -1) { @@ -140,7 +146,7 @@ export class SearchPage if (this.user.strongs_modal) this.presentStrongsModal(result); else - this.user.items.unshift({ id: this.last++, data: result, type: "Strongs", dict: "na" }); + this.addItemToList({ id: this.last++, data: result, type: "Strongs", dict: "na" }); } else { @@ -150,7 +156,7 @@ export class SearchPage let myref = new Reference(q.trim()); let r = this.bibleService.getResult(myref.Section); r.ref = myref.toString(); - this.user.items.unshift({ id: this.last++, data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" }); + this.addItemToList({ id: this.last++, data: r, type: "Passage", dict: r.testament == 'new' ? "G" : "H" }); } } } diff --git a/DynamicBibleIonic/src/pages/settings/settings.html b/DynamicBibleIonic/src/pages/settings/settings.html index 157370c5..ef11b832 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.html +++ b/DynamicBibleIonic/src/pages/settings/settings.html @@ -8,15 +8,21 @@ - - Show Strongs as Modal - - - - Clear Search Bar after Query - - - - - + \ No newline at end of file diff --git a/DynamicBibleIonic/src/pages/settings/settings.ts b/DynamicBibleIonic/src/pages/settings/settings.ts index e1d9a0a4..9fe4214c 100644 --- a/DynamicBibleIonic/src/pages/settings/settings.ts +++ b/DynamicBibleIonic/src/pages/settings/settings.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { Storage } from '@ionic/storage'; +import {UserHelpers} from '../../Helpers'; @Component({ selector: 'settings', @@ -9,17 +10,20 @@ import { Storage } from '@ionic/storage'; }) export class SettingsPage { - user: User = { strongs_modal: true, clear_search_after_query: true, items: [] }; + user: User = { strongs_modal: true, clear_search_after_query: true, items: [], append_to_bottom: false }; constructor(public navCtrl: NavController, public local: Storage) { // Check if there is a profile saved in local storage this.local.get('profile').then(profile => { - if (profile === null) - this.save(); - else - this.user = JSON.parse(profile); + let t = this.user; + + if (profile !== null) + t = JSON.parse(profile); + + new UserHelpers(local).validate(this.user, t); + this.user = t; }).catch(error => { console.log(error); @@ -33,7 +37,7 @@ export class SettingsPage reset() { - this.user = { strongs_modal: true, clear_search_after_query: true, items: [] }; + this.user = { strongs_modal: true, clear_search_after_query: true, items: [], append_to_bottom: false }; this.save(); } diff --git a/DynamicBibleIonic/src/polyfills.ts b/DynamicBibleIonic/src/polyfills.ts new file mode 100644 index 00000000..4f829e14 --- /dev/null +++ b/DynamicBibleIonic/src/polyfills.ts @@ -0,0 +1,19 @@ +// This file includes polyfills needed by Angular 2 and is loaded before +// the app. You can add your own extra polyfills to this file. +import 'core-js/es6/symbol'; +import 'core-js/es6/object'; +import 'core-js/es6/function'; +import 'core-js/es6/parse-int'; +import 'core-js/es6/parse-float'; +import 'core-js/es6/number'; +import 'core-js/es6/math'; +import 'core-js/es6/string'; +import 'core-js/es6/date'; +import 'core-js/es6/array'; +import 'core-js/es6/regexp'; +import 'core-js/es6/map'; +import 'core-js/es6/set'; +import 'core-js/es6/reflect'; + +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; \ No newline at end of file diff --git a/DynamicBibleIonic/src/types.ts b/DynamicBibleIonic/src/types.ts index 21835783..070f1cce 100644 --- a/DynamicBibleIonic/src/types.ts +++ b/DynamicBibleIonic/src/types.ts @@ -15,7 +15,8 @@ type CardItem = { id: number, data: any, type: string, dict: string } type User = { strongs_modal: boolean, clear_search_after_query: boolean, - items: CardItem[] + items: CardItem[], + append_to_bottom: boolean } type BiblePassage = { diff --git a/DynamicBibleIonic/typings/browser.d.ts b/DynamicBibleIonic/typings/browser.d.ts index c0dec551..39b21deb 100644 --- a/DynamicBibleIonic/typings/browser.d.ts +++ b/DynamicBibleIonic/typings/browser.d.ts @@ -1,2 +1,2 @@ -/// +/// /// diff --git a/DynamicBibleIonic/typings/browser/ambient/es6-shim/index.d.ts b/DynamicBibleIonic/typings/browser/ambient/es6-shim/index.d.ts deleted file mode 100644 index fe86f5ed..00000000 --- a/DynamicBibleIonic/typings/browser/ambient/es6-shim/index.d.ts +++ /dev/null @@ -1,670 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/es6-shim/es6-shim.d.ts -// Type definitions for es6-shim v0.31.2 -// Project: https://github.com/paulmillr/es6-shim -// Definitions by: Ron Buckton -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare type PropertyKey = string | number | symbol; - -interface IteratorResult { - done: boolean; - value?: T; -} - -interface IterableShim { - /** - * Shim for an ES6 iterable. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): Iterator; -} - -interface Iterator { - next(value?: any): IteratorResult; - return?(value?: any): IteratorResult; - throw?(e?: any): IteratorResult; -} - -interface IterableIteratorShim extends IterableShim, Iterator { - /** - * Shim for an ES6 iterable iterator. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): IterableIteratorShim; -} - -interface StringConstructor { - /** - * Return the String value whose elements are, in order, the elements in the List elements. - * If length is 0, the empty string is returned. - */ - fromCodePoint(...codePoints: number[]): string; - - /** - * String.raw is intended for use as a tag function of a Tagged Template String. When called - * as such the first argument will be a well formed template call site object and the rest - * parameter will contain the substitution values. - * @param template A well-formed template string call site representation. - * @param substitutions A set of substitution values. - */ - raw(template: TemplateStringsArray, ...substitutions: any[]): string; -} - -interface String { - /** - * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point - * value of the UTF-16 encoded code point starting at the string element at position pos in - * the String resulting from converting this object to a String. - * If there is no element at that position, the result is undefined. - * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. - */ - codePointAt(pos: number): number; - - /** - * Returns true if searchString appears as a substring of the result of converting this - * object to a String, at one or more positions that are - * greater than or equal to position; otherwise, returns false. - * @param searchString search string - * @param position If position is undefined, 0 is assumed, so as to search all of the String. - */ - includes(searchString: string, position?: number): boolean; - - /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at - * endPosition – length(this). Otherwise returns false. - */ - endsWith(searchString: string, endPosition?: number): boolean; - - /** - * Returns a String value that is made from count copies appended together. If count is 0, - * T is the empty String is returned. - * @param count number of copies to append - */ - repeat(count: number): string; - - /** - * Returns true if the sequence of elements of searchString converted to a String is the - * same as the corresponding elements of this object (converted to a String) starting at - * position. Otherwise returns false. - */ - startsWith(searchString: string, position?: number): boolean; - - /** - * Returns an HTML anchor element and sets the name attribute to the text value - * @param name - */ - anchor(name: string): string; - - /** Returns a HTML element */ - big(): string; - - /** Returns a HTML element */ - blink(): string; - - /** Returns a HTML element */ - bold(): string; - - /** Returns a HTML element */ - fixed(): string - - /** Returns a HTML element and sets the color attribute value */ - fontcolor(color: string): string - - /** Returns a HTML element and sets the size attribute value */ - fontsize(size: number): string; - - /** Returns a HTML element and sets the size attribute value */ - fontsize(size: string): string; - - /** Returns an HTML element */ - italics(): string; - - /** Returns an HTML element and sets the href attribute value */ - link(url: string): string; - - /** Returns a HTML element */ - small(): string; - - /** Returns a HTML element */ - strike(): string; - - /** Returns a HTML element */ - sub(): string; - - /** Returns a HTML element */ - sup(): string; - - /** - * Shim for an ES6 iterable. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): IterableIteratorShim; -} - -interface ArrayConstructor { - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ - from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: IterableShim): Array; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: T[]): Array; -} - -interface Array { - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; - - /** - * Returns the index of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: T) => boolean, thisArg?: any): number; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: T, start?: number, end?: number): T[]; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): T[]; - - /** - * Returns an array of key, value pairs for every entry in the array - */ - entries(): IterableIteratorShim<[number, T]>; - - /** - * Returns an list of keys in the array - */ - keys(): IterableIteratorShim; - - /** - * Returns an list of values in the array - */ - values(): IterableIteratorShim; - - /** - * Shim for an ES6 iterable. Not intended for direct use by user code. - */ - "_es6-shim iterator_"(): IterableIteratorShim; -} - -interface NumberConstructor { - /** - * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 - * that is representable as a Number value, which is approximately: - * 2.2204460492503130808472633361816 x 10‍−‍16. - */ - EPSILON: number; - - /** - * Returns true if passed value is finite. - * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a - * number. Only finite values of the type number, result in true. - * @param number A numeric value. - */ - isFinite(number: number): boolean; - - /** - * Returns true if the value passed is an integer, false otherwise. - * @param number A numeric value. - */ - isInteger(number: number): boolean; - - /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a - * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter - * to a number. Only values of the type number, that are also NaN, result in true. - * @param number A numeric value. - */ - isNaN(number: number): boolean; - - /** - * Returns true if the value passed is a safe integer. - * @param number A numeric value. - */ - isSafeInteger(number: number): boolean; - - /** - * The value of the largest integer n such that n and n + 1 are both exactly representable as - * a Number value. - * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. - */ - MAX_SAFE_INTEGER: number; - - /** - * The value of the smallest integer n such that n and n − 1 are both exactly representable as - * a Number value. - * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). - */ - MIN_SAFE_INTEGER: number; - - /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ - parseFloat(string: string): number; - - /** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ - parseInt(string: string, radix?: number): number; -} - -interface ObjectConstructor { - /** - * Copy the values of all of the enumerable own properties from one or more source objects to a - * target object. Returns the target object. - * @param target The target object to copy to. - * @param sources One or more source objects to copy properties from. - */ - assign(target: any, ...sources: any[]): any; - - /** - * Returns true if the values are the same value, false otherwise. - * @param value1 The first value. - * @param value2 The second value. - */ - is(value1: any, value2: any): boolean; - - /** - * Sets the prototype of a specified object o to object proto or null. Returns the object o. - * @param o The object to change its prototype. - * @param proto The value of the new prototype or null. - * @remarks Requires `__proto__` support. - */ - setPrototypeOf(o: any, proto: any): any; -} - -interface RegExp { - /** - * Returns a string indicating the flags of the regular expression in question. This field is read-only. - * The characters in this string are sequenced and concatenated in the following order: - * - * - "g" for global - * - "i" for ignoreCase - * - "m" for multiline - * - "u" for unicode - * - "y" for sticky - * - * If no flags are set, the value is the empty string. - */ - flags: string; -} - -interface Math { - /** - * Returns the number of leading zero bits in the 32-bit binary representation of a number. - * @param x A numeric expression. - */ - clz32(x: number): number; - - /** - * Returns the result of 32-bit multiplication of two numbers. - * @param x First number - * @param y Second number - */ - imul(x: number, y: number): number; - - /** - * Returns the sign of the x, indicating whether x is positive, negative or zero. - * @param x The numeric expression to test - */ - sign(x: number): number; - - /** - * Returns the base 10 logarithm of a number. - * @param x A numeric expression. - */ - log10(x: number): number; - - /** - * Returns the base 2 logarithm of a number. - * @param x A numeric expression. - */ - log2(x: number): number; - - /** - * Returns the natural logarithm of 1 + x. - * @param x A numeric expression. - */ - log1p(x: number): number; - - /** - * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of - * the natural logarithms). - * @param x A numeric expression. - */ - expm1(x: number): number; - - /** - * Returns the hyperbolic cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cosh(x: number): number; - - /** - * Returns the hyperbolic sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sinh(x: number): number; - - /** - * Returns the hyperbolic tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tanh(x: number): number; - - /** - * Returns the inverse hyperbolic cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - acosh(x: number): number; - - /** - * Returns the inverse hyperbolic sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - asinh(x: number): number; - - /** - * Returns the inverse hyperbolic tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - atanh(x: number): number; - - /** - * Returns the square root of the sum of squares of its arguments. - * @param values Values to compute the square root for. - * If no arguments are passed, the result is +0. - * If there is only one argument, the result is the absolute value. - * If any argument is +Infinity or -Infinity, the result is +Infinity. - * If any argument is NaN, the result is NaN. - * If all arguments are either +0 or −0, the result is +0. - */ - hypot(...values: number[]): number; - - /** - * Returns the integral part of the a numeric expression, x, removing any fractional digits. - * If x is already an integer, the result is x. - * @param x A numeric expression. - */ - trunc(x: number): number; - - /** - * Returns the nearest single precision float representation of a number. - * @param x A numeric expression. - */ - fround(x: number): number; - - /** - * Returns an implementation-dependent approximation to the cube root of number. - * @param x A numeric expression. - */ - cbrt(x: number): number; -} - -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} - -/** - * Represents the completion of an asynchronous operation - */ -interface Promise { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected?: (reason: any) => T | PromiseLike): Promise; - catch(onrejected?: (reason: any) => void): Promise; -} - -interface PromiseConstructor { - /** - * A reference to the prototype. - */ - prototype: Promise; - - /** - * Creates a new Promise. - * @param executor A callback used to initialize the promise. This callback is passed two arguments: - * a resolve callback used resolve the promise with a value or the result of another promise, - * and a reject callback used to reject the promise with a provided reason or error. - */ - new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; - - /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises - * resolve, or rejected when any Promise is rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - all(values: IterableShim>): Promise; - - /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved - * or rejected. - * @param values An array of Promises. - * @returns A new Promise. - */ - race(values: IterableShim>): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject(reason: any): Promise; - - /** - * Creates a new rejected promise for the provided reason. - * @param reason The reason the promise was rejected. - * @returns A new rejected Promise. - */ - reject(reason: any): Promise; - - /** - * Creates a new resolved promise for the provided value. - * @param value A promise. - * @returns A promise whose internal state matches the provided promise. - */ - resolve(value: T | PromiseLike): Promise; - - /** - * Creates a new resolved promise . - * @returns A resolved promise. - */ - resolve(): Promise; -} - -declare var Promise: PromiseConstructor; - -interface Map { - clear(): void; - delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - set(key: K, value?: V): Map; - size: number; - entries(): IterableIteratorShim<[K, V]>; - keys(): IterableIteratorShim; - values(): IterableIteratorShim; -} - -interface MapConstructor { - new (): Map; - new (iterable: IterableShim<[K, V]>): Map; - prototype: Map; -} - -declare var Map: MapConstructor; - -interface Set { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - size: number; - entries(): IterableIteratorShim<[T, T]>; - keys(): IterableIteratorShim; - values(): IterableIteratorShim; -} - -interface SetConstructor { - new (): Set; - new (iterable: IterableShim): Set; - prototype: Set; -} - -declare var Set: SetConstructor; - -interface WeakMap { - delete(key: K): boolean; - get(key: K): V; - has(key: K): boolean; - set(key: K, value?: V): WeakMap; -} - -interface WeakMapConstructor { - new (): WeakMap; - new (iterable: IterableShim<[K, V]>): WeakMap; - prototype: WeakMap; -} - -declare var WeakMap: WeakMapConstructor; - -interface WeakSet { - add(value: T): WeakSet; - delete(value: T): boolean; - has(value: T): boolean; -} - -interface WeakSetConstructor { - new (): WeakSet; - new (iterable: IterableShim): WeakSet; - prototype: WeakSet; -} - -declare var WeakSet: WeakSetConstructor; - -declare namespace Reflect { - function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; - function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; - function deleteProperty(target: any, propertyKey: PropertyKey): boolean; - function enumerate(target: any): IterableIteratorShim; - function get(target: any, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; - function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: PropertyKey): boolean; - function isExtensible(target: any): boolean; - function ownKeys(target: any): Array; - function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; - function setPrototypeOf(target: any, proto: any): boolean; -} - -declare module "es6-shim" { - var String: StringConstructor; - var Array: ArrayConstructor; - var Number: NumberConstructor; - var Math: Math; - var Object: ObjectConstructor; - var Map: MapConstructor; - var Set: SetConstructor; - var WeakMap: WeakMapConstructor; - var WeakSet: WeakSetConstructor; - var Promise: PromiseConstructor; - namespace Reflect { - function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; - function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; - function deleteProperty(target: any, propertyKey: PropertyKey): boolean; - function enumerate(target: any): Iterator; - function get(target: any, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; - function getPrototypeOf(target: any): any; - function has(target: any, propertyKey: PropertyKey): boolean; - function isExtensible(target: any): boolean; - function ownKeys(target: any): Array; - function preventExtensions(target: any): boolean; - function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; - function setPrototypeOf(target: any, proto: any): boolean; - } -} \ No newline at end of file