diff --git a/ts-activex/activex-data-objects-tests.ts b/activex-data-objects/activex-data-objects-tests.ts similarity index 92% rename from ts-activex/activex-data-objects-tests.ts rename to activex-data-objects/activex-data-objects-tests.ts index 27373ff8f0..6298298a48 100644 --- a/ts-activex/activex-data-objects-tests.ts +++ b/activex-data-objects/activex-data-objects-tests.ts @@ -1,6 +1,3 @@ -/// - - //open connection to an Excel file var pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx'; var conn = new ActiveXObject('ADODB.Connection'); diff --git a/ts-activex/activex-data-objects.d.ts b/activex-data-objects/index.d.ts similarity index 99% rename from ts-activex/activex-data-objects.d.ts rename to activex-data-objects/index.d.ts index 5b6844fef4..d3ccf7a6c7 100644 --- a/ts-activex/activex-data-objects.d.ts +++ b/activex-data-objects/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Zev Spitz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace ADODB { //Enums diff --git a/activex-data-objects/tsconfig.json b/activex-data-objects/tsconfig.json new file mode 100644 index 0000000000..5fb09cb648 --- /dev/null +++ b/activex-data-objects/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "activex-data-objects-tests.ts" + ] +} \ No newline at end of file diff --git a/ts-activex/microsoft-scripting-runtime-tests.ts b/activex-scripting-runtime/activex-scripting-runtime-tests.ts similarity index 97% rename from ts-activex/microsoft-scripting-runtime-tests.ts rename to activex-scripting-runtime/activex-scripting-runtime-tests.ts index d08dc5cf96..1510b98e1b 100644 --- a/ts-activex/microsoft-scripting-runtime-tests.ts +++ b/activex-scripting-runtime/activex-scripting-runtime-tests.ts @@ -1,6 +1,3 @@ -/// - - //source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx diff --git a/ts-activex/microsoft-scripting-runtime.d.ts b/activex-scripting-runtime/index.d.ts similarity index 99% rename from ts-activex/microsoft-scripting-runtime.d.ts rename to activex-scripting-runtime/index.d.ts index fd50b7504f..54065e1bd7 100644 --- a/ts-activex/microsoft-scripting-runtime.d.ts +++ b/activex-scripting-runtime/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Zev Spitz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace Scripting { //Enums diff --git a/activex-scripting-runtime/tsconfig.json b/activex-scripting-runtime/tsconfig.json new file mode 100644 index 0000000000..8845470e70 --- /dev/null +++ b/activex-scripting-runtime/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "activex-scripting-runtime-tests.ts" + ] +} \ No newline at end of file diff --git a/ts-activex/windows-image-acquisition-tests.ts b/activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts similarity index 97% rename from ts-activex/windows-image-acquisition-tests.ts rename to activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts index ae394a99f8..549bb4433f 100644 --- a/ts-activex/windows-image-acquisition-tests.ts +++ b/activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts @@ -1,5 +1,3 @@ -/// - //source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx diff --git a/ts-activex/windows-image-acquisition.d.ts b/activex-windows-image-acquisition/index.d.ts similarity index 99% rename from ts-activex/windows-image-acquisition.d.ts rename to activex-windows-image-acquisition/index.d.ts index 7be1884a4e..af32d8a865 100644 --- a/ts-activex/windows-image-acquisition.d.ts +++ b/activex-windows-image-acquisition/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Zev Spitz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace WIA { //Enums diff --git a/activex-windows-image-acquisition/tsconfig.json b/activex-windows-image-acquisition/tsconfig.json new file mode 100644 index 0000000000..d06b9b3b35 --- /dev/null +++ b/activex-windows-image-acquisition/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "activex-windows-image-acquisition-tests.ts" + ] +} \ No newline at end of file diff --git a/angular-bootstrap-calendar/package.json b/angular-bootstrap-calendar/package.json index 992b24d513..4c6d24a445 100644 --- a/angular-bootstrap-calendar/package.json +++ b/angular-bootstrap-calendar/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/async/async-tests.ts b/async/async-tests.ts index de5fbb387f..b724582368 100644 --- a/async/async-tests.ts +++ b/async/async-tests.ts @@ -1,8 +1,12 @@ +/// +import fs = require("fs"); -var fs, path; +var path: { + exists: (path: string, callback?: (err: string, exists: boolean) => any) => void; +}; -function callback() {} +function callback() { } async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { }); async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err, results) { }); diff --git a/bootstrap.v3.datetimepicker/package.json b/bootstrap.v3.datetimepicker/package.json index 992b24d513..4c6d24a445 100644 --- a/bootstrap.v3.datetimepicker/package.json +++ b/bootstrap.v3.datetimepicker/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/business-rules-engine/package.json b/business-rules-engine/package.json index c4decef904..d33ff913ce 100644 --- a/business-rules-engine/package.json +++ b/business-rules-engine/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } diff --git a/daterangepicker/package.json b/daterangepicker/package.json index 992b24d513..4c6d24a445 100644 --- a/daterangepicker/package.json +++ b/daterangepicker/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/detect-browser/detect-browser-tests.ts b/detect-browser/detect-browser-tests.ts new file mode 100644 index 0000000000..336da5150a --- /dev/null +++ b/detect-browser/detect-browser-tests.ts @@ -0,0 +1,5 @@ + +import detectBrowser = require("detect-browser"); + +const n: string = detectBrowser.name; +const v: string = detectBrowser.version; diff --git a/detect-browser/index.d.ts b/detect-browser/index.d.ts new file mode 100644 index 0000000000..0f845cd781 --- /dev/null +++ b/detect-browser/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for detect-browser v1.3.3 +// Project: https://github.com/DamonOehlman/detect-browser +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Browser name + */ +export const name: string; + +/** + * Browser version + */ +export const version: string; diff --git a/detect-browser/tsconfig.json b/detect-browser/tsconfig.json new file mode 100644 index 0000000000..c4acdf52df --- /dev/null +++ b/detect-browser/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "detect-browser-tests.ts" + ] +} \ No newline at end of file diff --git a/electron/index.d.ts b/electron/index.d.ts index 3344847224..612e9e4ab0 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -3967,9 +3967,13 @@ declare namespace Electron { */ getTitle(): string; /** - * @returns The favicon of the web page. + * @returns Whether the web page is destroyed. */ - getFavicon(): NativeImage; + isDestroyed(): boolean; + /** + * @returns Whether the web page is focused. + */ + isFocused(): boolean; /** * @returns Whether web page is still loading resources. */ diff --git a/ent/ent-tests.ts b/ent/ent-tests.ts new file mode 100644 index 0000000000..70b8bee858 --- /dev/null +++ b/ent/ent-tests.ts @@ -0,0 +1,9 @@ + +import ent = require("ent"); + +// encode +const s: string = ent.encode("foo"); +const s2: string = ent.encode("foo", { numeric: true, named: true, special: { foo: true } }); + +// decode +const t: string = ent.decode("foo"); diff --git a/ent/index.d.ts b/ent/index.d.ts new file mode 100644 index 0000000000..61dcfff355 --- /dev/null +++ b/ent/index.d.ts @@ -0,0 +1,36 @@ +// Type definitions for ent 2.2.0 +// Project: https://github.com/substack/node-ent +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * Options for the encode() function + */ +export interface EntOpts { + /** + * If opts.numeric is false or opts.named is true, encoding will used named codes like π. + */ + numeric?: boolean; + + /** + * If opts.numeric is false or opts.named is true, encoding will used named codes like π. + */ + named?: boolean; + + /** + * If opts.special is set to an Object, the key names will be forced to be encoded (defaults to forcing: <>'"&) + */ + special?: any; +} + +/** + * Escape unsafe characters in str with html entities. By default, entities are encoded with numeric decimal codes + */ +export function encode(s: string, opts?: EntOpts): string; + +/** + * Convert html entities in str back to raw text. + */ +export function decode(s: string): string; diff --git a/ng-table/tsconfig.json b/ent/tsconfig.json similarity index 92% rename from ng-table/tsconfig.json rename to ent/tsconfig.json index c310ef4ece..469af5853a 100644 --- a/ng-table/tsconfig.json +++ b/ent/tsconfig.json @@ -14,6 +14,6 @@ }, "files": [ "index.d.ts", - "ng-table-tests.ts" + "ent-tests.ts" ] } \ No newline at end of file diff --git a/eonasdan-bootstrap-datetimepicker/package.json b/eonasdan-bootstrap-datetimepicker/package.json index 992b24d513..4c6d24a445 100644 --- a/eonasdan-bootstrap-datetimepicker/package.json +++ b/eonasdan-bootstrap-datetimepicker/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/fullcalendar/package.json b/fullcalendar/package.json index c4decef904..d33ff913ce 100644 --- a/fullcalendar/package.json +++ b/fullcalendar/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } diff --git a/jasmine-ajax/jasmine-ajax-tests.ts b/jasmine-ajax/jasmine-ajax-tests.ts index 8cea33e453..890a724420 100644 --- a/jasmine-ajax/jasmine-ajax-tests.ts +++ b/jasmine-ajax/jasmine-ajax-tests.ts @@ -889,7 +889,7 @@ describe("Jasmine Mock Ajax (for toplevel)", function() { client.send(); request = mockAjax.requests.mostRecent(); - response = { status: 200, statusText: "OK", contentType: "text/html", responseText: "OK!" }; + response = { status: 200, statusText: "OK", contentType: "text/html", responseText: "OK!", responseType: "json" }; request.respondWith(response); sharedContext.responseCallback = success; @@ -1102,7 +1102,7 @@ describe("Jasmine Mock Ajax (for toplevel)", function() { client.send(); request = mockAjax.requests.mostRecent(); - response = { status: 0, statusText: "ABORT", responseText: '{"foo": "whoops!"}' }; + response = { status: 0, statusText: "ABORT", responseText: '{"foo": "whoops!"}', responseType: "json"}; request.respondWith(response); sharedContext.responseCallback = error; @@ -1138,7 +1138,7 @@ describe("Jasmine Mock Ajax (for toplevel)", function() { client.send(); request = mockAjax.requests.mostRecent(); - response = { status: 500, statusText: "SERVER ERROR", contentType: "text/html", responseText: "(._){" }; + response = { status: 500, statusText: "SERVER ERROR", contentType: "text/html", responseText: "(._){",responseType: "json"}; request.respondWith(response); sharedContext.responseCallback = error; @@ -1175,7 +1175,7 @@ describe("Jasmine Mock Ajax (for toplevel)", function() { client.send(); request = mockAjax.requests.mostRecent(); - response = { contentType: "text/html", response: "(._){response", responseText: "(._){", responseType: "text" }; + response = { contentType: "text/html", response: "(._){response", responseText: "(._){", responseType: "text", status: 200, statusText: 'OK' }; request.responseTimeout(response); sharedContext.responseCallback = error; diff --git a/jcanvas/index.d.ts b/jcanvas/index.d.ts new file mode 100644 index 0000000000..2a9c1f587c --- /dev/null +++ b/jcanvas/index.d.ts @@ -0,0 +1,84 @@ +// Type definitions for jCanvas 15.02.07 +// Project: http://projects.calebevans.me/jcanvas/ +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JCanvasRect { + x: number; + y: number; + width: number; + height: number; +} + +interface JCanvasSliceDef { + fillStyle: string; + x: number; + y: number; + /** + * Radius in pixels + */ + radius: number; + /** + * Start angle in degrees from north + */ + start: number; + /** + * End angle in degrees from north + */ + end: number; + /** + * Distance between slices as a fraction of the radius + */ + spread?: number; + + layer?: boolean; + name?: string; + groups?: string[]; +} + +interface JCanvasTextDef { + fillStyle: string; + strokeStyle: string; + strokeWidth: number; + x: number; + y: number; + fontSize: number; + fontFamily: string; + text: string; +} + +interface JQuery { + + /** + * This clearCanvas() clears all or any part of the canvas + * If nothing is passed, the entire canvas is cleared. + * Clearing a section works in the same way as drawing a rectangle, + * with the rectangle being drawn from its center (by default). + */ + clearCanvas(rect?: JCanvasRect): void; + + /** + * A slice in jCanvas is, essentially, a slice of a circle (similar to a pizza slice). + * You can draw a slice using the drawSlice() method. The size of a slice is determined by its start, end, and radius properties. + * The position of a slice is determined by its x and y properties. These coordinates lie at the tip of the slice. + */ + drawSlice(def: JCanvasSliceDef): void; + + /** + * To draw text on the canvas, use the drawText() method. + * The resulting text on the canvas is determined by the value of the text property, as well as any of the following font properties: + * fontStyle + * fontSize + * fontFamily + */ + drawText(def: JCanvasTextDef): void; +} + +// note this declare module is necessary to tell TypeScript not to interpret the whole file as one module; +// the JQuery interface below should extend the existing jquery module interface +declare module "jcanvas" { + function jcanvas(jquery: JQueryStatic, window: Window): void; + export = jcanvas; +} diff --git a/jcanvas/jcanvas-tests.ts b/jcanvas/jcanvas-tests.ts new file mode 100644 index 0000000000..3cd5e32cab --- /dev/null +++ b/jcanvas/jcanvas-tests.ts @@ -0,0 +1,23 @@ + +import $ = require("jquery"); +import jcanvas = require("jcanvas"); +jcanvas($, window); + + +const elt = $(".foo"); +elt.clearCanvas(); +elt.drawSlice({ + fillStyle: "blue", + x: 100, y: 100, + radius: 80, + start: 0, end: 359.9 +}); +elt.drawText({ + fillStyle: "white", + strokeStyle: "red", + strokeWidth: 2, + x: 100, y: 100, + fontSize: 48, + fontFamily: "Arial", + text: "bar" +}); diff --git a/jcanvas/tsconfig.json b/jcanvas/tsconfig.json new file mode 100644 index 0000000000..6f92aa9018 --- /dev/null +++ b/jcanvas/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [ + "node" + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jcanvas-tests.ts" + ] +} diff --git a/jquery.bbq/jquery.bbq-tests.ts b/jquery.bbq/jquery.bbq-tests.ts index fd49051ed3..baa6c7f42f 100644 --- a/jquery.bbq/jquery.bbq-tests.ts +++ b/jquery.bbq/jquery.bbq-tests.ts @@ -15,7 +15,7 @@ var recursiveEncoded = $.param(myObject); var recursiveDecoded = decodeURIComponent($.param(myObject)); var shallowEncoded = $.param(myObject, true); var shallowDecoded = decodeURIComponent(shallowEncoded); - + var params = { width:1680, height:1050 }; var str = jQuery.param(params); $("#results").text(str); @@ -24,7 +24,7 @@ $("#results").text(str); $.param({ a: [2,3,4] }) // "a=2&a=3&a=4" // >=1.4: $.param({ a: [2,3,4] }) // "a[]=2&a[]=3&a[]=4" - + // <=1.3.2: $.param({ a: { b:1,c:2 }, d: [3,4,{ e:5 }] }) // "a=[object+Object]&d=3&d=4&d=[object+Object]" // >=1.4: @@ -67,7 +67,7 @@ function run_many_tests(...args: any[]) { func_each = $.isFunction( tests[0] ) && tests.shift(), func_done = $.isFunction( tests[0] ) && tests.shift(), result; - + function set_result( i, test ) { result = $.isArray( test ) ? func_each.apply( this, test ) @@ -75,10 +75,10 @@ function run_many_tests(...args: any[]) { ? test( result ) : ''; }; - + if ( delay ) { stop(); - + (function loopy(){ //test && test.func && test.func( result ); if ( tests.length ) { @@ -89,7 +89,7 @@ function run_many_tests(...args: any[]) { start(); } })(); - + } else { $.each( tests, set_result ); func_done && func_done(); @@ -105,7 +105,7 @@ var params_obj = { a:['4','5','6'], b:{x:['7'], y:'8', z:['9','0','true','false' params_obj_coerce = { a:[4,5,6] },//, b:{x:[7], y:8, z:[9,0,true,false,undefined,'']}, c:1 }, params_str = params_init, params_str_old = 'a=4&a=5&a=6&b=[object+Object]&c=1', - + // If a params fragment starts with ! and BBQ is not in ajaxCrawlable mode, // things can get very ugly, very quickly. params_obj_bang = { "!a":['4'], a:['5','6'], b:{x:['7'], y:'8', z:['9','0','true','false','undefined','']}, c:'1' }, @@ -136,7 +136,7 @@ test( 'jQuery.param.sorted', function() { expected_old: 'a=4,5,6&a=7,8,9' // obviously not great, but that's the way jQuery used to roll } ]; - + if ( $.fn.jquery != '1.4.1' ) { // this explodes in jQuery 1.4.1 tests.push({ @@ -146,36 +146,36 @@ test( 'jQuery.param.sorted', function() { expected: 'a[]=3&a[]=2&a[]=1&b[]=6&b[]=5&b[]=4&x=2&z=1' }); } - + expect( tests.length * 2 + 6 ); - + $.each( tests, function(i,test: any){ var unsorted = $.param( test.obj, test.traditional ), sorted = $.param.sorted( test.obj, test.traditional ); - + equal( decodeURIComponent( sorted ), old_jquery && test.expected_old || test.expected, 'params should be sorted' ); deepEqual( $.deparam( unsorted, true ), $.deparam( sorted, true ), 'sorted params should deparam the same as unsorted params' ) }); - + equal( $.param.fragment( 'foo', '#b=2&a=1' ), 'foo#a=1&b=2', 'params should be sorted' ); equal( $.param.fragment( 'foo', '#b=2&a=1', 1 ), 'foo#a=1&b=2', 'params should be sorted' ); equal( $.param.fragment( 'foo', '#b=2&a=1', 2 ), 'foo#b=2&a=1', 'params should NOT be sorted' ); equal( $.param.fragment( 'foo#c=3&a=4', '#b=2&a=1' ), 'foo#a=1&b=2&c=3', 'params should be sorted' ); equal( $.param.fragment( 'foo#c=3&a=4', '#b=2&a=1', 1 ), 'foo#a=4&b=2&c=3', 'params should be sorted' ); equal( $.param.fragment( 'foo#c=3&a=4', '#b=2&a=1', 2 ), 'foo#b=2&a=1', 'params should NOT be sorted' ); - + }); test( 'jQuery.param.querystring', function() { expect( 11 ); - + equal( $.param.querystring( 'http://example.com/' ), '', 'properly identifying params' ); equal( $.param.querystring( 'http://example.com/?foo' ),'foo', 'properly identifying params' ); equal( $.param.querystring( 'http://example.com/?foo#bar' ),'foo', 'properly identifying params' ); equal( $.param.querystring( 'http://example.com/?foo#bar?baz' ),'foo', 'properly identifying params' ); equal( $.param.querystring( 'http://example.com/#foo' ),'', 'properly identifying params' ); equal( $.param.querystring( 'http://example.com/#foo?bar' ),'', 'properly identifying params' ); - + equal( $.param.querystring(), params_str, 'params string from window.location' ); equal( $.param.querystring( '?' + params_str ), params_str, 'params string from url' ); equal( $.param.querystring( 'foo.html?' + params_str ), params_str, 'params string from url' ); @@ -185,276 +185,276 @@ test( 'jQuery.param.querystring', function() { test( 'jQuery.param.querystring - build URL', function() { expect( 10 ); - + function fake_encode( params_str ) { return '?' + $.map( params_str.split('&'), encodeURIComponent ).join('&').replace( /%3D/g, '=' ).replace( /%2B/g, '+' ); } - + var pre = 'http://a:b@example.com:1234/foo.html', post = '#get-on-the-floor', current_url = pre + post; - + run_many_tests( - + // execute this for each array item function(){ current_url = $.param.querystring.apply( this, [ current_url ].concat( aps.call( arguments ) ) ); }, - + // tests: - + [ { a:'2' } ], - + function(result){ equal( current_url, pre + '?a=2' + post, '$.param.querystring( url, Object )' ); }, - + [ { b:'2' } ], - + function(result){ equal( current_url, pre + '?a=2&b=2' + post, '$.param.querystring( url, Object )' ); }, - + [ { c:true, d:false, e:'undefined', f:'' } ], - + function(result){ equal( current_url, pre + '?a=2&b=2&c=true&d=false&e=undefined&f=' + post, '$.param.querystring( url, Object )' ); }, - + [ { a:[4,5,6]}],//, b:{x:[7], y:8, z:[9,0,'true','false','undefined','']} }, 2 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]='; - + equal( current_url, pre + fake_encode( params ) + post, '$.param.querystring( url, Object, 2 )' ); }, - + [ { a:'1', c:'2' }, 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2'; - + equal( current_url, pre + fake_encode( params ) + post, '$.param.querystring( url, Object, 1 )' ); }, - + [ 'foo=1' ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ) + post, '$.param.querystring( url, String )' ); }, - + [ 'foo=2&bar=3', 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&bar=3&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&bar=3&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ) + post, '$.param.querystring( url, String, 1 )' ); }, - + [ 'http://example.com/test.html?/path/to/file.php#the-cow-goes-moo', 2 ], - + function(result){ equal( current_url, pre + '?/path/to/file.php' + post, '$.param.querystring( url, String, 2 )' ); }, - + [ '?another-example', 2 ], - + function(result){ equal( current_url, pre + '?another-example' + post, '$.param.querystring( url, String, 2 )' ); }, - + [ 'i_am_out_of_witty_strings', 2 ], - + function(result){ equal( current_url, pre + '?i_am_out_of_witty_strings' + post, '$.param.querystring( url, String, 2 )' ); } - + ); - + }); test( 'jQuery.param.fragment', function() { expect( 29 ); - + equal( $.param.fragment( 'http://example.com/' ), '', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo' ),'', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#bar' ),'bar', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#bar?baz' ),'bar?baz', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#foo' ),'foo', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#foo?bar' ),'foo?bar', 'properly identifying params' ); - + equal( $.param.fragment( 'http://example.com/' ), '', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo' ),'', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#!bar' ),'!bar', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#!bar?baz' ),'!bar?baz', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#!foo' ),'!foo', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#!foo?bar' ),'!foo?bar', 'properly identifying params' ); - + equal( $.param.fragment(), params_str, 'params string from window.location' ); equal( $.param.fragment( '#' + params_str ), params_str, 'params string from url' ); equal( $.param.fragment( 'foo.html#' + params_str ), params_str, 'params string from url' ); equal( $.param.fragment( 'http://a:b@example.com:1234/foo.html#' + params_str ), params_str, 'params string from url' ); equal( $.param.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#' + params_str ), params_str, 'params string from url' ); - + $.param.fragment.ajaxCrawlable( true ); - + equal( $.param.fragment( 'http://example.com/' ), '', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo' ),'', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#bar' ),'bar', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#bar?baz' ),'bar?baz', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#foo' ),'foo', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#foo?bar' ),'foo?bar', 'properly identifying params' ); - + equal( $.param.fragment( 'http://example.com/' ), '', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo' ),'', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#!bar' ),'bar', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/?foo#!bar?baz' ),'bar?baz', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#!foo' ),'foo', 'properly identifying params' ); equal( $.param.fragment( 'http://example.com/#!foo?bar' ),'foo?bar', 'properly identifying params' ); - + $.param.fragment.ajaxCrawlable( false ); - + }); test( 'jQuery.param.fragment - build URL', function() { expect( 40 ); - + function fake_encode( params_str ) { return '#' + $.map( params_str.split('&'), encodeURIComponent ).join('&').replace( /%3D/g, '=' ).replace( /%2B/g, '+' ); } - + var pre = 'http://a:b@example.com:1234/foo.html?and-dance-with-me', current_url = pre; - + run_many_tests( - + // execute this for each array item function(){ current_url = $.param.fragment.apply( this, [ current_url ].concat( aps.call( arguments ) ) ); }, - + // tests: - + [ { a:'2' } ], - + function(result){ equal( current_url, pre + '#a=2', '$.param.fragment( url, Object )' ); }, - + [ { b:'2' } ], - + function(result){ equal( current_url, pre + '#a=2&b=2', '$.param.fragment( url, Object )' ); }, - + [ { c:true, d:false, e:'undefined', f:'' } ], - + function(result){ equal( current_url, pre + '#a=2&b=2&c=true&d=false&e=undefined&f=', '$.param.fragment( url, Object )' ); }, - + [ { a:[4,5,6]}],//, b:{x:[7], y:8, z:[9,0,'true','false','undefined','']} }, 2 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]='; - + equal( current_url, pre + fake_encode( params ), '$.param.fragment( url, Object, 2 )' ); }, - + [ { a:'1', c:'2' }, 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2'; - + equal( current_url, pre + fake_encode( params ), '$.param.fragment( url, Object, 1 )' ); }, - + [ 'foo=1' ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ), '$.param.fragment( url, String )' ); }, - + [ 'foo=2&bar=3', 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&bar=3&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&bar=3&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ), '$.param.fragment( url, String, 1 )' ); }, - + [ 'http://example.com/test.html?the-cow-goes-moo#/path/to/file.php', 2 ], - + function(result){ equal( current_url, pre + '#/path/to/file.php', '$.param.fragment( url, String, 2 )' ); }, - + [ '#another-example', 2 ], - + function(result){ equal( current_url, pre + '#another-example', '$.param.fragment( url, String, 2 )' ); }, - + [ 'i_am_out_of_witty_strings', 2 ], - + function(result){ equal( current_url, pre + '#i_am_out_of_witty_strings', '$.param.fragment( url, String, 2 )' ); } - + ); - + $.param.fragment.ajaxCrawlable( true ); - + equal( $.param.fragment( 'foo', {} ) , 'foo#!', '$.param.fragment( url, Object )' ); equal( $.param.fragment( 'foo', { b:2, a:1 } ) , 'foo#!a=1&b=2', '$.param.fragment( url, Object )' ); equal( $.param.fragment( 'foo#', { b:2, a:1 } ) , 'foo#!a=1&b=2', '$.param.fragment( url, Object )' ); equal( $.param.fragment( 'foo#!', { b:2, a:1 } ) , 'foo#!a=1&b=2', '$.param.fragment( url, Object )' ); equal( $.param.fragment( 'foo#c=3&a=4', { b:2, a:1 } ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, Object )' ); equal( $.param.fragment( 'foo#!c=3&a=4', { b:2, a:1 } ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, Object )' ); - + equal( $.param.fragment( 'foo', '' ) , 'foo#!', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo', 'b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#', 'b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!', 'b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#c=3&a=4', 'b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!c=3&a=4', 'b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, String )' ); - + equal( $.param.fragment( 'foo', '#' ) , 'foo#!', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo', '#b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#', '#b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!', '#b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#c=3&a=4', '#b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!c=3&a=4', '#b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, String )' ); - + equal( $.param.fragment( 'foo', '#!' ) , 'foo#!', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo', '#!b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#', '#!b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!', '#!b=2&a=1' ) , 'foo#!a=1&b=2', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#c=3&a=4', '#!b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!c=3&a=4', '#!b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.param.fragment( url, String )' ); - + $.param.fragment.ajaxCrawlable( false ); - + // If a params fragment starts with ! and BBQ is not in ajaxCrawlable mode, // things can get very ugly, very quickly. equal( $.param.fragment( 'foo', '#!' ) , 'foo#!=', '$.param.fragment( url, String )' ); @@ -463,12 +463,12 @@ test( 'jQuery.param.fragment - build URL', function() { equal( $.param.fragment( 'foo#!', '#!b=2&a=1' ) , 'foo#!=&!b=2&a=1', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#c=3&a=4', '#!b=2&a=1' ) , 'foo#!b=2&a=1&c=3', '$.param.fragment( url, String )' ); equal( $.param.fragment( 'foo#!c=3&a=4', '#!b=2&a=1' ) , 'foo#!b=2&!c=3&a=1', '$.param.fragment( url, String )' ); - + }); test( 'jQuery.param.fragment.ajaxCrawlable', function() { expect( 5 ); - + equal( ajaxcrawlable_init, false, 'ajaxCrawlable is disabled by default' ); equal( $.param.fragment.ajaxCrawlable( true ), true, 'enabling ajaxCrawlable should return true' ); equal( $.param.fragment.ajaxCrawlable(), true, 'ajaxCrawlable is now enabled' ); @@ -478,13 +478,13 @@ test( 'jQuery.param.fragment.ajaxCrawlable', function() { test( 'jQuery.param.fragment.noEscape', function() { expect( 2 ); - + equal( $.param.fragment( '#', { foo: '/a,b@c$d+e&f=g h!' } ), '#foo=/a,b%40c%24d%2Be%26f%3Dg+h!', '/, should be unescaped, everything else but space (+) should be urlencoded' ); - + $.param.fragment.ajaxCrawlable( true ); - + equal( $.param.fragment( '#', { foo: '/a,b@c$d+e&f=g h!' } ), '#!foo=/a,b%40c%24d%2Be%26f%3Dg+h!', '/, should be unescaped, everything else but ! and space (+) should be urlencoded' ); - + $.param.fragment.ajaxCrawlable( false ); }); @@ -505,7 +505,7 @@ test( 'jQuery.deparam - pre-1.4-style params', function() { var params_str = 'a=1&a=2&a=3&b=4&c=5&c=6&c=true&c=false&c=undefined&c=&d=7', params_obj = { a:['1','2','3'], b:'4', c:['5','6','true','false','undefined',''], d:'7' }, params_obj_coerce = { a:[1,2,3], b:4, c:[5,6,true,false,undefined,''], d:7 }; - + expect( 2 ); deepEqual( $.deparam( params_str ), params_obj, '$.deparam( String )' ); deepEqual( $.deparam( params_str, true ), params_obj_coerce, '$.deparam( String, true )' ); @@ -513,7 +513,7 @@ test( 'jQuery.deparam - pre-1.4-style params', function() { test( 'jQuery.deparam.querystring', function() { expect( 12 ); - + deepEqual( $.deparam.querystring(), params_obj, 'params obj from window.location' ); deepEqual( $.deparam.querystring( /*true*/ ), params_obj_coerce, 'params obj from window.location, coerced' ); deepEqual( $.deparam.querystring( params_str ), params_obj, 'params obj from string' ); @@ -530,12 +530,12 @@ test( 'jQuery.deparam.querystring', function() { test( 'jQuery.deparam.fragment', function() { expect( 36 ); - + deepEqual( $.deparam.fragment(), params_obj, 'params obj from window.location' ); deepEqual( $.deparam.fragment( /*true*/ ), params_obj_coerce, 'params obj from window.location, coerced' ); deepEqual( $.deparam.fragment( params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); - + deepEqual( $.deparam.fragment( '#' + params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( '#' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'foo.html#' + params_str ), params_obj, 'params obj from string' ); @@ -544,7 +544,7 @@ test( 'jQuery.deparam.fragment', function() { deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html#' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#' + params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); - + // If a params fragment starts with ! and BBQ is not in ajaxCrawlable mode, // things can get very ugly, very quickly. deepEqual( $.deparam.fragment( '#!' + params_str ), params_obj_bang, 'params obj from string' ); @@ -555,9 +555,9 @@ test( 'jQuery.deparam.fragment', function() { deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html#!' + params_str, true ), params_obj_bang_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#!' + params_str ), params_obj_bang, 'params obj from string' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#!' + params_str, true ), params_obj_bang_coerce, 'params obj from string, coerced' ); - + $.param.fragment.ajaxCrawlable( true ); - + deepEqual( $.deparam.fragment( '#' + params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( '#' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'foo.html#' + params_str ), params_obj, 'params obj from string' ); @@ -566,7 +566,7 @@ test( 'jQuery.deparam.fragment', function() { deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html#' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#' + params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); - + deepEqual( $.deparam.fragment( '#!' + params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( '#!' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'foo.html#!' + params_str ), params_obj, 'params obj from string' ); @@ -575,7 +575,7 @@ test( 'jQuery.deparam.fragment', function() { deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html#!' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#!' + params_str ), params_obj, 'params obj from string' ); deepEqual( $.deparam.fragment( 'http://a:b@example.com:1234/foo.html?bippity-boppity-boo#!' + params_str, true ), params_obj_coerce, 'params obj from string, coerced' ); - + $.param.fragment.ajaxCrawlable( false ); }); @@ -599,7 +599,7 @@ function init_url_attr( _, url ) { function test_url_attr( container ) { var url; - + $.each( test_elems, function(i,v){ var val = container.children( v ).attr( $.elemUrlAttr()[ v ] ); if ( !url ) { @@ -608,277 +608,277 @@ function test_url_attr( container ) { url = -1; } }); - + return url; }; test( 'jQuery.fn.querystring', function() { expect( 60 ); - + function fake_encode( params_str ) { return '?' + $.map( params_str.split('&'), encodeURIComponent ).join('&').replace( /%3D/g, '=' ).replace( /%2B/g, '+' ); } - + var pre = 'http://a:b@example.com:1234/foo.html', post = '#get-on-the-floor', current_url = pre + post; - + run_many_tests( - + // execute this for each array item function(){ var container, elems; - + container = init_url_attr( container, current_url ); elems = container.children('span'); equal( elems.length, 1, 'select the correct elements' ); equal( elems.querystring.apply( elems, [ 'arbitrary_attr' ].concat( aps.call( arguments ) ) ), elems, 'pass query string' ); - + container = init_url_attr( container, current_url ); elems = container.children('a, link'); equal( elems.length, 2, 'select the correct elements' ); equal( elems.querystring.apply( elems, [ 'href' ].concat( aps.call( arguments ) ) ), elems, 'pass query string' ); - + container = init_url_attr( container, current_url ); elems = container.children(); equal( elems.querystring.apply( elems, aps.call( arguments ) ), elems, 'pass query string' ); - + current_url = test_url_attr( container ); }, - + // tests: - + [ { a:'2' } ], - + function(result){ equal( current_url, pre + '?a=2' + post, '$.fn.querystring( url, Object )' ); }, - + [ { b:'2' } ], - + function(result){ equal( current_url, pre + '?a=2&b=2' + post, '$.fn.querystring( url, Object )' ); }, - + [ { c:true, d:false, e:'undefined', f:'' } ], - + function(result){ equal( current_url, pre + '?a=2&b=2&c=true&d=false&e=undefined&f=' + post, '$.fn.querystring( url, Object )' ); }, - + [ { a:[4,5,6]}],//, b:{x:[7], y:8, z:[9,0,'true','false','undefined','']} }, 2 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]='; - + equal( current_url, pre + fake_encode( params ) + post, '$.fn.querystring( url, Object, 2 )' ); }, - + [ { a:'1', c:'2' }, 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2'; - + equal( current_url, pre + fake_encode( params ) + post, '$.fn.querystring( url, Object, 1 )' ); }, - + [ 'foo=1' ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ) + post, '$.fn.querystring( url, String )' ); }, - + [ 'foo=2&bar=3', 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&bar=3&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&bar=3&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ) + post, '$.fn.querystring( url, String, 1 )' ); }, - + [ 'http://example.com/test.html?/path/to/file.php#the-cow-goes-moo', 2 ], - + function(result){ equal( current_url, pre + '?/path/to/file.php' + post, '$.fn.querystring( url, String, 2 )' ); }, - + [ '?another-example', 2 ], - + function(result){ equal( current_url, pre + '?another-example' + post, '$.fn.querystring( url, String, 2 )' ); }, - + [ 'i_am_out_of_witty_strings', 2 ], - + function(result){ equal( current_url, pre + '?i_am_out_of_witty_strings' + post, '$.fn.querystring( url, String, 2 )' ); } - + ); - + }); test( 'jQuery.fn.fragment', function() { expect( 240 ); - + function fake_encode( params_str ) { return '#' + $.map( params_str.split('&'), encodeURIComponent ).join('&').replace( /%3D/g, '=' ).replace( /%2B/g, '+' ); } - + var pre = 'http://a:b@example.com:1234/foo.html?and-dance-with-me', current_url = pre; - + run_many_tests( - + // execute this for each array item function( params, merge_mode ){ current_url = test_fn_fragment( current_url, params, merge_mode ); }, - + // tests: - + [ { a:'2' } ], - + function(result){ equal( current_url, pre + '#a=2', '$.fn.fragment( url, Object )' ); }, - + [ { b:'2' } ], - + function(result){ equal( current_url, pre + '#a=2&b=2', '$.fn.fragment( url, Object )' ); }, - + [ { c:true, d:false, e:'undefined', f:'' } ], - + function(result){ equal( current_url, pre + '#a=2&b=2&c=true&d=false&e=undefined&f=', '$.fn.fragment( url, Object )' ); }, - + [ { a:[4,5,6]}],//, b:{x:[7], y:8, z:[9,0,'true','false','undefined','']} }, 2 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]='; - + equal( current_url, pre + fake_encode( params ), '$.fn.fragment( url, Object, 2 )' ); }, - + [ { a:'1', c:'2' }, 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2'; - + equal( current_url, pre + fake_encode( params ), '$.fn.fragment( url, Object, 1 )' ); }, - + [ 'foo=1' ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ), '$.fn.fragment( url, String )' ); }, - + [ 'foo=2&bar=3', 1 ], - + function(result){ var params = old_jquery ? 'a=4&a=5&a=6&b=[object+Object]&bar=3&c=2&foo=1' : 'a[]=4&a[]=5&a[]=6&b[x][]=7&b[y]=8&b[z][]=9&b[z][]=0&b[z][]=true&b[z][]=false&b[z][]=undefined&b[z][]=&bar=3&c=2&foo=1'; - + equal( current_url, pre + fake_encode( params ), '$.fn.fragment( url, String, 1 )' ); }, - + [ 'http://example.com/test.html?the-cow-goes-moo#/path/to/file.php', 2 ], - + function(result){ equal( current_url, pre + '#/path/to/file.php', '$.fn.fragment( url, String, 2 )' ); }, - + [ '#another-example', 2 ], - + function(result){ equal( current_url, pre + '#another-example', '$.fn.fragment( url, String, 2 )' ); }, - + [ 'i_am_out_of_witty_strings', 2 ], - + function(result){ equal( current_url, pre + '#i_am_out_of_witty_strings', '$.fn.fragment( url, String, 2 )' ); } - + ); - + $.param.fragment.ajaxCrawlable( true ); - + function test_fn_fragment( url, params, merge_mode? ) { var container, elems; - + container = init_url_attr( container, url ); elems = container.children('span'); equal( elems.length, 1, 'select the correct elements' ); equal( elems.fragment( 'arbitrary_attr', params, merge_mode ), elems, 'pass fragment' ); - + container = init_url_attr( container, url ); elems = container.children('a, link'); equal( elems.length, 2, 'select the correct elements' ); equal( elems.fragment( params, merge_mode ), elems, 'pass fragment' ); - + container = init_url_attr( container, url ); elems = container.children(); equal( elems.fragment( params, merge_mode ), elems, 'pass fragment' ); - + return test_url_attr( container ); }; - + equal( test_fn_fragment( 'foo', {} ) , 'foo#!', '$.fn.fragment( url, Object )' ); equal( test_fn_fragment( 'foo', { b:2, a:1 } ) , 'foo#!a=1&b=2', '$.fn.fragment( url, Object )' ); equal( test_fn_fragment( 'foo#', { b:2, a:1 } ) , 'foo#!a=1&b=2', '$.fn.fragment( url, Object )' ); equal( test_fn_fragment( 'foo#!', { b:2, a:1 } ) , 'foo#!a=1&b=2', '$.fn.fragment( url, Object )' ); equal( test_fn_fragment( 'foo#c=3&a=4', { b:2, a:1 } ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, Object )' ); equal( test_fn_fragment( 'foo#!c=3&a=4', { b:2, a:1 } ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, Object )' ); - + equal( test_fn_fragment( 'foo', '' ) , 'foo#!', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo', 'b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#', 'b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!', 'b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#c=3&a=4', 'b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!c=3&a=4', 'b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, String )' ); - + equal( test_fn_fragment( 'foo', '#' ) , 'foo#!', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo', '#b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#', '#b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!', '#b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#c=3&a=4', '#b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!c=3&a=4', '#b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, String )' ); - + equal( test_fn_fragment( 'foo', '#!' ) , 'foo#!', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo', '#!b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#', '#!b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!', '#!b=2&a=1' ) , 'foo#!a=1&b=2', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#c=3&a=4', '#!b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!c=3&a=4', '#!b=2&a=1' ) , 'foo#!a=1&b=2&c=3', '$.fn.fragment( url, String )' ); - + $.param.fragment.ajaxCrawlable( false ); - + // If a params fragment starts with ! and BBQ is not in ajaxCrawlable mode, // things can get very ugly, very quickly. equal( test_fn_fragment( 'foo', '#!' ) , 'foo#!=', '$.fn.fragment( url, String )' ); @@ -887,7 +887,7 @@ test( 'jQuery.fn.fragment', function() { equal( test_fn_fragment( 'foo#!', '#!b=2&a=1' ) , 'foo#!=&!b=2&a=1', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#c=3&a=4', '#!b=2&a=1' ) , 'foo#!b=2&a=1&c=3', '$.fn.fragment( url, String )' ); equal( test_fn_fragment( 'foo#!c=3&a=4', '#!b=2&a=1' ) , 'foo#!b=2&!c=3&a=1', '$.fn.fragment( url, String )' ); - + }); //////////////////////////////////////////////////////////////////////////////// @@ -897,21 +897,21 @@ QUnit.module( 'jQuery.bbq' ); test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), window.onhashchange', function() { expect( old_jquery ? 95 : 167 ); - - var a, b, c, d, e, f, x, y, hash, hash_actual, obj, event, msg = 'Testing window.onhashchange and history'; - + + var a:{ str: string, coerce: boolean }, b:{ str: string, coerce: boolean }, c, d, e, f, x, y, hash, hash_actual, obj: { str: string, coerce: boolean }, event:JQueryBbq.EventObject, msg = 'Testing window.onhashchange and history'; + $.bbq.pushState(); equal( window.location.hash.replace( /^#/, ''), '', 'window.location hash should be empty' ); - + $.bbq.pushState({ a:'1', b:'1' }); deepEqual( $.deparam.fragment(), { a:'1', b:'1' }, 'hash should be set properly' ); - + $(window).bind( 'hashchange', function(evt) { var hash_str = $.param.fragment(), param_obj = $.bbq.getState(), param_val = $.bbq.getState( 'param_name' ); - - event = evt; + + //event = evt; hash = $.param.fragment(); hash_actual = location.hash; obj = { str: $.bbq.getState(), coerce: $.bbq.getState( true ) }; @@ -921,40 +921,40 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), d = { str: $.bbq.getState( 'd' ), coerce: $.bbq.getState( 'd', true ) }; e = { str: $.bbq.getState( 'e' ), coerce: $.bbq.getState( 'e', true ) }; f = { str: $.bbq.getState( 'f' ), coerce: $.bbq.getState( 'f', true ) }; - + }).trigger( 'hashchange' ); - + deepEqual( obj.str, { a:'1', b:'1' }, 'hashchange triggered manually: $.bbq.getState()' ); deepEqual( obj.coerce, { a:1, b:1 }, 'hashchange triggered manually: $.bbq.getState( true )' ); equal( a.str, '1', 'hashchange triggered manually: $.bbq.getState( "a" )' ); equal( a.coerce, 1, 'hashchange triggered manually: $.bbq.getState( "a", true )' ); - + if ( !old_jquery ) { deepEqual( event.getState(), { a:'1', b:'1' }, 'hashchange triggered manually: event.getState()' ); - deepEqual( event.getState(true), { a:1, b:1 }, 'hashchange triggered manually: event.getState( true )' ); + deepEqual( event.getState('a'), { a:1, b:1 }, 'hashchange triggered manually: event.getState( true )' ); equal( event.getState('a'), '1', 'hashchange triggered manually: event.getState( "a" )' ); equal( event.getState('a',true), 1, 'hashchange triggered manually: event.getState( "a", true )' ); } - + run_many_tests( // run asynchronously 250, - + // execute this for each array item function(){ notice( msg += '.' ); $.bbq.pushState.apply( this, aps.call( arguments ) ); }, - + // execute this at the end function(){ notice(); }, - + // tests: - + [ { a:'2' } ], - + function(result){ equal( hash_actual, '#' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:'2', b:'1' }, '$.bbq.getState()' ); @@ -963,14 +963,14 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( a.coerce, 2, '$.bbq.getState( "a", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:'2', b:'1' }, 'event.getState()' ); - deepEqual( event.getState(true), { a:2, b:1 }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:2, b:1 }, 'event.getState( true )' ); equal( event.getState('a'), '2', 'event.getState( "a" )' ); equal( event.getState('a',true), 2, 'event.getState( "a", true )' ); } }, - + [ { b:'2' } ], - + function(result){ equal( hash_actual, '#' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:'2', b:'2' }, '$.bbq.getState()' ); @@ -979,14 +979,14 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( b.coerce, 2, '$.bbq.getState( "b", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:'2', b:'2' }, 'event.getState()' ); - deepEqual( event.getState(true), { a:2, b:2 }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:2, b:2 }, 'event.getState( true )' ); equal( event.getState('b'), '2', 'event.getState( "b" )' ); equal( event.getState('b',true), 2, 'event.getState( "b", true )' ); } }, - + [ { c:true, d:false, e:'undefined', f:'' } ], - + function(result){ equal( hash_actual, '#' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:'2', b:'2', c:'true', d:'false', e:'undefined', f:'' }, '$.bbq.getState()' ); @@ -1001,7 +1001,7 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( f.coerce, '', '$.bbq.getState( "f", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:'2', b:'2', c:'true', d:'false', e:'undefined', f:'' }, 'event.getState()' ); - deepEqual( event.getState(true), { a:2, b:2, c:true, d:false, e:undefined, f:'' }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:2, b:2, c:true, d:false, e:undefined, f:'' }, 'event.getState( true )' ); equal( event.getState('c'), 'true', 'event.getState( "c" )' ); equal( event.getState('c',true), true, 'event.getState( "c", true )' ); equal( event.getState('d'), 'false', 'event.getState( "d" )' ); @@ -1012,15 +1012,15 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( event.getState('f',true), '', 'event.getState( "f", true )' ); } }, - + function(result){ $.param.fragment.ajaxCrawlable( true ); }, - + function(result){ $.bbq.removeState( 'c' ); }, - + function(result){ equal( hash_actual, '#!' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:'2', b:'2', d:'false', e:'undefined', f:'' }, '$.bbq.getState()' ); @@ -1039,7 +1039,7 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( f.coerce, '', '$.bbq.getState( "f", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:'2', b:'2', d:'false', e:'undefined', f:'' }, 'event.getState()' ); - deepEqual( event.getState(true), { a:2, b:2, d:false, e:undefined, f:'' }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:2, b:2, d:false, e:undefined, f:'' }, 'event.getState( true )' ); equal( event.getState('a'), '2', 'event.getState( "a" )' ); equal( event.getState('a',true), 2, 'event.getState( "a", true )' ); equal( event.getState('b'), '2', 'event.getState( "b" )' ); @@ -1054,11 +1054,11 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( event.getState('f',true), '', 'event.getState( "f", true )' ); } }, - + function(result){ $.bbq.removeState( [ 'd', 'e', 'f', 'nonexistent' ] ); }, - + function(result){ equal( hash_actual, '#!' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:'2', b:'2' }, '$.bbq.getState()' ); @@ -1077,7 +1077,7 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( f.coerce, undefined, '$.bbq.getState( "f", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:'2', b:'2' }, 'event.getState()' ); - deepEqual( event.getState(true), { a:2, b:2 }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:2, b:2 }, 'event.getState( true )' ); equal( event.getState('a'), '2', 'event.getState( "a" )' ); equal( event.getState('a',true), 2, 'event.getState( "a", true )' ); equal( event.getState('b'), '2', 'event.getState( "b" )' ); @@ -1092,11 +1092,11 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( event.getState('f',true), undefined, 'event.getState( "f", true )' ); } }, - + function(result){ $.bbq.removeState(); }, - + function(result){ equal( hash_actual, '#!', 'hash should just be #!' ); deepEqual( obj.str, {}, '$.bbq.getState()' ); @@ -1115,7 +1115,7 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( f.coerce, undefined, '$.bbq.getState( "f", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), {}, 'event.getState()' ); - deepEqual( event.getState(true), {}, 'event.getState( true )' ); + deepEqual( event.getState('a'), {}, 'event.getState( true )' ); equal( event.getState('a'), undefined, 'event.getState( "a" )' ); equal( event.getState('a',true), undefined, 'event.getState( "a", true )' ); equal( event.getState('b'), undefined, 'event.getState( "b" )' ); @@ -1130,11 +1130,11 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( event.getState('f',true), undefined, 'event.getState( "f", true )' ); } }, - + [ { a:'2', b:'2', c:true, d:false, e:'undefined', f:'' } ], - + [ { a:[4,5,6]}],//, b:{x:[7], y:8, z:[9,0,'true','false','undefined','']} }, 2 ], - + function(result){ var b_str = old_jquery ? '[object Object]' @@ -1142,7 +1142,7 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), b_coerce = old_jquery ? '[object Object]' : {x:[7], y:8};//z:[9,0,true,false,undefined,'']}; - + equal( hash_actual, '#!' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:['4','5','6'], b:b_str }, '$.bbq.getState()' ); deepEqual( obj.coerce, { a:[4,5,6], b:b_coerce }, '$.bbq.getState( true )' ); @@ -1150,14 +1150,14 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), deepEqual( a.coerce, [4,5,6], '$.bbq.getState( "a", true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:['4','5','6'], b:b_str }, 'event.getState()' ); - deepEqual( event.getState(true), { a:[4,5,6], b:b_coerce }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:[4,5,6], b:b_coerce }, 'event.getState( true )' ); deepEqual( event.getState('a'), ['4','5','6'], 'event.getState( "a" )' ); deepEqual( event.getState('a',true), [4,5,6], 'event.getState( "a", true )' ); } }, - + [ { a:'1', c:'2' }, 1 ], - + function(result){ var b_str = old_jquery ? '[object Object]' @@ -1165,18 +1165,18 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), b_coerce = old_jquery ? '[object Object]' : {x:[7], y:8};//, z:[9,0,true,false,undefined,'']}; - + equal( hash_actual, '#!' + hash, 'hash should begin with #!' ); deepEqual( obj.str, { a:['4','5','6'], b:b_str, c:'2' }, '$.bbq.getState()' ); deepEqual( obj.coerce, { a:[4,5,6], b:b_coerce, c:2 }, '$.bbq.getState( true )' ); if ( !old_jquery ) { deepEqual( event.getState(), { a:['4','5','6'], b:b_str, c:'2' }, 'event.getState()' ); - deepEqual( event.getState(true), { a:[4,5,6], b:b_coerce, c:2 }, 'event.getState( true )' ); + deepEqual( event.getState('a'), { a:[4,5,6], b:b_coerce, c:2 }, 'event.getState( true )' ); } }, - + [ '#/path/to/file.php', 2 ], - + function(result){ equal( hash_actual, '#!' + hash, 'hash should begin with #!' ); equal( hash, '/path/to/file.php', '$.param.fragment()' ); @@ -1184,9 +1184,9 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( event.fragment, '/path/to/file.php', 'event.fragment' ); } }, - + [], - + function(result){ equal( hash_actual, '#!', 'hash should just be #!' ); equal( hash, '', '$.param.fragment()' ); @@ -1194,67 +1194,67 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), equal( event.fragment, '', 'event.fragment' ); } }, - + function(result){ $(window).bind( 'hashchange', function(evt){ x = $.param.fragment(); }); }, - + [ '#omg_ponies', 2 ], - + function(result){ equal( hash, 'omg_ponies', 'event handler 1: $.param.fragment()' ); equal( x, 'omg_ponies', 'event handler 2: $.param.fragment()' ); - + hash = x = ''; equal( hash + x, '', 'vars reset' ); - + $(window).triggerHandler( 'hashchange' ); equal( hash, 'omg_ponies', 'event handler 1: $.param.fragment()' ); equal( x, 'omg_ponies', 'event handler 2: $.param.fragment()' ); - + hash = x = ''; equal( hash + x, '', 'vars reset' ); - + $(window).unbind( 'hashchange' ); }, - + [ '#almost_done?not_search', 2 ], - + function(result){ equal( hash, '', 'event handler 1: $.param.fragment()' ); equal( x, '', 'event handler 2: $.param.fragment()' ); - + var events:any;// = $.data( window, 'events' ); ok( !events || !events.hashchange, 'hashchange event unbound' ); }, - + [ '#' ], - + function(result){ x = []; $(window).bind( 'hashchange', function(evt){ x.push( $.param.fragment() ); }); }, - + function(result){ !is_chrome && window.history.go( -1 ); }, - + function(result){ !is_chrome && window.history.go( -1 ); }, - + function(result){ !is_chrome && window.history.go( -1 ); }, - + function(result){ !is_chrome && window.history.go( -1 ); }, - + function(result){ if ( is_chrome ) { // Read about this issue here: http://benalman.com/news/2009/09/chrome-browser-history-buggine/ @@ -1262,20 +1262,20 @@ test( 'jQuery.bbq.pushState(), jQuery.bbq.getState(), jQuery.bbq.removeState(), } else { deepEqual( x, ['almost_done?not_search', 'omg_ponies', '', '/path/to/file.php'], 'back button and window.bbq.go(-1) should work' ); } - + $(window).unbind( 'hashchange' ); var events: any;// = $.data( window, 'events' ); ok( !events || !events.hashchange, 'hashchange event unbound' ); }, - + function(result){ $.param.fragment.ajaxCrawlable( false ); }, - + [ '#all_done' ] - + ); - + }); diff --git a/jquery.livestampjs/package.json b/jquery.livestampjs/package.json index c4decef904..d33ff913ce 100644 --- a/jquery.livestampjs/package.json +++ b/jquery.livestampjs/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 0063a6115b..2cce742f86 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -816,11 +816,7 @@ function test_autocomplete() { }, response); }, search: () => { - // custom minLength - var term = null - if (term.length < 2) { - return false; - } + return false; }, focus: () => { return false; diff --git a/jsonwebtoken/index.d.ts b/jsonwebtoken/index.d.ts index 4cdbf3d924..15790f7547 100644 --- a/jsonwebtoken/index.d.ts +++ b/jsonwebtoken/index.d.ts @@ -46,7 +46,7 @@ export interface SignOptions { issuer?: string; jwtid?: string; noTimestamp?: boolean; - headers?: Object; + header?: Object; encoding?: string; } diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts b/knockout/tests/knockout-templatingBehaviors-tests.ts index 29e09f5729..213ee06f15 100644 --- a/knockout/tests/knockout-templatingBehaviors-tests.ts +++ b/knockout/tests/knockout-templatingBehaviors-tests.ts @@ -120,7 +120,7 @@ describe('Templating', function() { }); it('Should be able to access newly rendered/inserted elements in \'afterRender\' callaback', function () { - var passedElement, passedDataItem; + var passedElement:any, passedDataItem; var myCallback = function(elementsArray, dataItem) { expect(elementsArray.length).toEqual(1); passedElement = elementsArray[0]; diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index 1f9f52ff47..ba96f6863f 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -242,7 +242,13 @@ function test_bindings() { } }; - var node, containerElem, nodeToInsert, insertAfter, nodeToPrepend, arrayOfNodes; + var node: Node = {}; + var insertAfter: Node = {}; + var nodeToPrepend: Node = {}; + var arrayOfNodes: Node[] = []; + var containerElem: KnockoutVirtualElement = {}; + var nodeToInsert: Node = {} + ko.virtualElements.emptyNode(containerElem); ko.virtualElements.firstChild(containerElem); ko.virtualElements.insertAfter(containerElem, nodeToInsert, insertAfter); @@ -568,7 +574,7 @@ function test_misc() { var x = ko.observableArray([1, 2, 3]); - var element; + var element: Element = {}; ko.utils.domNodeDisposal.addDisposeCallback(element, function () { $(element).datepicker("destroy"); }); diff --git a/kolite/kolite-tests.ts b/kolite/kolite-tests.ts index 698e915578..539c284861 100644 --- a/kolite/kolite-tests.ts +++ b/kolite/kolite-tests.ts @@ -7,11 +7,11 @@ function test_activityDefaults() { container: 'i', inactiveClass: '' }; - + ko.bindingHandlers.activity.defaultOptions = { activityClass: 'some Value' }; - + ko.bindingHandlers.activity.defaultOptions = { }; } @@ -60,12 +60,12 @@ function test_asyncCommand_isExecuting() { } function test_dirtyFlag() { - var viewModel; + var viewModel: any; viewModel.dirtyFlag = new ko.DirtyFlag(viewModel.model); viewModel.dirtyFlag().isDirty(); viewModel.dirtyFlag().reset(); - var self; + var self: any; this.dirtyFlag = new ko.DirtyFlag( self.firstName, self.lastName); diff --git a/ldapjs/index.d.ts b/ldapjs/index.d.ts new file mode 100644 index 0000000000..50942be9fd --- /dev/null +++ b/ldapjs/index.d.ts @@ -0,0 +1,93 @@ +// Type definitions for ldapjs v0.7.1 +// Project: http://ldapjs.org +// Definitions by: Peter Kooijmans +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +export interface Error { + code: number; + name: string; + message: string; +} + +export interface CallBack { + (error: Error, result?: any): void; +} + +export interface ClientOptions { + url: string; + socketPath?: string; + log?: any; + timeout?: number; + connectTimeout?: number; + maxConnections?: number; + bindDN?: string; + bindCredentials?: string; + checkInterval?: number; + maxIdleTime?: number; +} + +export interface SearchOptions { + scope?: string; + filter?: string; + attributes?: string[]; + attrsOnly?: boolean; + sizeLimit?: number; + timeLimit?: number; +} + +export interface SearchCallBack { + (error: Error, result: NodeJS.EventEmitter): void; +} + +export interface Client { + /** + * Performs a simple authentication against the server. + * + * @param name the DN to bind as. + * @param credentials the userPassword associated with name. + * @param controls (optional) either a Control or [Control]. + * @param callback callback of the form f(err, res). + * @throws {TypeError} on invalid input. + */ + bind(dn: string, password: string, callback: CallBack): void; + + /** + * Performs an LDAP search against the server. + * + * Note that the defaults for options are a 'base' search, if that's what + * you want you can just pass in a string for options and it will be treated + * as the search filter. Also, you can either pass in programatic Filter + * objects or a filter string as the filter option. + * + * Note that this method is 'special' in that the callback 'res' param will + * have two important events on it, namely 'entry' and 'end' that you can hook + * to. The former will emit a SearchEntry object for each record that comes + * back, and the latter will emit a normal LDAPResult object. + * + * @param {String} base the DN in the tree to start searching at. + * @param {Object} options parameters: + * - {String} scope default of 'base'. + * - {String} filter default of '(objectclass=*)'. + * - {Array} attributes [string] to return. + * - {Boolean} attrsOnly whether to return values. + * @param {Control} controls (optional) either a Control or [Control]. + * @param {Function} callback of the form f(err, res). + * @throws {TypeError} on invalid input. + */ + search(base: string, options: SearchOptions, callback: SearchCallBack): void; + + /** + * Unbinds this client from the LDAP server. + * + * Note that unbind does not have a response, so this callback is actually + * optional; either way, the client is disconnected. + * + * @param {Function} callback of the form f(err). + * @throws {TypeError} if you pass in callback as not a function. + */ + unbind(callback: CallBack): void; +} + +export function createClient(options? : ClientOptions): Client; diff --git a/ldapjs/ldapjs-tests.ts b/ldapjs/ldapjs-tests.ts new file mode 100644 index 0000000000..6b2d879142 --- /dev/null +++ b/ldapjs/ldapjs-tests.ts @@ -0,0 +1,20 @@ + +import ldap = require("ldapjs"); + +let client = ldap.createClient({ + url: 'ldap://127.0.0.1:1389' +}); + +client.bind('cn=root', 'secret', (err: Error): void => { + // nothing +}); + +let opts: ldap.SearchOptions = { + filter: '(&(l=Seattle)(email=*@foo.com))', + scope: 'sub', + attributes: ['dn', 'sn', 'cn'] +}; + +client.search('o=example', opts, (err: Error, res: NodeJS.EventEmitter): void => { + // nothing +}); diff --git a/ldapjs/tsconfig.json b/ldapjs/tsconfig.json new file mode 100644 index 0000000000..b9ed13b2e2 --- /dev/null +++ b/ldapjs/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ldapjs-tests.ts" + ] +} \ No newline at end of file diff --git a/lolex/index.d.ts b/lolex/index.d.ts index 27052b54a5..544fb88fb6 100644 --- a/lolex/index.d.ts +++ b/lolex/index.d.ts @@ -1,10 +1,12 @@ -// Type definitions for lolex 1.2.1 +// Type definitions for lolex 1.5.1 // Project: https://github.com/sinonjs/lolex // Definitions by: Wim Looman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Clock { + now: number; + setTimeout(callback: () => any, timeout: number): number; setInterval(callback: () => any, timeout: number): number; setImmediate(callback: () => any): number; @@ -13,6 +15,9 @@ export interface Clock { clearInterval(id: number): void; clearImmediate(id: number): void; + setSystemTime(now: number): void; + setSystemTime(date: Date): void; + tick(ms: number): void; uninstall(): void; } diff --git a/lolex/lolex-tests.ts b/lolex/lolex-tests.ts index 8f2c96a1c7..00feecfdd6 100644 --- a/lolex/lolex-tests.ts +++ b/lolex/lolex-tests.ts @@ -57,6 +57,11 @@ clock = lolex.install(window, Date.now(), ['setTimeout', 'clearTimeout']); clock = lolex.install(Date.now()); clock = lolex.install(Date.now(), ['setTimeout', 'clearTimeout']); +/** + * clock.now + */ +var n: number = clock.now; + var id: number; /** @@ -100,6 +105,11 @@ id = clock.setImmediate(() => {}); clock.clearImmediate(id); +/** + * clock.setSystemTime + */ +clock.setSystemTime(0); +clock.setSystemTime(new Date()); /** * clock.tick(time) @@ -113,3 +123,4 @@ clock.tick(1000); */ clock.uninstall(); + diff --git a/mobile-detect/index.d.ts b/mobile-detect/index.d.ts index 5e3df3377a..e85b1afc27 100644 --- a/mobile-detect/index.d.ts +++ b/mobile-detect/index.d.ts @@ -18,3 +18,6 @@ declare class MobileDetect { version(value: string): number; versionStr(value: string): string; } + +export = MobileDetect; +export as namespace MobileDetect; \ No newline at end of file diff --git a/moment-jalaali/package.json b/moment-jalaali/package.json index 992b24d513..4c6d24a445 100644 --- a/moment-jalaali/package.json +++ b/moment-jalaali/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/moment-range/package.json b/moment-range/package.json index 992b24d513..4c6d24a445 100644 --- a/moment-range/package.json +++ b/moment-range/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/moment-timezone/index.d.ts b/moment-timezone/index.d.ts index 030c09270b..6d45938c18 100644 --- a/moment-timezone/index.d.ts +++ b/moment-timezone/index.d.ts @@ -20,19 +20,16 @@ declare namespace MomentTimezone { parse(timestamp: number): number } - type MomentFormatSpecification = - string | (() => void) | (string | (() => void))[]; - interface MomentTimezone { (): moment.Moment; (timezone: string): moment.Moment; (date: number, timezone: string): moment.Moment; (date: number[], timezone: string): moment.Moment; (date: string, timezone: string): moment.Moment; - (date: string, format: MomentFormatSpecification, timezone: string): moment.Moment; - (date: string, format: MomentFormatSpecification, strict: boolean, timezone: string): moment.Moment; - (date: string, format: MomentFormatSpecification, language: string, timezone: string): moment.Moment; - (date: string, format: MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment; + (date: string, format: moment.MomentFormatSpecification, timezone: string): moment.Moment; + (date: string, format: moment.MomentFormatSpecification, strict: boolean, timezone: string): moment.Moment; + (date: string, format: moment.MomentFormatSpecification, language: string, timezone: string): moment.Moment; + (date: string, format: moment.MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment; (date: Date, timezone: string): moment.Moment; (date: moment.Moment, timezone: string): moment.Moment; (date: Object, timezone: string): moment.Moment; diff --git a/moment-timezone/package.json b/moment-timezone/package.json index c4decef904..d33ff913ce 100644 --- a/moment-timezone/package.json +++ b/moment-timezone/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } diff --git a/ng-table/index.d.ts b/ng-table/index.d.ts deleted file mode 100644 index e079977db9..0000000000 --- a/ng-table/index.d.ts +++ /dev/null @@ -1,838 +0,0 @@ -// Type definitions for ng-table -// Project: https://github.com/esvit/ng-table -// Definitions by: Christian Crowhurst -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -/** - * Parameters manager for an ngTable directive - */ -declare class NgTableParams { - /** - * The page of data rows currently being displayed in the table - */ - data: T[]; - - constructor(baseParameters?: NgTable.IParamValues, baseSettings?: NgTable.ISettings) - - /** - * Returns the number of data rows per page - */ - count(): number - /** - * Sets the number of data rows per page. - * Changes to count will cause `isDataReloadRequired` to return true - */ - count(count: number): NgTableParams - - /** - * Returns the current filter values used to restrict the set of data rows. - * @param trim supply true to return the current filter minus any insignificant values - * (null, undefined and empty string) - */ - filter(trim?: boolean): NgTable.IFilterValues - /** - * Sets filter values to the `filter` supplied; any existing filter will be removed - * Changes to filter will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 - */ - filter(filter: NgTable.IFilterValues): NgTableParams - /** - * Generate array of pages. - * When no arguments supplied, the current parameter state of this `NgTableParams` instance will be used - */ - generatePagesArray(currentPage?: number, totalItems?: number, pageSize?: number, maxBlocks?: number): NgTable.IPageButton[] - /** - * Returns the current grouping used to group the data rows - */ - group(): NgTable.Grouping - /** - * Sets grouping to the `field` and `sortDirection` supplied; any existing grouping will be removed - * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 - */ - group(field: string, sortDirection?: string): NgTableParams - /** - * Sets grouping to the `group` supplied; any existing grouping will be removed. - * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 - */ - group(group: NgTable.Grouping): NgTableParams - /** - * Returns true when an attempt to `reload` the current `parameter` values have resulted in a failure. - * This method will continue to return true until the `reload` is successfully called or when the - * `parameter` values have changed - */ - hasErrorState(): boolean - /** - * Returns true if `filter` has significant filter value(s) (any value except null, undefined, or empty string), - * otherwise false - */ - hasFilter(): boolean - /** - * Return true when a change to `filters` require the `reload` method - * to be run so as to ensure the data presented to the user reflects these filters - */ - hasFilterChanges(): boolean - /** - * Returns true when at least one group has been set - */ - hasGroup(): boolean - /** - * Returns true when the `group` and when supplied, the `sortDirection` matches an existing group - */ - hasGroup(group: string | NgTable.IGroupingFunc, sortDirection?: string): boolean - /** - * Return true when a change to this instance should require the `reload` method - * to be run so as to ensure the data rows presented to the user reflects the current state. - * - * Note that this method will return false when the `reload` method has run but fails. In this case - * `hasErrorState` will return true. - * - * The built-in `ngTable` directives will watch for when this function returns true and will then call - * the `reload` method to load its data rows - */ - isDataReloadRequired(): boolean - /** - * Returns sorting values in a format that can be consumed by the angular `$orderBy` filter service - */ - orderBy(): string[] - /** - * Trigger a reload of the data rows - */ - reload>(): ng.IPromise - /** - * Returns the settings for the table. - */ - settings(): NgTable.ISettings - /** - * Sets the settings for the table; new setting values will be merged with the existing settings. - * Supplying a new `dataset` will cause `isDataReloadRequired` to return true and the `ngTableEventsChannel` - * to fire its `datasetChanged` event - */ - settings(newSettings: NgTable.ISettings): NgTableParams - /** - * Returns the current sorting used to order the data rows. - * Changes to sorting will cause `isDataReloadRequired` to return true - */ - sorting(): NgTable.ISortingValues - /** - * Sets sorting values to the `sorting` supplied; any existing sorting will be removed. - * Changes to sorting will cause `isDataReloadRequired` to return true - */ - sorting(sorting: NgTable.ISortingValues): NgTableParams - /** - * Sets sorting to the `field` and `direction` supplied; any existing sorting will be removed - */ - sorting(field: string, direction: string): NgTableParams - /** - * Returns the index of the current "slice" of data rows - */ - page(): number - /** - * Sets the index of the current "slice" of data rows. The index starts at 1. - * Changing the page number will cause `isDataReloadRequired` to return true - */ - page(page: number): NgTableParams - /** - * Returns the count of the data rows that match the current `filter` - */ - total(): number - /** - * Sets `settings().total` to the value supplied. - * Typically you will need to set a `total` in the body of any custom `getData` function - * you supply as a setting value to this instance. - * @example - * var tp = new NgTableParams({}, { getData: customGetData }) - * function customGetData(params) { - * var queryResult = /* code to fetch current data rows and total *\/ - * params.total(queryResult.total); - * return queryResult.dataRowsPage; - * } - */ - total(total: number): NgTableParams - /** - * Returns the current parameter values uri-encoded. Set `asString` to - * true for the parameters to be returned as an array of strings of the form 'paramName=value' - * otherwise parameters returned as a key-value object - */ - url(asString?: boolean): { [name: string]: string } | string[] -} - -declare namespace NgTable { - - interface IDataSettings { - applyPaging?: boolean; - } - - /** - * An angular value object that allow for overriding of the initial default values used when constructing - * an instance of `NgTableParams` - */ - interface IDefaults { - params?: IParamValues; - settings?: ISettings - } - - /** - * Map of the names of fields declared on a data row and the corrosponding filter value - */ - interface IFilterValues { [name: string]: any } - - /** - * Map of the names of fields on a data row and the corrosponding sort direction; - * Set the value of a key to undefined to let value of `ISettings.defaultSort` apply - */ - interface ISortingValues { [name: string]: string } - - type Grouping = IGroupValues | IGroupingFunc; - - /** - * Map of the names of fields on a data row and the corrosponding sort direction - */ - interface IGroupValues { [name: string]: string } - - /** - * Signature of a function that should return the name of the group - * that the `item` should be placed within - */ - interface IGroupingFunc { - (item: T): string; - /** - * 'asc' or 'desc'; leave undefined to let the value of `ISettings.groupOptions.defaultSort` apply - */ - sortDirection?: string - } - - /** - * The runtime values for `NgTableParams` that determine the set of data rows and - * how they are to be displayed in a table - */ - interface IParamValues { - /** - * The index of the "slice" of data rows, starting at 1, to be displayed by the table. - */ - page?: number; - /** - * The number of data rows per page - */ - count?: number; - /** - * The filter that should be applied to restrict the set of data rows - */ - filter?: IFilterValues; - /** - * The sort order that should be applied to the data rows. - */ - sorting?: ISortingValues; - /** - * The grouping that should be applied to the data rows - */ - group?: string | Grouping; - } - - - type FilterComparator = boolean | IFilterComparatorFunc; - - interface IFilterComparatorFunc { - (actual: T, expected: T): boolean; - } - - interface IFilterFunc { - (data: T[], filter: IFilterValues, filterComparator: FilterComparator): T[] - } - - - interface IFilterSettings { - /** - * Use this to determine how items are matched against the filter values. - * This setting is identical to the `comparator` parameter supported by the angular - * `$filter` filter service - * - * Defaults to `undefined` which will result in a case insensitive susbstring match when - * `IDefaultGetData` service is supplying the implementation for the - * `ISettings.getData` function - */ - filterComparator?: FilterComparator; - /** - * A duration to wait for the user to stop typing before applying the filter. - * - Defaults to 0 for small managed inmemory arrays ie where a `ISettings.dataset` argument is - * supplied to `NgTableParams.settings`. - * - Defaults to 500 milliseconds otherwise. - */ - filterDelay?: number; - /** - * The number of elements up to which a managed inmemory array is considered small. Defaults to 10000. - */ - filterDelayThreshold?: number; - /** - * Overrides `IDefaultGetDataProvider.filterFilterName`. - * The value supplied should be the name of the angular `$filter` service that will be selected to perform - * the actual filter logic. - * Defaults to 'filter'. - */ - filterFilterName?: string; - /** - * Tells `IDefaultGetData` to use this function supplied to perform the filtering instead of selecting an angular $filter. - */ - filterFn?: IFilterFunc; - /** - * The layout to use when multiple html templates are to rendered in a single table header column. - * Available values: - * - stack (the default) - * - horizontal - */ - filterLayout?: string - } - - interface IGroupSettings { - /** - * The default sort direction that will be used whenever a group is supplied that - * does not define its own sort direction - */ - defaultSort?: string; - /** - * Determines whether groups should be displayed expanded to show their items. Defaults to true - */ - isExpanded?: boolean; - } - - /** - * Definition of the buttons rendered by the data row pager directive - */ - interface IPageButton { - type: string; - number?: number; - active: boolean; - current?: boolean; - } - - /** - * Configuration settings for `NgTableParams` - */ - interface ISettings { - /** - * Returns true whenever a call to `getData` is in progress - */ - $loading?: boolean; - /** - * An array that contains all the data rows that NgTable should manage. - * The `gateData` function will be used to manage the data rows - * that ultimately will be displayed. - */ - dataset?: T[]; - dataOptions?: {}; - /** - * The total number of data rows before paging has been applied. - * Typically you will not need to supply this yourself - */ - total?: number; - /** - * The default sort direction that will be used whenever a sorting is supplied that - * does not define its own sort direction - */ - defaultSort?: string; - filterOptions?: IFilterSettings; - groupOptions?: IGroupSettings; - /** - * The page size buttons that should be displayed. Each value defined in the array - * determines the possible values that can be supplied to `NgTableParams.page()` - */ - counts?: number[]; - /** - * The collection of interceptors that should apply to the results of a call to - * the `getData` function before the data rows are displayed in the table - */ - interceptors?: IInterceptor[]; - /** - * Configuration for the template that will display the page size buttons - */ - paginationMaxBlocks?: number; - /** - * Configuration for the template that will display the page size buttons - */ - paginationMinBlocks?: number; - /** - * The html tag that will be used to display the sorting indicator in the table header - */ - sortingIndicator?: string; - /** - * The function that will be used fetch data rows. Leave undefined to let the `IDefaultGetData` - * service provide a default implementation that will work with the `dataset` array you supply. - * - * Typically you will supply a custom function when you need to execute filtering, paging and sorting - * on the server - */ - getData?: Data.IGetDataFunc | Data.IInterceptableGetDataFunc; - /** - * The function that will be used group data rows according to the groupings returned by `NgTableParams.group()` - */ - getGroups?: Data.IGetGroupFunc; - } - - /** - * Configuration values that determine the behaviour of the `ngTableFilterConfig` service - */ - interface IFilterConfigValues { - /** - * The default base url to use when deriving the url for a filter template given just an alias name - * Defaults to 'ng-table/filters/' - */ - defaultBaseUrl?: string; - /** - * The extension to use when deriving the url of a filter template when given just an alias name - */ - defaultExt?: string; - /** - * A map of alias names and their corrosponding urls. A lookup against this map will be used - * to find the url matching an alias name. - * If no match is found then a url will be derived using the following pattern `${defaultBaseUrl}${aliasName}.${defaultExt}` - */ - aliasUrls?: { [name: string]: string }; - } - - /** - * The angular provider used to configure the behaviour of the `ngTableFilterConfig` service - */ - interface IFilterConfigProvider { - $get: IFilterConfig; - /** - * Reset back to factory defaults the config values that `ngTableFilterConfig` service will use - */ - resetConfigs(): void; - /** - * Set the config values used by `ngTableFilterConfig` service - */ - setConfig(customConfig: IFilterConfigValues): void; - } - - /** - * A key value-pair map where the key is the name of a field in a data row and the value is the definition - * for the template used to render a filter cell in the header of a html table. - * Where the value is supplied as a string this should either be url to a html template or an alias to a url registered - * using the `ngTableFilterConfigProvider` - * @example - * vm.ageFilter = { "age": "number" } - * @example - * vm.ageFilter = { "age": "my/custom/ageTemplate.html" } - * @example - * vm.ageFilter = { "age": { id: "number", placeholder: "Age of person"} } - */ - interface IFilterTemplateDefMap { - [name: string]: string | IFilterTemplateDef - } - - /** - * A fully qualified template definition for a single filter - */ - interface IFilterTemplateDef { - /** - * A url to a html template of an alias to a url registered using the `ngTableFilterConfigProvider` - */ - id: string, - /** - * The text that should be rendered as a prompt to assist the user when entering a filter value - */ - placeholder: string - } - - /** - * Exposes configuration values and methods used to return the location of the html - * templates used to render the filter row of an ng-table directive - */ - interface IFilterConfig { - /** - * Readonly copy of the final values used to configure the service. - */ - config: IFilterConfigValues, - /** - * Return the url of the html filter template for the supplied definition and key. - * For more information see the documentation for `IFilterTemplateMap` - */ - getTemplateUrl(filterDef: string | IFilterTemplateDef, filterKey?: string): string, - /** - * Return the url of the html filter template registered with the alias supplied - */ - getUrlForAlias(aliasName: string, filterKey?: string): string - } - - interface InternalTableParams extends NgTableParams { - isNullInstance: boolean - } - - /** - * A custom object that can be registered with an NgTableParams instance that can be used - * to post-process the results (and failures) returned by its `getData` function - */ - interface IInterceptor { - response?: (data: TData, params: NgTableParams) => TData; - responseError?: (reason: any, params: NgTableParams) => any; - } - - type SelectData = ISelectOption[] | ISelectDataFunc - - interface ISelectOption { - id: string | number; - title: string; - } - - interface ISelectDataFunc { - (): ISelectOption[] | ng.IPromise - } - - /** - * Definition of the constructor function that will construct new instances of `NgTableParams`. - * On construction of `NgTableParams` the `ngTableEventsChannel` will fire its `afterCreated` event. - */ - interface ITableParamsConstructor { - new (baseParameters?: IParamValues, baseSettings?: ISettings): NgTableParams - } - - - namespace Data { - - type DataResult = T | IDataRowGroup; - - interface IDataRowGroup { - data: T[]; - $hideRows: boolean; - value: string; - } - - /** - * A default implementation of the getData function that will apply the `filter`, `orderBy` and - * paging values from the `NgTableParams` instance supplied to the data array supplied. - * - * A call to this function will: - * - return the resulting array - * - assign the total item count after filtering to the `total` of the `NgTableParams` instance supplied - */ - interface IDefaultGetData { - (data: T[], params: NgTableParams): T[]; - /** - * Convenience function that this service will use to apply paging to the data rows. - * - * Returns a slice of rows from the `data` array supplied and sets the `NgTableParams.total()` - * on the `params` instance supplied to `data.length` - */ - applyPaging(data: T[], params: NgTableParams): T[], - /** - * Returns a reference to the function that this service will use to filter data rows - */ - getFilterFn(params: NgTableParams): IFilterFunc, - /** - * Returns a reference to the function that this service will use to sort data rows - */ - getOrderByFn(params?: NgTableParams): void - } - - /** - * Allows for the configuration of the ngTableDefaultGetData service. - */ - interface IDefaultGetDataProvider { - $get(): IDefaultGetData; - /** - * The name of a angular filter that knows how to apply the values returned by - * `NgTableParams.filter()` to restrict an array of data. - * (defaults to the angular `filter` filter service) - */ - filterFilterName: string, - /** - * The name of a angular filter that knows how to apply the values returned by - * `NgTableParams.orderBy()` to sort an array of data. - * (defaults to the angular `orderBy` filter service) - */ - sortingFilterName: string - } - - interface IGetDataBcShimFunc { - (originalFunc: ILegacyGetDataFunc): { (params: NgTableParams): ng.IPromise } - } - - /** - * Signature of a function that will called whenever NgTable requires to load data rows - * into the table. - * `params` is the table requesting the data rows - */ - interface IGetDataFunc { - (params: NgTableParams): T[] | ng.IPromise; - } - - interface IGetGroupFunc { - (params: NgTableParams): { [name: string]: IDataRowGroup[] } - } - - /** - * Variation of the `IGetDataFunc` function signature that allows for flexibility for - * the shape of the return value. - * Typcially you will use this function signature when you want to configure `NgTableParams` with - * interceptors that will return the final data rows array. - */ - interface IInterceptableGetDataFunc { - (params: NgTableParams): TResult; - } - - interface ILegacyGetDataFunc { - ($defer: ng.IDeferred, params: NgTableParams): void - } - } - - namespace Events { - interface IEventSelectorFunc { - (publisher: NgTableParams): boolean - } - - type EventSelector = NgTableParams | IEventSelectorFunc - - interface IDatasetChangedListener { - (publisher: NgTableParams, newDataset: T[], oldDataset: T[]): any - } - interface IAfterCreatedListener { - (publisher: NgTableParams): any - } - interface IAfterReloadDataListener { - (publisher: NgTableParams, newData: NgTable.Data.DataResult[], oldData: NgTable.Data.DataResult[]): any - } - interface IPagesChangedListener { - (publisher: NgTableParams, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): any - } - - interface IUnregistrationFunc { - (): void - } - - interface IEventsChannel { - /** - * Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed. - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a - * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. - * - * @param listener the function that will be called when the event fires - * @param scope the angular `$scope` that will limit the lifetime of the event subscription - * @param eventFilter a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onAfterCreated(listener: Events.IAfterCreatedListener, scope: ng.IScope, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc; - /** - * Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed. - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. - * - * @param listener the function that will be called when the event fires - * @param eventFilter a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onAfterCreated(listener: Events.IAfterCreatedListener, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc; - /** - * Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a - * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. - * - * @param listener the function that will be called when the event fires - * @param scope the angular `$scope` that will limit the lifetime of the event subscription - * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onAfterReloadData(listener: Events.IAfterReloadDataListener, scope: ng.IScope, eventFilter?: Events.EventSelector): IUnregistrationFunc; - /** - * Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. - * - * @param listener the function that will be called when the event fires - * @param eventFilter a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onAfterReloadData(listener: Events.IAfterReloadDataListener, eventFilter?: Events.EventSelector): IUnregistrationFunc; - - /** - * Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance. - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a - * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. - * - * @param listener the function that will be called when the event fires - * @param scope the angular `$scope` that will limit the lifetime of the event subscription - * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onDatasetChanged(listener: Events.IDatasetChangedListener, scope: ng.IScope, eventFilter?: Events.EventSelector): IUnregistrationFunc; - /** - * Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance. - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. - * - * @param listener the function that will be called when the event fires - * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onDatasetChanged(listener: Events.IDatasetChangedListener, eventFilter?: Events.EventSelector): IUnregistrationFunc; - - /** - * Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a - * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. - * - * @param listener the function that will be called when the event fires - * @param scope the angular `$scope` that will limit the lifetime of the event subscription - * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onPagesChanged(listener: Events.IPagesChangedListener, scope: ng.IScope, eventFilter?: Events.EventSelector): IUnregistrationFunc; - /** - * Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change - * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. - * - * @param listener the function that will be called when the event fires - * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event - * @return a unregistration function that when called will unregister the `listener` - */ - onPagesChanged(listener: Events.IPagesChangedListener, eventFilter?: Events.EventSelector): IUnregistrationFunc; - - publishAfterCreated(publisher: NgTableParams): void; - publishAfterReloadData(publisher: NgTableParams, newData: T[], oldData: T[]): void; - publishDatasetChanged(publisher: NgTableParams, newDataset: T[], oldDataset: T[]): void; - publishPagesChanged(publisher: NgTableParams, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): void; - } - } - - namespace Columns { - - type ColumnFieldContext = ng.IScope & { - $column: IColumnDef; - $columns: IColumnDef[]; - } - - interface IColumnField { - (context?: ColumnFieldContext): T; - assign($scope: ng.IScope, value: T): void; - } - - /** - * The definition of the column within a ngTable. - * When using `ng-table` directive a column definition will be parsed from each `td` tag found in the - * `tr` data row tag. - * - * @example - * - * - * - * - */ - interface IColumnDef { - /** - * Custom CSS class that should be added to the `th` tag(s) of this column in the table header - * - * To set this on the `td` tag of a html table use the attribute `header-class` or `data-header-class` - */ - class: IColumnField; - /** - * The `ISelectOption`s that can be used in a html filter template for this colums. - */ - data?: SelectData; - /** - * The index position of this column within the `$columns` container array - */ - id: number; - /** - * The definition of 0 or more html filter templates that should be rendered for this column in - * the table header - */ - filter: IColumnField; - /** - * Supplies the `ISelectOption`s that can be used in a html filter template for this colums. - * At the creation of the `NgTableParams` this field will be called and the result then assigned - * to the `data` field of this column. - */ - filterData: IColumnField | SelectData>; - /** - * The name of the data row field that will be used to group on, or false when this column - * does not support grouping - */ - groupable: IColumnField; - /** - * The url of a custom html template that should be used to render a table header for this column - * - * To set this on the `td` tag for a html table use the attribute `header` or `data-header` - */ - headerTemplateURL: IColumnField; - /** - * The text that should be used as a tooltip for this column in the table header - */ - headerTitle: IColumnField; - /** - * Determines whether this column should be displayed in the table - * - * To set this on the `td` tag for a html table use the attribute `ng-if` - */ - show: IColumnField; - /** - * The name of the data row field that will be used to sort on, or false when this column - * does not support sorting - */ - sortable: IColumnField; - /** - * The title of this column that should be displayed in the table header - */ - title: IColumnField; - /** - * An alternate column title. Typically this can be used for responsive table layouts - * where the titleAlt should be used for small screen sizes - */ - titleAlt: IColumnField; - } - - type DynamicTableColField = IDynamicTableColFieldFunc | T; - - interface IDynamicTableColFieldFunc { - (context: ColumnFieldContext): T; - } - - /** - * The definition of the column supplied to a ngTableDynamic directive. - */ - interface IDynamicTableColDef { - /** - * Custom CSS class that should be added to the `th` tag(s) of this column in the table header - */ - class?: DynamicTableColField; - /** - * The definition of 0 or more html filter templates that should be rendered for this column in - * the table header - */ - filter?: DynamicTableColField; - /** - * Supplies the `ISelectOption`s that can be used in a html filter template for this colums. - * At the creation of the `NgTableParams` this field will be called and the result then assigned - * to the `data` field of this column. - */ - filterData?: DynamicTableColField | SelectData>; - /** - * The name of the data row field that will be used to group on, or false when this column - * does not support grouping - */ - groupable?: DynamicTableColField; - /** - * The url of a custom html template that should be used to render a table header for this column - */ - headerTemplateURL?: DynamicTableColField; - /** - * The text that should be used as a tooltip for this column in the table header - */ - headerTitle?: DynamicTableColField; - /** - * Determines whether this column should be displayed in the table - */ - show?: DynamicTableColField; - /** - * The name of the data row field that will be used to sort on, or false when this column - * does not support sorting - */ - sortable?: DynamicTableColField; - /** - * The title of this column that should be displayed in the table header - */ - title?: DynamicTableColField; - /** - * An alternate column title. Typically this can be used for responsive table layouts - * where the titleAlt should be used for small screen sizes - */ - titleAlt?: DynamicTableColField; - } - } -} - diff --git a/ng-table/ng-table-tests.ts b/ng-table/ng-table-tests.ts deleted file mode 100644 index e8c9c44e4d..0000000000 --- a/ng-table/ng-table-tests.ts +++ /dev/null @@ -1,114 +0,0 @@ - - -interface IPerson { - age: number; - name: string; -} - -function printPerson(p: IPerson) { - console.log('age: ' + p.age); - console.log('name: ' + p.name); -} - -// NgTableParams signature tests -namespace NgTableParamsTests { - - let initialParams: NgTable.IParamValues = { - filter: { name: 'Christian' }, - sorting: { age: 'asc' } - }; - let settings: NgTable.ISettings = { - dataset: [{ age: 1, name: 'Christian' }, { age: 2, name: 'Lee' }, { age: 40, name: 'Christian' }], - filterOptions: { - filterComparator: true, - filterDelay: 100 - }, - counts: [10, 20, 50] - }; - - export let tableParams = new NgTableParams(initialParams, settings); - - // modify parameters - tableParams.filter({ name: 'Lee' }); - tableParams.sorting('age', 'desc'); - tableParams.count(10); - tableParams.group(item => (item.age * 10).toString()); - - // modify settings at runtime - tableParams.settings({ - dataset: [{ age: 1, name: 'Brandon' }, { age: 2, name: 'Lee' }] - }); - - tableParams.reload().then(rows => { - rows.forEach(printPerson); - }); -} - -// Dynamic table column signature tests -namespace ColumnTests { - interface ICustomColFields { - field: string; - } - let dynamicCols: (NgTable.Columns.IDynamicTableColDef & ICustomColFields)[]; - - dynamicCols.push({ - class: () => 'table', - field: 'age', - filter: { age: 'number' }, - sortable: true, - show: true, - title: 'Age of Person', - titleAlt: 'Age' - }); -} - -namespace EventsTests { - declare let events: NgTable.Events.IEventsChannel; - - let unregistrationFuncs: NgTable.Events.IUnregistrationFunc[] = []; - let x: NgTable.Events.IUnregistrationFunc; - - x = events.onAfterCreated(params => { - // do stuff - }); - unregistrationFuncs.push(x); - - x = events.onAfterReloadData((params, newData, oldData) => { - newData.forEach(row => { - if (isDataGroup(row)) { - row.data.forEach(printPerson) - } else { - printPerson(row); - } - }); - }, NgTableParamsTests.tableParams); - unregistrationFuncs.push(x); - - x = events.onDatasetChanged((params, newDataset, oldDataset) => { - if (newDataset != null) { - newDataset.forEach(printPerson); - } - }, NgTableParamsTests.tableParams); - unregistrationFuncs.push(x); - - x = events.onPagesChanged((params, newButtons, oldButtons) => { - newButtons.forEach(printPageButton); - }, NgTableParamsTests.tableParams); - unregistrationFuncs.push(x); - - unregistrationFuncs.forEach(f => { - f(); - }); - - - function printPageButton(btn: NgTable.IPageButton) { - console.log('type: ' + btn.type); - console.log('number: ' + btn['number']); - console.log('current: ' + btn.current); - console.log('active: ' + btn.active); - } - - function isDataGroup(row: any): row is NgTable.Data.IDataRowGroup { - return ('$hideRows' in row); - } -} \ No newline at end of file diff --git a/node-forge/index.d.ts b/node-forge/index.d.ts index 7e0cae19df..b39ede7ac4 100644 --- a/node-forge/index.d.ts +++ b/node-forge/index.d.ts @@ -34,4 +34,11 @@ declare module "node-forge" { export function generateKeyPair(options?: GenerateKeyPairOptions, callback?: (err: Error, keypair: KeyPair) => void): KeyPair; } } + + export namespace ssh { + /** + * Encodes a private RSA key as an OpenSSH file. + */ + export function privateKeyToOpenSSH(privateKey?: string, passphrase?: string): string; + } } diff --git a/node-forge/node-forge-tests.ts b/node-forge/node-forge-tests.ts index 16538ad84f..7ed36e50e2 100644 --- a/node-forge/node-forge-tests.ts +++ b/node-forge/node-forge-tests.ts @@ -3,3 +3,5 @@ import * as forge from "node-forge"; let keypair = forge.pki.rsa.generateKeyPair({bits: 512}); let privateKeyPem = forge.pki.privateKeyToPem(keypair.privateKey); let publicKeyPem = forge.pki.publicKeyToPem(keypair.publicKey); + +let x: string = forge.ssh.privateKeyToOpenSSH(); diff --git a/notNeededPackages.json b/notNeededPackages.json index 625683156e..88ede42075 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -10,6 +10,12 @@ "typingsPackageName": "moment", "sourceRepoURL": "https://github.com/moment/moment", "asOfVersion": "2.13.0" + }, + { + "libraryName": "ng-table", + "typingsPackageName": "ng-table", + "sourceRepoURL": "https://github.com/esvit/ng-table", + "asOfVersion": "2.0.1" } ] } diff --git a/openlayers/index.d.ts b/openlayers/index.d.ts index f7f11d8ebf..5d72ce5711 100644 --- a/openlayers/index.d.ts +++ b/openlayers/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for OpenLayers v3.6.0 +// Type definitions for OpenLayers v3.18.2 // Project: http://openlayers.org/ // Definitions by: Olivier Sechet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -13786,4 +13786,4 @@ declare module olx { declare module "openlayers" { export = ol; -} \ No newline at end of file +} diff --git a/oracledb/index.d.ts b/oracledb/index.d.ts index a6449fff1e..17ade85591 100644 --- a/oracledb/index.d.ts +++ b/oracledb/index.d.ts @@ -1,589 +1,684 @@ -// Type definitions for oracledb v1.5.0 +// Type definitions for oracledb v1.11.0 // Project: https://github.com/oracle/node-oracledb // Definitions by: Richard Natal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +import * as stream from 'stream'; +import * as events from 'events'; -import * as stream from "stream"; +declare namespace oracledb { -export type TRet = T | IPromise; -export type TFunc = (value: T) => TRet; + type TRet = T | IPromise; + type TFunc = (value: T) => TRet; -export interface IPromise { - catch(onReject: TFunc) : IPromise; - then(onResolve?: TFunc, onReject?: TFunc) : IPromise; + interface IPromise { + catch(onReject: TFunc) : IPromise; + then(onResolve?: TFunc, onReject?: TFunc) : IPromise; + } + + interface ILob { + chunkSize: number; + length: number; + pieceSize: number; + offset?: number; + type: string; + /** + * Release method on ILob class. + * @remarks The cleanup() called by Release() only frees OCI error handle and Lob + * locator. These calls acquire mutex on OCI environment handle very briefly. + */ + release?(): void; + /** + * Read method on ILob class. + * @param {(err : any, chunk: string | Buffer) => void} callback Callback to recive the data from lob. + * @remarks CLobs send strings while BLobs send Buffer object. + */ + read?(callback: (err: any, chunk: string | Buffer) => void): void; + /** + * Read method on ILob class. + * @param {Buffer} data Data write into Lob. + * @param {(err: any) => void} callback Callback executed when writ is finished or when some error occured. + * @remarks CLobs send strings while BLobs send Buffer object. + */ + write?(data: Buffer, callback: (err: any) => void): void; + } + + /* tslint:disable-next-line:interface-name */ + interface Lob extends stream.Duplex { + iLob: ILob; + /** This corresponds to the size used by the Oracle LOB layer when accessing or modifying the LOB value. */ + chunkSize: number; + /** Length of a queried LOB in bytes (for BLOBs) or characters (for CLOBs). */ + length: number; + /** + * he number of bytes (for BLOBs) or characters (for CLOBs) to read for each Stream 'data' event of a queried LOB. + * The default value is chunkSize. + * For efficiency, it is recommended that pieceSize be a multiple of chunkSize. + * The maximum value for pieceSize is limited to the value of UINT_MAX. + */ + pieceSize: number; + /** + * This read-only attribute shows the type of Lob being used. It will have the value of one of the constants Oracledb.BLOB or Oracledb.CLOB. The value is derived from the bind type when using LOB bind variables, or from the column type when a LOB is returned by a query. + */ + type: number; + + /** + * Do not call this... used internally by node-oracledb + */ + constructor(iLob: ILob, opts: stream.DuplexOptions): Lob; + constructor(iLob: ILob): Lob; + + /** + * Closes the current LOB. + * @param {(err: any) => void} callback? When passed, is called after the release. + * @returns void + */ + close(callback: (err: any) => void): void; + close(): void; + } + + interface IConnectionAttributes { + user?: string; + password?: string; + connectString: string; + stmtCacheSize?: number; + externalAuth?: boolean; + /** If not passed, "default" will be used. */ + poolAlias?: string; + } + + interface IPoolAttributes extends IConnectionAttributes { + poolMax?: number; + poolMin?: number; + poolIncrement?: number; + poolTimeout?: number; + } + + interface IExecuteOptions { + /** + * Transaction should auto commit after each statement? + * Overrides Oracledb autoCommit. + */ + autoCommit?: boolean; + /** + * Determines whether additional metadata is available for queries and for REF CURSORs returned from PL/SQL blocks. + * Overrides Oracledb extendedMetaData. + */ + extendedMetaData?: boolean; + /** + * Object defining how query column data should be represented in JavaScript. + * The fetchInfo property can be used to indicate that number or date columns in a query should be returned as strings instead of their native format. The property can be used in conjunction with, or instead of, the global setting fetchAsString. + * For example: + * + * fetchInfo: + * { + * "HIRE_DATE": { type : oracledb.STRING }, // return the date as a string + * "COMMISSION_PCT": { type : oracledb.DEFAULT } // override Oracledb.fetchAsString + * } + * + * Each column is specified by name, using Oracle's standard naming convention. + * The valid values for type are STRING and DEFAULT. The former indicates that the given column should be returned as a string. The latter can be used to override any global mapping given by fetchAsString and allow the column data for this query to be returned in native format. + * The maximum length of a string created by type mapping is 200 bytes. However, if a database column that is already of type STRING is specified in fetchInfo, then the actual database metadata will be used to determine the maximum length. + * Columns fetched from REF CURSORS are not mapped by fetchInfo settings in the execute() call. Use the global fetchAsString instead. + */ + fetchInfo?: Object; + /** + * Maximum number of rows that will be retrieved. Used when resultSet is false. + * Overrides Oracledb maxRows. + */ + maxRows?: number; + /** + * Result format - ARRAY o OBJECT + * Overrides Oracledb outFormat. + */ + outFormat?: number; + /** + * Number of rows to be fetched in advance. + * Overrides Oracledb prefetchRows. + */ + prefetchRows?: number; + /** + * Determines whether query results should be returned as a ResultSet object or directly. The default is false. + */ + resultSet?: boolean; + } + + interface IExecuteReturn { + /** Metadata information - column names is always given. If the Oracledb extendedMetaData or execute() option extendedMetaData are true then additional information is included. */ + metaData?: Array; + /** This is either an array or an object containing OUT and IN OUT bind values. If bindParams is passed as an array, then outBinds is returned as an array. If bindParams is passed as an object, then outBinds is returned as an object. */ + outBinds?: Array | Object; + /** For SELECT statements when the resultSet option is true, use the resultSet object to fetch rows. See ResultSet Class. */ + resultSet?: IResultSet; + /** For SELECT statements where the resultSet option is false or unspecified, rows contains an array of fetched rows. It will be NULL if there is an error or the SQL statement was not a SELECT statement. By default, the rows are in an array of column value arrays, but this can be changed to arrays of objects by setting outFormat to OBJECT. If a single row is fetched, then rows is an array that contains one single row. The number of rows returned is limited to the maxRows configuration property of the Oracledb object, although this may be overridden in any execute() call. */ + rows?: Array> | Array; + /** For DML statements (including SELECT FOR UPDATE) this contains the number of rows affected, for example the number of rows inserted. For non-DML statements such as queries, or if no rows are affected, then rowsAffected will be zero. */ + rowsAffected?: number; + } + + interface IMetaData { + /** The column name follows Oracle's standard name-casing rules. It will commonly be uppercase, since most applications create tables using unquoted, case-insensitive names. */ + name: string; + /** one of the Node-oracledb Type Constant values. */ + fetchType?: number; + /** one of the Node-oracledb Type Constant values. */ + dbType?: number; + /** the database byte size. This is only set for DB_TYPE_VARCHAR, DB_TYPE_CHAR and DB_TYPE_RAW column types. */ + byteSize?: number; + /** set only for DB_TYPE_NUMBER, DB_TYPE_TIMESTAMP, DB_TYPE_TIMESTAMP_TZ and DB_TYPE_TIMESTAMP_LTZ columns. */ + precision?: number; + /** set only for DB_TYPE_NUMBER columns. */ + scale: number; + /** indicates whether NULL values are permitted for this column. */ + nullable?: boolean; + } + + interface IResultSet { + /** + * Contains an array of objects with metadata about the query or REF CURSOR columns. + * Each column's name is always given. If the Oracledb extendedMetaData or execute() option extendedMetaData are true then additional information is included. + */ + metaData?: Array; + + /** + * Closes a ResultSet. Applications should always call this at the end of fetch or when no more rows are needed. + * @param {(err:any)=>void} callback Callback called on finish or when some error occurs. + * @returns void + * @remarks Applications should always call this at the end of fetch or when no more rows are needed. + */ + close(callback: (err: any) => void): void; + + /** + * Closes a ResultSet. Applications should always call this at the end of fetch or when no more rows are needed. + * @returns A void Promise on finish or when some error occurs. + * @remarks Applications should always call this at the end of fetch or when no more rows are needed. + */ + close(): IPromise; + + /** + * This call fetches one row of the result set as an object or an array of column values, depending on the value of outFormat. + * At the end of fetching, the ResultSet should be freed by calling close(). + * @param {(err:any,row:Array|Object)=>void} callback Callback called when the row is available or when some error occurs. + * @returns void + */ + getRow(callback: (err: any, row: Array | Object) => void): void; + + /** + * This call fetches one row of the result set as an object or an array of column values, depending on the value of outFormat. + * At the end of fetching, the ResultSet should be freed by calling close(). + * @returns Promise when the row is available or when some error occurs. + */ + getRow(): IPromise | Object>; + + /** + * This synchronous method converts a ResultSet into a stream. + * It can be used to make ResultSets from top-level queries or from REF CURSOR bind variables streamable. To make top-level queries streamable, the alternative connection.queryStream() method may be easier to use. + * @returns synchronous stream of result set. + */ + toQueryStream(): stream.Readable; + } + + /** Emits "_after_close" event */ + interface IConnection extends events.EventEmitter { + /** + * The action attribute for end-to-end application tracing. + * This is a write-only property. Displaying a Connection object will show a value of null for this attribute. See End-to-end Tracing, Mid-tier Authentication, and Auditing. + */ + action: string; + /** + * The client identifier for end-to-end application tracing, use with mid-tier authentication, and with Virtual Private Databases. + * This is a write-only property. Displaying a Connection object will show a value of null for this attribute. See End-to-end Tracing, Mid-tier Authentication, and Auditing. + */ + clientId: string; + /** + * The module attribute for end-to-end application tracing. + * This is a write-only property. Displaying a Connection object will show a value of null for this attribute. See End-to-end Tracing, Mid-tier Authentication, and Auditing. + */ + module: string; + /** + * This readonly property gives a numeric representation of the Oracle database version. For version a.b.c.d.e, this property gives the number: (100000000 * a) + (1000000 * b) + (10000 * c) + (100 * d) + e + */ + oracleServerVersion: number; + /** + * The number of statements to be cached in the statement cache of the connection. The default value is the stmtCacheSize property in effect in the Pool object when the connection is created in the pool. + */ + stmtCacheSize: number; + + /** + * This call stops the currently running operation on the connection. + * If there is no operation in progress or the operation has completed by the time the break is issued, the break() is effectively a no-op. + * If the running asynchronous operation is interrupted, its callback will return an error. + * @param {(err: any) => void} callback Callback on break done. + */ + break(callback: (err: any) => void): void; + + /** + * This call stops the currently running operation on the connection. + * If there is no operation in progress or the operation has completed by the time the break is issued, the break() is effectively a no-op. + * If the running asynchronous operation is interrupted, its callback will return an error. + * @returns A void promise when break is done. + */ + break(): IPromise; + + /** + * Releases a connection. If the connection was obtained from the pool, the connection is returned to the pool and is available for reuse. + * Note: calling close() when connections are no longer required is strongly encouraged. Releasing helps avoid resource leakage and can improve system efficiency. + * When a connection is released, any ongoing transaction on the connection is rolled back. + * After releasing a connection to a pool, there is no guarantee a subsequent getConnection() call gets back the same database connection. The application must redo any ALTER SESSION statements on the new connection object, as required. + * @param {(err: any) => void} callback Callback on close done. + */ + close(callback: (err: any) => void): void; + + /** + * Releases a connection. If the connection was obtained from the pool, the connection is returned to the pool and is available for reuse. + * Note: calling close() when connections are no longer required is strongly encouraged. Releasing helps avoid resource leakage and can improve system efficiency. + * When a connection is released, any ongoing transaction on the connection is rolled back. + * After releasing a connection to a pool, there is no guarantee a subsequent getConnection() call gets back the same database connection. The application must redo any ALTER SESSION statements on the new connection object, as required. + * @returns A void Promise on close done. + */ + close(): IPromise; + + /** + * Send a commit requisition to the database. + * @param {(err: any) => void} callback Callback on commit done. + */ + commit(callback: (err: any) => void): void; + + /** + * Send a commit requisition to the database. + * @returns A void Promise on commit done. + */ + commit(): IPromise; + + /** + * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. + * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. + * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. + * @param {string} sql SQL Statement. + * @param {Object|Array} bindParams Binds Object/Array + * @param {IExecuteOptions} options Options object + * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. + */ + execute(sql: string, + bindParams: Object | Array, + options: IExecuteOptions, + callback: (err: any, value: IExecuteReturn) => void): void; + + /** + * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. + * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. + * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. + * @param {string} sql SQL Statement. + * @param {Object|Array} bindParams Binds Object/Array + * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. + */ + execute(sql: string, + bindParams: Object | Array, + callback: (err: any, value: IExecuteReturn) => void): void; + + /** + * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. + * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. + * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. + * @param {string} sql SQL Statement. + * @param {IExecuteOptions} options Options object + * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. + */ + execute(sql: string, + options: IExecuteOptions, + callback: (err: any, value: IExecuteReturn) => void): void; + + /** + * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. + * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. + * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. + * @param {string} sql SQL Statement. + * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. + */ + execute(sql: string, + callback: (err: any, value: IExecuteReturn) => void): void; + + /** + * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. + * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. + * @param {string} sql SQL Statement. + * @param {Object|Array} bindParams Binds Object/Array + * @param {IExecuteOptions} options Options object + * @returns A Promise of a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. + */ + execute(sql: string, + bindParams?: Object | Array, + options?: IExecuteOptions): IPromise; + + /** + * This function provides query streaming support. The parameters are the same as execute() except a callback is not used. Instead this function returns a stream used to fetch data. + * Each row is returned as a data event. Query metadata is available via a metadata event. The end event indicates the end of the query results. + * Query results must be fetched to completion to avoid resource leaks. + * The connection must remain open until the stream is completely read. + * For tuning purposes the oracledb.maxRows property can be used to size an internal buffer used by queryStream(). Note it does not limit the number of rows returned by the stream. The oracledb.prefetchRows value will also affect performance. + * @param {string} sql SQL Statement. + * @param {Object|Array} bindParams Binds Object/Array + * @param {IExecuteOptions} options Options object + * @returns Readable Stream for queries. + */ + queryStream(sql: string, + bindParams?: Object | Array, + options?: IExecuteOptions): stream.Readable; + + /** + * An alias for Connection.close(). + * @param {(err: any) => void} callback Callback on close done. + */ + release(callback: (err: any) => void): void; + + /** + * An alias for Connection.close(). + * @returns A void Promise on close done. + */ + release(): IPromise; + + /** + * Send a rollback requisition to database. + * @param {(err: any) => void} callback Callback on rollback done. + */ + rollback(callback: (err: any) => void): void; + + /** + * Send a rollback requisition to database. + * @returns A void Promise on rollback done. + */ + rollback(): IPromise; + } + + /** Emits "_after_close" event */ + interface IConnectionPool extends events.EventEmitter { + /** + * The number of currently active connections in the connection pool i.e. the number of connections currently checked-out using getConnection(). + */ + connectionsInUse: number; + /** + * The number of currently open connections in the underlying connection pool. + */ + connectionsOpen: number; + /** + * The readonly alias of this pool in the connection pool cache. An alias cannot be changed once the pool has been created. + */ + poolAlias: string; + /** + * The number of connections that are opened whenever a connection request exceeds the number of currently open connections. + */ + poolIncrement: number; + /** + * The maximum number of connections that can be open in the connection pool. + */ + poolMax: number; + /** + * The minimum number of connections a connection pool maintains, even when there is no activity to the target database. + */ + poolMin: number; + /** + * The time (in seconds) after which the pool terminates idle connections (unused in the pool). The number of connections does not drop below poolMin. + */ + poolTimeout: number; + /** + * Determines whether requests for connections from the pool are queued when the number of connections "checked out" from the pool has reached the maximum number specified by poolMax. + */ + queueRequests: number; + /** + * The time (in milliseconds) that a connection request should wait in the queue before the request is terminated. + */ + queueTimeout: number; + /** + * The number of statements to be cached in the statement cache of each connection. + */ + stmtCacheSize: number; + + /** + * Finalizes the connection pool. + * @param {(err:any)=>void} callback Callback called when the pool is terminated or when some error occurs + * @returns void + */ + close(callback: (err: any) => void): void; + + /** + * Finalizes the connection pool. + * @returns Promise to when the close finishes. + */ + close(): IPromise; + + /** + * This method obtains a connection from the connection pool. + * If a previously opened connection is available in the pool, that connection is returned. If all connections in the pool are in use, a new connection is created and returned to the caller, as long as the number of connections does not exceed the specified maximum for the pool. If the pool is at its maximum limit, the getConnection() call results in an error, such as ORA-24418: Cannot open further sessions. + * @param {(err:any,connection:IConnection)=>void} callback Callback called when the connection is available or when some error occurs. + * @returns void + * @see {@link https://jsao.io/2015/03/making-a-wrapper-module-for-the-node-js-driver-for-oracle-database/} + * @see {@link https://github.com/OraOpenSource/orawrap} + */ + getConnection(callback: (err: any, connection: IConnection) => void): void; + + /** + * This method obtains a connection from the connection pool. + * If a previously opened connection is available in the pool, that connection is returned. If all connections in the pool are in use, a new connection is created and returned to the caller, as long as the number of connections does not exceed the specified maximum for the pool. If the pool is at its maximum limit, the getConnection() call results in an error, such as ORA-24418: Cannot open further sessions. + * @returns An IConnection Promise to when the connection is available or when some error occurs. + * @see {@link https://jsao.io/2015/03/making-a-wrapper-module-for-the-node-js-driver-for-oracle-database/} + * @see {@link https://github.com/OraOpenSource/orawrap} + */ + getConnection(): IPromise; + + /** + * An alias for IConnectionPool.close(). + * @param {(err:any)=>void} callback Callback called when the pool is terminated or when some error occurs + * @returns void + */ + terminate(callback: (err: any) => void): void; + + /** + * An alias for IConnectionPool.close(). + * @returns Promise to when the close finishes. + */ + terminate(): IPromise; + } + + /* tslint:disable no-unused-variable */ + const DEFAULT: number; + /** Metadata return type */ + const DB_TYPE_VARCHAR: number; + /** Metadata return type */ + const DB_TYPE_NUMBER: number; + /** Metadata return type */ + const DB_TYPE_DATE: number; + /** Metadata return type */ + const DB_TYPE_RAW: number; + /** Metadata return type */ + const DB_TYPE_CHAR: number; + /** Metadata return type */ + const DB_TYPE_BINARY_FLOAT: number; + /** Metadata return type */ + const DB_TYPE_BINARY_DOUBLE: number; + /** Metadata return type */ + const DB_TYPE_ROWID: number; + /** Metadata return type */ + const DB_TYPE_CLOB: number; + /** Metadata return type */ + const DB_TYPE_BLOB: number; + /** Metadata return type */ + const DB_TYPE_TIMESTAMP: number; + /** Metadata return type */ + const DB_TYPE_TIMESTAMP_TZ: number; + /** Metadata return type */ + const DB_TYPE_TIMESTAMP_LTZ: number; + /** Data type */ + const STRING: number; + /** Data type */ + const NUMBER: number; + /** Data type */ + const DATE: number; + /** Data type */ + const CURSOR: number; + /** Data type */ + const BUFFER: number; + /** Data type */ + const CLOB: number; + /** Data type */ + const BLOB: number; + /** Bind direction */ + const BIND_IN: number; + /** Bind direction */ + const BIND_INOUT: number; + /** Bind direction */ + const BIND_OUT: number; + /** outFormat */ + const ARRAY: number; + /** outFormat */ + const OBJECT: number; + + /** + * Do not use this method - used internally by node-oracledb. + */ + function newLob(iLob: ILob): Lob; + + /* tslint:disable no-var-keyword */ + /** Default transaction behaviour of auto commit for each statement. */ + var autoCommit: boolean; + /** + * The user-chosen Connection class value defines a logical name for connections. Most single purpose applications should set connectionClass when using a connection pool or DRCP. + * When a pooled session has a connection class, Oracle ensures that the session is not shared outside of that connection class. + */ + var connectionClass: string; + /** + * Determines whether additional metadata is available for queries and for REF CURSORs returned from PL/SQL blocks. + * The default value for extendedMetaData is false. With this value, the result.metaData result.resultSet.metaData objects only include column names. + */ + var extendedMetaData: boolean; + /** Default authentication/authorization method. When true, the SO trusted user will be used. */ + var externalAuth: boolean; + /** + * An array of node-oracledb types. When any column having the specified type is queried with execute(), the column data is returned as a string instead of the native representation. For column types not specified in fetchAsString, native types will be returned. + * By default all columns are returned as native types. + */ + var fetchAsString: Array; + /** Default size in bytes that the driver will fetch from LOBs in advance. */ + var lobPrefetchSize: number; + /** Default maximum number of rows to be fetched in statements not using ResultSets */ + var maxRows: number; + /** Version of OCI that is used. */ + var oracleClientVersion: number; + /** Default format for returning rows. When ARRAY, it will return Array>. When OBJECT, it will return Array. */ + var outFormat: number; + /** Default number of connections to increment when available connections reach 0 in created pools. poolMax will be respected. */ + var poolIncrement: number; + /** Default maximum connections in created pools */ + var poolMax: number; + /** Default minimum connections in created pools */ + var poolMin: number; + /** Default timeout for unused connections in pool to be released. poolMin will be respected. */ + var poolTimeout: number; + /** Default number of rows that the driver will fetch in each query. */ + var prefetchRows: number; + /** + * Readonly reference to the native oracledb. + */ + var Oracledb: any; + /** + * Readonly reference to the native connection object. + */ + var Connection: any; + /** + * Readonly reference to the native Lob object. + */ + var Lob: any; + /** + * Reference to the native ResultSet object. + */ + var ResultSet: any; + /** + * Node-oracledb supports Promises on all methods. The standard Promise library is used in Node 0.12 and greater. + * Promise support is not enabled by default in Node 0.10. + * You can change the Promisse library to any default ES6 compatible library (like bluebird). + */ + var Promise: any; + /** + * If this property is true and the number of connections "checked out" from the pool has reached the number specified by poolMax, then new requests for connections are queued until in-use connections are released. + * If this property is false and a request for a connection is made from a pool where the number of "checked out" connections has reached poolMax, then an ORA-24418 error indicating that further sessions cannot be opened will be returned. + * The default value is true. + */ + var queueRequests: boolean; + /** + * The number of milliseconds after which connection requests waiting in the connection request queue are terminated. If queueTimeout is 0, then queued connection requests are never terminated. + * The default value is 60000. + */ + var queueTimeout: number; + /** Default size of statements cache. Used to speed up creating queries. */ + var stmtCacheSize: number; + /** node-oracledb driver version. */ + var version: number; + + /** + * Creates a database managed connection pool. + * @param {IPoolAttributes} poolAttributes Parameters to stablish the connection pool. + * @param {(err:any,connection:IConnectionPool)=>void} callback Callback to run when the connection pool gets created or when some error occurs. + * @returns void + */ + function createPool(poolAttributes: IPoolAttributes, callback: (err: any, connection: IConnectionPool) => void): void; + + /** + * Creates a database managed connection pool. + * @param {IPoolAttributes} poolAttributes Parameters to stablish the connection pool. + * @returns Promise {(connection:IConnectionPool)=>any} Promise with the connection pool. + */ + function createPool(poolAttributes: IPoolAttributes): IPromise< IConnectionPool >; + + /** + * Retrieves a connection pool from cache. If it does not exists, an error will be thrown. + * @param {string} alias The index of the cache for the pool. If none is passed, it will use the default one. + * @returns The connection pool or throws an error if it was not found. + */ + function getPool(poolAlias?: string): IConnectionPool; + + /** + * Creates a connection with the database - the pool alias will be "default". + * @param {(err:any,connection:IConnection)=>void} callback Callback to run when the connection gets stablished or when some error occurs. + * @returns void + */ + function getConnection(callback: (err: any, connection: IConnection) => void): void; + + /** + * Creates a connection with the database. + * @param {string} poolAlias Poll from which the connection should be retrieved. + * @param {(err:any,connection:IConnection)=>void} callback Callback to run when the connection gets stablished or when some error occurs. + * @returns void + */ + function getConnection(poolAlias: string, callback: (err: any, connection: IConnection) => void): void; + + /** + * Creates a connection with the database. + * @param {IConnectionAttributes} connectionAttributes Parameters to stablish the connection. + * @param {(err:any,connection:IConnection)=>void} callback Callback to run when the connection gets stablished or when some error occurs. + * @returns void + */ + function getConnection(connectionAttributes: IConnectionAttributes, callback: (err: any, connection: IConnection) => void): void; + + /** + * Creates a connection with the database. The pool name will be "default". + * @returns {(connection:IConnection)=>any} Promise with the connection. + */ + function getConnection(): IPromise< IConnection >; + + /** + * Creates a connection with the database. + * @param {string} poolAlias Poll from which the connection should be retrieved. + * @returns {(connection:IConnection)=>any} Promise with the connection. + */ + function getConnection(poolAlias: string): IPromise< IConnection >; + + /** + * Creates a connection with the database. + * @param {IConnectionAttributes} connectionAttributes Parameters to stablish the connection. + * @returns {(connection:IConnection)=>any} Promise with the connection. + */ + function getConnection(connectionAttributes: IConnectionAttributes): IPromise< IConnection >; } -export interface ILob { - chunkSize: number; - length: number; - pieceSize: number; - offset?: number; - type: string; - /** - * Release method on ILob class. - * @remarks The cleanup() called by Release() only frees OCI error handle and Lob - * locator. These calls acquire mutex on OCI environment handle very briefly. - */ - release?(): void; - /** - * Read method on ILob class. - * @param {(err : any, chunk: string | Buffer) => void} callback Callback to recive the data from lob. - * @remarks CLobs send strings while BLobs send Buffer object. - */ - read?(callback: (err: any, chunk: string | Buffer) => void): void; - /** - * Read method on ILob class. - * @param {Buffer} data Data write into Lob. - * @param {(err: any) => void} callback Callback executed when writ is finished or when some error occured. - * @remarks CLobs send strings while BLobs send Buffer object. - */ - write?(data: Buffer, callback: (err: any) => void): void; -} - -export interface Lob extends stream.Duplex { - iLob: ILob; - /** This corresponds to the size used by the Oracle LOB layer when accessing or modifying the LOB value. */ - chunkSize: number; - /** Length of a queried LOB in bytes (for BLOBs) or characters (for CLOBs). */ - length: number; - /** - * he number of bytes (for BLOBs) or characters (for CLOBs) to read for each Stream 'data' event of a queried LOB. - * The default value is chunkSize. - * For efficiency, it is recommended that pieceSize be a multiple of chunkSize. - * The maximum value for pieceSize is limited to the value of UINT_MAX. - */ - pieceSize: number; - /** - * This read-only attribute shows the type of Lob being used. It will have the value of one of the constants Oracledb.BLOB or Oracledb.CLOB. The value is derived from the bind type when using LOB bind variables, or from the column type when a LOB is returned by a query. - */ - type: number; - - /** - * Do not call this... used internally by node-oracledb - */ - constructor(iLob: ILob, opts: stream.DuplexOptions): Lob; - constructor(iLob: ILob): Lob; - - /** - * Closes the current LOB. - * @param {(err: any) => void} callback? When passed, is called after the release. - * @returns void - */ - close(callback: (err: any) => void): void; - close(): void; -} - -export interface IConnectionAttributes { - user?: string; - password?: string; - connectString: string; - stmtCacheSize?: number; - externalAuth?: boolean; -} - -export interface IPoolAttributes extends IConnectionAttributes { - poolMax?: number; - poolMin?: number; - poolIncrement?: number; - poolTimeout?: number; -} - -export interface IExecuteOptions { - /** - * Transaction should auto commit after each statement? - * Overrides Oracledb autoCommit. - */ - autoCommit?: boolean; - /** - * Determines whether additional metadata is available for queries and for REF CURSORs returned from PL/SQL blocks. - * Overrides Oracledb extendedMetaData. - */ - extendedMetaData?: boolean; - /** - * Object defining how query column data should be represented in JavaScript. - * The fetchInfo property can be used to indicate that number or date columns in a query should be returned as strings instead of their native format. The property can be used in conjunction with, or instead of, the global setting fetchAsString. - * For example: - * - * fetchInfo: - * { - * "HIRE_DATE": { type : oracledb.STRING }, // return the date as a string - * "COMMISSION_PCT": { type : oracledb.DEFAULT } // override Oracledb.fetchAsString - * } - * - * Each column is specified by name, using Oracle's standard naming convention. - * The valid values for type are STRING and DEFAULT. The former indicates that the given column should be returned as a string. The latter can be used to override any global mapping given by fetchAsString and allow the column data for this query to be returned in native format. - * The maximum length of a string created by type mapping is 200 bytes. However, if a database column that is already of type STRING is specified in fetchInfo, then the actual database metadata will be used to determine the maximum length. - * Columns fetched from REF CURSORS are not mapped by fetchInfo settings in the execute() call. Use the global fetchAsString instead. - */ - fetchInfo?: Object; - /** - * Maximum number of rows that will be retrieved. Used when resultSet is false. - * Overrides Oracledb maxRows. - */ - maxRows?: number; - /** - * Result format - ARRAY o OBJECT - * Overrides Oracledb outFormat. - */ - outFormat?: number; - /** - * Number of rows to be fetched in advance. - * Overrides Oracledb prefetchRows. - */ - prefetchRows?: number; - /** - * Determines whether query results should be returned as a ResultSet object or directly. The default is false. - */ - resultSet?: boolean; -} - -export interface IExecuteReturn { - /** Metadata information - column names is always given. If the Oracledb extendedMetaData or execute() option extendedMetaData are true then additional information is included. */ - metaData?: Array; - /** This is either an array or an object containing OUT and IN OUT bind values. If bindParams is passed as an array, then outBinds is returned as an array. If bindParams is passed as an object, then outBinds is returned as an object. */ - outBinds?: Array | Object; - /** For SELECT statements when the resultSet option is true, use the resultSet object to fetch rows. See ResultSet Class. */ - resultSet?: IResultSet; - /** For SELECT statements where the resultSet option is false or unspecified, rows contains an array of fetched rows. It will be NULL if there is an error or the SQL statement was not a SELECT statement. By default, the rows are in an array of column value arrays, but this can be changed to arrays of objects by setting outFormat to OBJECT. If a single row is fetched, then rows is an array that contains one single row. The number of rows returned is limited to the maxRows configuration property of the Oracledb object, although this may be overridden in any execute() call. */ - rows?: Array> | Array; - /** For DML statements (including SELECT FOR UPDATE) this contains the number of rows affected, for example the number of rows inserted. For non-DML statements such as queries, or if no rows are affected, then rowsAffected will be zero. */ - rowsAffected?: number; -} - -export interface IMetaData { - /** The column name follows Oracle's standard name-casing rules. It will commonly be uppercase, since most applications create tables using unquoted, case-insensitive names. */ - name: string; - /** one of the Node-oracledb Type Constant values. */ - fetchType?: number; - /** one of the Node-oracledb Type Constant values. */ - dbType?: number; - /** the database byte size. This is only set for DB_TYPE_VARCHAR, DB_TYPE_CHAR and DB_TYPE_RAW column types. */ - byteSize?: number; - /** set only for DB_TYPE_NUMBER, DB_TYPE_TIMESTAMP, DB_TYPE_TIMESTAMP_TZ and DB_TYPE_TIMESTAMP_LTZ columns. */ - precision?: number; - /** set only for DB_TYPE_NUMBER columns. */ - scale: number; - /** indicates whether NULL values are permitted for this column. */ - nullable?: boolean; -} - -export interface IResultSet { - /** - * Contains an array of objects with metadata about the query or REF CURSOR columns. - * Each column's name is always given. If the Oracledb extendedMetaData or execute() option extendedMetaData are true then additional information is included. - */ - metaData?: Array; - - /** - * Closes a ResultSet. Applications should always call this at the end of fetch or when no more rows are needed. - * @param {(err:any)=>void} callback Callback called on finish or when some error occurs. - * @returns void - * @remarks Applications should always call this at the end of fetch or when no more rows are needed. - */ - close(callback: (err: any) => void): void; - - /** - * Closes a ResultSet. Applications should always call this at the end of fetch or when no more rows are needed. - * @returns A void Promise on finish or when some error occurs. - * @remarks Applications should always call this at the end of fetch or when no more rows are needed. - */ - close(): IPromise; - - /** - * This call fetches one row of the result set as an object or an array of column values, depending on the value of outFormat. - * At the end of fetching, the ResultSet should be freed by calling close(). - * @param {(err:any,row:Array|Object)=>void} callback Callback called when the row is available or when some error occurs. - * @returns void - */ - getRow(callback: (err: any, row: Array | Object) => void): void; - - /** - * This call fetches one row of the result set as an object or an array of column values, depending on the value of outFormat. - * At the end of fetching, the ResultSet should be freed by calling close(). - * @returns Promise when the row is available or when some error occurs. - */ - getRow(): IPromise | Object>; - - /** - * This synchronous method converts a ResultSet into a stream. - * It can be used to make ResultSets from top-level queries or from REF CURSOR bind variables streamable. To make top-level queries streamable, the alternative connection.queryStream() method may be easier to use. - * @returns synchronous stream of result set. - */ - toQueryStream(): stream.Readable; -} - -export interface IConnection { - /** - * The action attribute for end-to-end application tracing. - * This is a write-only property. Displaying a Connection object will show a value of null for this attribute. See End-to-end Tracing, Mid-tier Authentication, and Auditing. - */ - action: string; - /** - * The client identifier for end-to-end application tracing, use with mid-tier authentication, and with Virtual Private Databases. - * This is a write-only property. Displaying a Connection object will show a value of null for this attribute. See End-to-end Tracing, Mid-tier Authentication, and Auditing. - */ - clientId: string; - /** - * The module attribute for end-to-end application tracing. - * This is a write-only property. Displaying a Connection object will show a value of null for this attribute. See End-to-end Tracing, Mid-tier Authentication, and Auditing. - */ - module: string; - /** - * This readonly property gives a numeric representation of the Oracle database version. For version a.b.c.d.e, this property gives the number: (100000000 * a) + (1000000 * b) + (10000 * c) + (100 * d) + e - */ - oracleServerVersion: number; - /** - * The number of statements to be cached in the statement cache of the connection. The default value is the stmtCacheSize property in effect in the Pool object when the connection is created in the pool. - */ - stmtCacheSize: number; - - /** - * This call stops the currently running operation on the connection. - * If there is no operation in progress or the operation has completed by the time the break is issued, the break() is effectively a no-op. - * If the running asynchronous operation is interrupted, its callback will return an error. - * @param {(err: any) => void} callback Callback on break done. - */ - break(callback: (err: any) => void): void; - - /** - * This call stops the currently running operation on the connection. - * If there is no operation in progress or the operation has completed by the time the break is issued, the break() is effectively a no-op. - * If the running asynchronous operation is interrupted, its callback will return an error. - * @returns A void promise when break is done. - */ - break(): IPromise; - - /** - * Releases a connection. If the connection was obtained from the pool, the connection is returned to the pool and is available for reuse. - * Note: calling close() when connections are no longer required is strongly encouraged. Releasing helps avoid resource leakage and can improve system efficiency. - * When a connection is released, any ongoing transaction on the connection is rolled back. - * After releasing a connection to a pool, there is no guarantee a subsequent getConnection() call gets back the same database connection. The application must redo any ALTER SESSION statements on the new connection object, as required. - * @param {(err: any) => void} callback Callback on close done. - */ - close(callback: (err: any) => void): void; - - /** - * Releases a connection. If the connection was obtained from the pool, the connection is returned to the pool and is available for reuse. - * Note: calling close() when connections are no longer required is strongly encouraged. Releasing helps avoid resource leakage and can improve system efficiency. - * When a connection is released, any ongoing transaction on the connection is rolled back. - * After releasing a connection to a pool, there is no guarantee a subsequent getConnection() call gets back the same database connection. The application must redo any ALTER SESSION statements on the new connection object, as required. - * @returns A void Promise on close done. - */ - close(): IPromise; - - /** - * Send a commit requisition to the database. - * @param {(err: any) => void} callback Callback on commit done. - */ - commit(callback: (err: any) => void): void; - - /** - * Send a commit requisition to the database. - * @returns A void Promise on commit done. - */ - commit(): IPromise; - - /** - * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. - * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. - * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. - * @param {string} sql SQL Statement. - * @param {Object|Array} bindParams Binds Object/Array - * @param {IExecuteOptions} options Options object - * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. - */ - execute(sql: string, - bindParams: Object | Array, - options: IExecuteOptions, - callback: (err: any, value: IExecuteReturn) => void): void; - - /** - * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. - * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. - * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. - * @param {string} sql SQL Statement. - * @param {Object|Array} bindParams Binds Object/Array - * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. - */ - execute(sql: string, - bindParams: Object | Array, - callback: (err: any, value: IExecuteReturn) => void): void; - - /** - * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. - * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. - * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. - * @param {string} sql SQL Statement. - * @param {IExecuteOptions} options Options object - * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. - */ - execute(sql: string, - options: IExecuteOptions, - callback: (err: any, value: IExecuteReturn) => void): void; - - /** - * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. - * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. - * A callback function returns a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. - * @param {string} sql SQL Statement. - * @param {(err: any, value: IExecuteReturn) => void} callback Callback function to receive the result. - */ - execute(sql: string, - callback: (err: any, value: IExecuteReturn) => void): void; - - /** - * This call executes a SQL or PL/SQL statement. See SQL Execution for examples. - * The statement to be executed may contain IN binds, OUT or IN OUT bind values or variables, which are bound using either an object or an array. - * @param {string} sql SQL Statement. - * @param {Object|Array} bindParams Binds Object/Array - * @param {IExecuteOptions} options Options object - * @returns A Promise of a result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements. - */ - execute(sql: string, - bindParams?: Object | Array, - options?: IExecuteOptions): IPromise; - - /** - * This function provides query streaming support. The parameters are the same as execute() except a callback is not used. Instead this function returns a stream used to fetch data. - * Each row is returned as a data event. Query metadata is available via a metadata event. The end event indicates the end of the query results. - * Query results must be fetched to completion to avoid resource leaks. - * The connection must remain open until the stream is completely read. - * For tuning purposes the oracledb.maxRows property can be used to size an internal buffer used by queryStream(). Note it does not limit the number of rows returned by the stream. The oracledb.prefetchRows value will also affect performance. - * @param {string} sql SQL Statement. - * @param {Object|Array} bindParams Binds Object/Array - * @param {IExecuteOptions} options Options object - * @returns Readable Stream for queries. - */ - queryStream(sql: string, - bindParams?: Object | Array, - options?: IExecuteOptions): stream.Readable; - - /** - * An alias for Connection.close(). - * @param {(err: any) => void} callback Callback on close done. - */ - release(callback: (err: any) => void): void; - - /** - * An alias for Connection.close(). - * @returns A void Promise on close done. - */ - release(): IPromise; - - /** - * Send a rollback requisition to database. - * @param {(err: any) => void} callback Callback on rollback done. - */ - rollback(callback: (err: any) => void): void; - - /** - * Send a rollback requisition to database. - * @returns A void Promise on rollback done. - */ - rollback(): IPromise -} - -export interface IConnectionPool { - /** - * The number of currently active connections in the connection pool i.e. the number of connections currently checked-out using getConnection(). - */ - connectionsInUse: number; - /** - * The number of currently open connections in the underlying connection pool. - */ - connectionsOpen: number; - /** - * The number of connections that are opened whenever a connection request exceeds the number of currently open connections. - */ - poolIncrement: number; - /** - * The maximum number of connections that can be open in the connection pool. - */ - poolMax: number; - /** - * The minimum number of connections a connection pool maintains, even when there is no activity to the target database. - */ - poolMin: number; - /** - * The time (in seconds) after which the pool terminates idle connections (unused in the pool). The number of connections does not drop below poolMin. - */ - poolTimeout: number; - /** - * Determines whether requests for connections from the pool are queued when the number of connections "checked out" from the pool has reached the maximum number specified by poolMax. - */ - queueRequests: number; - /** - * The time (in milliseconds) that a connection request should wait in the queue before the request is terminated. - */ - queueTimeout: number; - /** - * The number of statements to be cached in the statement cache of each connection. - */ - stmtCacheSize: number; - - /** - * Finalizes the connection pool. - * @param {(err:any)=>void} callback Callback called when the pool is terminated or when some error occurs - * @returns void - */ - close(callback: (err: any) => void): void; - - /** - * Finalizes the connection pool. - * @returns Promise to when the close finishes. - */ - close(): IPromise; - - /** - * This method obtains a connection from the connection pool. - * If a previously opened connection is available in the pool, that connection is returned. If all connections in the pool are in use, a new connection is created and returned to the caller, as long as the number of connections does not exceed the specified maximum for the pool. If the pool is at its maximum limit, the getConnection() call results in an error, such as ORA-24418: Cannot open further sessions. - * @param {(err:any,connection:IConnection)=>void} callback Callback called when the connection is available or when some error occurs. - * @returns void - * @see {@link https://jsao.io/2015/03/making-a-wrapper-module-for-the-node-js-driver-for-oracle-database/} - * @see {@link https://github.com/OraOpenSource/orawrap} - */ - getConnection(callback: (err: any, connection: IConnection) => void): void; - - /** - * This method obtains a connection from the connection pool. - * If a previously opened connection is available in the pool, that connection is returned. If all connections in the pool are in use, a new connection is created and returned to the caller, as long as the number of connections does not exceed the specified maximum for the pool. If the pool is at its maximum limit, the getConnection() call results in an error, such as ORA-24418: Cannot open further sessions. - * @returns An IConnection Promise to when the connection is available or when some error occurs. - * @see {@link https://jsao.io/2015/03/making-a-wrapper-module-for-the-node-js-driver-for-oracle-database/} - * @see {@link https://github.com/OraOpenSource/orawrap} - */ - getConnection(): IPromise; - - /** - * An alias for IConnectionPool.close(). - * @param {(err:any)=>void} callback Callback called when the pool is terminated or when some error occurs - * @returns void - */ - terminate(callback: (err: any) => void): void; - - /** - * An alias for IConnectionPool.close(). - * @returns Promise to when the close finishes. - */ - terminate(): IPromise; -} - -export declare const DEFAULT: number; -/** Data type */ -export declare const STRING: number; -/** Data type */ -export declare const NUMBER: number; -/** Data type */ -export declare const DATE: number; -/** Data type */ -export declare const CURSOR: number; -/** Data type */ -export declare const BUFFER: number; -/** Data type */ -export declare const CLOB: number; -/** Data type */ -export declare const BLOB: number; -/** Bind direction */ -export declare const BIND_IN: number; -/** Bind direction */ -export declare const BIND_INOUT: number; -/** Bind direction */ -export declare const BIND_OUT: number; -/** outFormat */ -export declare const ARRAY: number; -/** outFormat */ -export declare const OBJECT: number; - -/** - * Do not use this method - used internally by node-oracledb. - */ -export declare function newLob(iLob: ILob): Lob; - -/** Default transaction behaviour of auto commit for each statement. */ -export var autoCommit: boolean; -/** - * The user-chosen Connection class value defines a logical name for connections. Most single purpose applications should set connectionClass when using a connection pool or DRCP. - * When a pooled session has a connection class, Oracle ensures that the session is not shared outside of that connection class. - */ -export var connectionClass: string; -/** - * Determines whether additional metadata is available for queries and for REF CURSORs returned from PL/SQL blocks. - * The default value for extendedMetaData is false. With this value, the result.metaData result.resultSet.metaData objects only include column names. - */ -export var extendedMetaData: boolean; -/** Default authentication/authorization method. When true, the SO trusted user will be used. */ -export var externalAuth: boolean; -/** - * An array of node-oracledb types. When any column having the specified type is queried with execute(), the column data is returned as a string instead of the native representation. For column types not specified in fetchAsString, native types will be returned. - * By default all columns are returned as native types. - */ -export var fetchAsString: Array; -/** Default size in bytes that the driver will fetch from LOBs in advance. */ -export var lobPrefetchSize: number; -/** Default maximum number of rows to be fetched in statements not using ResultSets */ -export var maxRows: number; -/** Version of OCI that is used. */ -export var oracleClientVersion: number; -/** Default format for returning rows. When ARRAY, it will return Array>. When OBJECT, it will return Array. */ -export var outFormat: number; -/** Default number of connections to increment when available connections reach 0 in created pools. poolMax will be respected.*/ -export var poolIncrement: number; -/** Default maximum connections in created pools */ -export var poolMax: number; -/** Default minimum connections in created pools */ -export var poolMin: number; -/** Default timeout for unused connections in pool to be released. poolMin will be respected.*/ -export var poolTimeout: number; -/** Default number of rows that the driver will fetch in each query.*/ -export var prefetchRows: number; -/** - * Node-oracledb supports Promises on all methods. The standard Promise library is used in Node 0.12 and greater. Promise support is not enabled by default in Node 0.10. - */ -export var Promise: any; -/** - * If this property is true and the number of connections "checked out" from the pool has reached the number specified by poolMax, then new requests for connections are queued until in-use connections are released. - * If this property is false and a request for a connection is made from a pool where the number of "checked out" connections has reached poolMax, then an ORA-24418 error indicating that further sessions cannot be opened will be returned. - * The default value is true. - */ -export var queueRequests: boolean; -/** - * The number of milliseconds after which connection requests waiting in the connection request queue are terminated. If queueTimeout is 0, then queued connection requests are never terminated. - * The default value is 60000. - */ -export var queueTimeout: number; -/** Default size of statements cache. Used to speed up creating queries.*/ -export var stmtCacheSize: number; -/** node-oracledb driver version. */ -export var version: number; - -/** - * Creates a database managed connection pool. - * @param {IPoolAttributes} poolAttributes Parameters to stablish the connection pool. - * @param {(err:any,connection:IConnectionPool)=>void} callback Callback to run when the connection pool gets created or when some error occurs. - * @returns void - */ -export function createPool(poolAttributes: IPoolAttributes, callback: (err: any, connection: IConnectionPool) => void): void; - -/** - * Creates a database managed connection pool. - * @param {IPoolAttributes} poolAttributes Parameters to stablish the connection pool. - * @returns Promise {(connection:IConnectionPool)=>any} Promise with the connection pool. - */ -export function createPool(poolAttributes: IPoolAttributes): IPromise< IConnectionPool >; - -/** - * Creates a connection with the database. - * @param {IConnectionAttributes} connectionAttributes Parameters to stablish the connection. - * @param {(err:any,connection:IConnection)=>void} callback Callback to run when the connection gets stablished or when some error occurs. - * @returns void - */ -export function getConnection(connectionAttributes: IConnectionAttributes, callback: (err: any, connection: IConnection) => void): void; - -/** - * Creates a connection with the database. - * @param {IConnectionAttributes} connectionAttributes Parameters to stablish the connection. - * @returns {(connection:IConnection)=>any} Promise with the connection. - */ -export function getConnection(connectionAttributes: IConnectionAttributes): IPromise< IConnection >; \ No newline at end of file +export = oracledb; \ No newline at end of file diff --git a/physijs/tests/body.ts b/physijs/tests/body.ts index 83924a9a4d..4cb57a40d9 100644 --- a/physijs/tests/body.ts +++ b/physijs/tests/body.ts @@ -13,20 +13,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '1px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '1px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene(); scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -62,7 +62,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + //// light.shadowDarkness = .7; scene.add( light ); // Materials @@ -71,16 +71,16 @@ initScene = function() { .8, // high friction .4 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); box_material = Physijs.createMaterial( new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/plywood.jpg' ) }), .4, // low friction .6 // high restitution ); - box_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - box_material.map.repeat.set( .25, .25 ); + // box_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // box_material.map.repeat.set( .25, .25 ); // Ground ground = new Physijs.BoxMesh( @@ -131,8 +131,8 @@ render = function() { setMousePosition = function( evt ) { // Find where mouse cursor intersects the ground plane var vector = new THREE.Vector3( - ( evt.clientX / renderer.domElement.clientWidth ) * 2 - 1, - -( ( evt.clientY / renderer.domElement.clientHeight ) * 2 - 1 ), + ( evt.clientX / renderer.dom.clientWidth ) * 2 - 1, + -( ( evt.clientY / renderer.dom.clientHeight ) * 2 - 1 ), .5 ); projector.unprojectVector( vector, camera ); diff --git a/physijs/tests/collisions.ts b/physijs/tests/collisions.ts index 82cb9f9589..6946cf8457 100644 --- a/physijs/tests/collisions.ts +++ b/physijs/tests/collisions.ts @@ -12,20 +12,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -60,7 +60,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + //// light.shadowDarkness = .7; scene.add( light ); // Ground @@ -69,8 +69,8 @@ initScene = function() { .8, // high friction .3 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + //ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); ground = new Physijs.BoxMesh( new THREE.BoxGeometry(100, 1, 100), @@ -89,7 +89,7 @@ initScene = function() { spawnBox = (function() { var box_geometry = new THREE.BoxGeometry( 4, 4, 4 ), - handleCollision = function( collided_with, linearVelocity, angularVelocity ) { + handleCollision = function( collided_with ) { var target = this; target.collisions = 0; switch (++target.collisions) { @@ -127,8 +127,8 @@ spawnBox = (function() { .6, // medium friction .3 // low restitution ); - material.map.wrapS = material.map.wrapT = THREE.RepeatWrapping; - material.map.repeat.set( .5, .5 ); + // material.map.wrapS = material.map.wrapT = THREE.RepeatWrapping; + // material.map.repeat.set( .5, .5 ); //material = new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/rocks.jpg' ) }); @@ -137,7 +137,7 @@ spawnBox = (function() { material ); - box.collisions = 0; + // box.collisions = 0; box.position.set( Math.random() * 15 - 7.5, diff --git a/physijs/tests/compound.ts b/physijs/tests/compound.ts index 36e4a48e1a..c5445d7776 100644 --- a/physijs/tests/compound.ts +++ b/physijs/tests/compound.ts @@ -12,20 +12,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -50, 0 )); @@ -60,7 +60,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // light.shadowDarkness = .7; scene.add( light ); // Materials @@ -69,16 +69,16 @@ initScene = function() { .8, // high friction .4 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); chair_material = Physijs.createMaterial( new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/wood.jpg' ) }), .6, // medium friction .2 // low restitution ); - chair_material.map.wrapS = chair_material.map.wrapT = THREE.RepeatWrapping; - chair_material.map.repeat.set( .25, .25 ); + // chair_material.map.wrapS = chair_material.map.wrapT = THREE.RepeatWrapping; + // chair_material.map.repeat.set( .25, .25 ); // Ground ground = new Physijs.BoxMesh( diff --git a/physijs/tests/constraints_car.ts b/physijs/tests/constraints_car.ts index 4e343c06d1..2863253d63 100644 --- a/physijs/tests/constraints_car.ts +++ b/physijs/tests/constraints_car.ts @@ -14,20 +14,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -62,7 +62,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + //// light.shadowDarkness = .7; scene.add( light ); // Materials @@ -71,8 +71,8 @@ initScene = function() { .8, // high friction .4 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); // Ground ground = new Physijs.BoxMesh( diff --git a/physijs/tests/heightfield.ts b/physijs/tests/heightfield.ts index 30caf48398..d184d705ea 100644 --- a/physijs/tests/heightfield.ts +++ b/physijs/tests/heightfield.ts @@ -17,20 +17,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene({ fixedTimeStep: 1 / 120 }); scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -65,7 +65,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // // light.shadowDarkness = .7; scene.add( light ); // Materials @@ -74,8 +74,8 @@ initScene = function() { .8, // high friction .4 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 2.5, 2.5 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 2.5, 2.5 ); // Ground NoiseGen = new SimplexNoise; @@ -155,7 +155,7 @@ createShape = (function() { break; } - shape.material.color.setRGB( Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100 ); + // shape.material.color.setRGB( Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100 ); shape.castShadow = true; shape.receiveShadow = true; diff --git a/physijs/tests/jenga.ts b/physijs/tests/jenga.ts index 43a4d924de..d4a333f426 100644 --- a/physijs/tests/jenga.ts +++ b/physijs/tests/jenga.ts @@ -12,20 +12,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '1px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '1px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene({ fixedTimeStep: 1 / 120 }); scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -78,7 +78,7 @@ initScene = function() { dir_light.shadowCameraFar = 200; dir_light.shadowBias = -.001 dir_light.shadowMapWidth = dir_light.shadowMapHeight = 2048; - dir_light.shadowDarkness = .5; + // dir_light.shadowDarkness = .5; scene.add( dir_light ); // Materials @@ -87,16 +87,16 @@ initScene = function() { .9, // high friction .2 // low restitution ); - table_material.map.wrapS = table_material.map.wrapT = THREE.RepeatWrapping; - table_material.map.repeat.set( 5, 5 ); + // table_material.map.wrapS = table_material.map.wrapT = THREE.RepeatWrapping; + // table_material.map.repeat.set( 5, 5 ); block_material = Physijs.createMaterial( new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/plywood.jpg' ) }), .4, // medium friction .4 // medium restitution ); - block_material.map.wrapS = block_material.map.wrapT = THREE.RepeatWrapping; - block_material.map.repeat.set( 1, .5 ); + // block_material.map.wrapS = block_material.map.wrapT = THREE.RepeatWrapping; + // block_material.map.repeat.set( 1, .5 ); // Table table = new Physijs.BoxMesh( @@ -179,10 +179,10 @@ initEventHandling = (function() { selected_block = intersections[0].object; _vector.set( 0, 0, 0 ); - selected_block.setAngularFactor( _vector ); - selected_block.setAngularVelocity( _vector ); - selected_block.setLinearFactor( _vector ); - selected_block.setLinearVelocity( _vector ); + // selected_block.setAngularFactor( _vector ); + // selected_block.setAngularVelocity( _vector ); + // selected_block.setLinearFactor( _vector ); + // selected_block.setLinearVelocity( _vector ); mouse_pos.copy( intersections[0].point ); block_offset.subVectors( selected_block.position, mouse_pos ); @@ -225,9 +225,9 @@ initEventHandling = (function() { }; return function() { - renderer.domElement.addEventListener( 'mousedown', handleMouseDown ); - renderer.domElement.addEventListener( 'mousemove', handleMouseMove ); - renderer.domElement.addEventListener( 'mouseup', handleMouseUp ); + renderer.dom.addEventListener( 'mousedown', handleMouseDown ); + renderer.dom.addEventListener( 'mousemove', handleMouseMove ); + renderer.dom.addEventListener( 'mouseup', handleMouseUp ); }; })(); diff --git a/physijs/tests/memorytest-compound.ts b/physijs/tests/memorytest-compound.ts index b755092ac2..a30a56658e 100644 --- a/physijs/tests/memorytest-compound.ts +++ b/physijs/tests/memorytest-compound.ts @@ -17,20 +17,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -81,7 +81,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // // light.shadowDarkness = .7; scene.add( light ); // Ground @@ -90,8 +90,8 @@ initScene = function() { .8, // high friction .3 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); ground = new Physijs.BoxMesh( new THREE.BoxGeometry(100, 1, 100), @@ -119,7 +119,7 @@ spawnBox = (function() { .3 // low restitution ); - material.color.setRGB(Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100); + // material.color.setRGB(Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100); box = new Physijs.BoxMesh( box_geometry, @@ -130,8 +130,8 @@ spawnBox = (function() { material ); - childBox.collisions = 0; - box.collisions = 0; + // childBox.collisions = 0; + // box.collisions = 0; box.add(childBox); box.position.set( diff --git a/physijs/tests/memorytest-convex.ts b/physijs/tests/memorytest-convex.ts index 4a73bd6130..a46183498a 100644 --- a/physijs/tests/memorytest-convex.ts +++ b/physijs/tests/memorytest-convex.ts @@ -17,20 +17,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -81,7 +81,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // light.shadowDarkness = .7; scene.add( light ); // Ground @@ -90,8 +90,8 @@ initScene = function() { .8, // high friction .3 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); ground = new Physijs.BoxMesh( new THREE.BoxGeometry(100, 1, 100), @@ -119,13 +119,13 @@ spawnBox = (function() { .3 // low restitution ); - material.color.setRGB(Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100); + // material.color.setRGB(Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100); box = new Physijs.ConvexMesh( box_geometry, material ); - box.collisions = 0; + // box.collisions = 0; box.position.set( Math.random() * 15 - 7.5, diff --git a/physijs/tests/memorytest.ts b/physijs/tests/memorytest.ts index 4b5d6ac325..d7c2a3ddc3 100644 --- a/physijs/tests/memorytest.ts +++ b/physijs/tests/memorytest.ts @@ -17,20 +17,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -81,7 +81,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // light.shadowDarkness = .7; scene.add( light ); // Ground @@ -90,8 +90,8 @@ initScene = function() { .8, // high friction .3 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); ground = new Physijs.BoxMesh( new THREE.BoxGeometry(100, 1, 100), @@ -119,13 +119,13 @@ spawnBox = (function() { .3 // low restitution ); - material.color.setRGB(Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100); + // material.color.setRGB(Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100); box = new Physijs.BoxMesh( box_geometry, material ); - box.collisions = 0; + // box.collisions = 0; box.position.set( Math.random() * 15 - 7.5, diff --git a/physijs/tests/shapes.ts b/physijs/tests/shapes.ts index b5cecd0262..72f3cda0c2 100644 --- a/physijs/tests/shapes.ts +++ b/physijs/tests/shapes.ts @@ -18,20 +18,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '0px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '0px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene({ fixedTimeStep: 1 / 120 }); scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -66,7 +66,7 @@ initScene = function() { light.shadowCameraFar = 200; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // light.shadowDarkness = .7; scene.add( light ); // Materials @@ -75,8 +75,8 @@ initScene = function() { .8, // high friction .4 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 2.5, 2.5 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 2.5, 2.5 ); // Ground ground = new Physijs.BoxMesh( @@ -204,7 +204,7 @@ createShape = (function() { break; } - shape.material.color.setRGB( Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100 ); + // shape.material.color.setRGB( Math.random() * 100 / 100, Math.random() * 100 / 100, Math.random() * 100 / 100 ); shape.castShadow = true; shape.receiveShadow = true; diff --git a/physijs/tests/vehicle.ts b/physijs/tests/vehicle.ts index b133299a5b..beecaa1c8b 100644 --- a/physijs/tests/vehicle.ts +++ b/physijs/tests/vehicle.ts @@ -18,20 +18,20 @@ initScene = function() { renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.shadowMapEnabled = true; - renderer.shadowMapSoft = true; + // renderer.shadowMapSoft = true; document.getElementById( 'viewport' ).appendChild( renderer.domElement ); render_stats = new Stats(); - render_stats.domElement.style.position = 'absolute'; - render_stats.domElement.style.top = '1px'; - render_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( render_stats.domElement ); + render_stats.dom.style.position = 'absolute'; + render_stats.dom.style.top = '1px'; + render_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( render_stats.dom ); physics_stats = new Stats(); - physics_stats.domElement.style.position = 'absolute'; - physics_stats.domElement.style.top = '50px'; - physics_stats.domElement.style.zIndex = 100; - document.getElementById( 'viewport' ).appendChild( physics_stats.domElement ); + physics_stats.dom.style.position = 'absolute'; + physics_stats.dom.style.top = '50px'; + physics_stats.dom.style.zIndex = '100'; + document.getElementById( 'viewport' ).appendChild( physics_stats.dom ); scene = new Physijs.Scene; scene.setGravity(new THREE.Vector3( 0, -30, 0 )); @@ -84,7 +84,7 @@ initScene = function() { light.shadowCameraFar = 400; light.shadowBias = -.0001 light.shadowMapWidth = light.shadowMapHeight = 2048; - light.shadowDarkness = .7; + // light.shadowDarkness = .7; scene.add( light ); @@ -97,16 +97,16 @@ initScene = function() { .8, // high friction .4 // low restitution ); - ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - ground_material.map.repeat.set( 3, 3 ); + // ground_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // ground_material.map.repeat.set( 3, 3 ); box_material = Physijs.createMaterial( new THREE.MeshLambertMaterial({ map: THREE.ImageUtils.loadTexture( 'images/plywood.jpg' ) }), .4, // low friction .6 // high restitution ); - box_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; - box_material.map.repeat.set( .25, .25 ); + // box_material.map.wrapS = ground_material.map.wrapT = THREE.RepeatWrapping; + // box_material.map.repeat.set( .25, .25 ); // Ground var NoiseGen = new SimplexNoise; diff --git a/pikaday/package.json b/pikaday/package.json index c4decef904..d33ff913ce 100644 --- a/pikaday/package.json +++ b/pikaday/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } diff --git a/random-js/index.d.ts b/random-js/index.d.ts index 81a056e82e..fd3909e508 100644 --- a/random-js/index.d.ts +++ b/random-js/index.d.ts @@ -3,60 +3,67 @@ // Definitions by: Gustavo Di Pietro // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace random { - export function Engine(): number; - export interface Engine { - } +declare module TemporaryName { + + export interface Engine { - export function MT19937 (): number; - export interface MT19937 extends Engine{ - seed (value: number): Engine; - seedWithArray(array: Array): Engine - autoSeed(): Engine; - discard(count: number): Engine; - getUseCount(): Engine; - } + } - export class Random { - constructor (engine?: Engine); + export interface MT19937 extends Engine{ + seed (value: number): Engine; + seedWithArray(array: Array): Engine + autoSeed(): Engine; + discard(count: number): Engine; + getUseCount(): Engine; + } - static engines: { - nativeMath: Engine, - browserCrypto: Engine, - mt19937: () => MT19937 - } - - static integer(min: number, max: number): (engine: Engine) => number; - static real(min: number, max: number, inclusive: boolean): (engine: Engine) => number; - static bool(percentage?: number): (engine: Engine) => boolean; - static bool(numerator: number, denominator: number): (engine: Engine) => boolean; - static pick(engine: Engine, array: Array, begin?: number, end?: number): T; - static picker(array: Array, begin?: number, end?: number): (engine: Engine) => T; - static shuffle(engine: Engine, array: Array): Array; - static sample(engine: Engine, population: Array, sampleSize: number): Array; - static die(sideCount: number): (engine: Engine) => number; - static dice(sideCount: number, dieCount: number): (engine: Engine) => number; - static uuid4(engine: Engine): string; - static string(engine: Engine, length: number): string; - static string(pool: string, length: number): (engine: Engine, length: number) => string; - static hex(upperCase?: boolean): (engine: Engine, length: number) => string; - static date(start: Date, end: Date): (engine: Engine) => Date; - - integer(min: number, max: number): number; - real(min: number, max: number, inclusive: boolean): number; - bool(percentage?: number): (engine: Engine) => boolean; - bool(numerator: number, denominator: number): boolean; - pick(engine: Engine, array: Array, begin?: number, end?: number): T; - picker(array: Array, begin?: number, end?: number): (engine: Engine) => T; - shuffle(engine: Engine, array: Array): Array; - sample(engine: Engine, population: Array, sampleSize: number): Array; - die(sideCount: number): (engine: Engine) => number; - dice(sideCount: number, dieCount: number): number; - uuid4(engine: Engine): string; - string(engine: Engine, length: number): string; - string(pool: string, length: number): string; - hex(upperCase?: boolean): string; - date(start: Date, end: Date): Date; - } } + +declare class TemporaryName { + constructor (engine?: TemporaryName.Engine); + + static engines: { + nativeMath: TemporaryName.Engine, + browserCrypto: TemporaryName.Engine, + mt19937: () => TemporaryName.MT19937 + } + + static Engine(): number; + static MT19937 (): number; + + static integer(min: number, max: number): (engine: TemporaryName.Engine) => number; + static real(min: number, max: number, inclusive: boolean): (engine: TemporaryName.Engine) => number; + static bool(percentage?: number): (engine: TemporaryName.Engine) => boolean; + static bool(numerator: number, denominator: number): (engine: TemporaryName.Engine) => boolean; + static pick(engine: TemporaryName.Engine, array: Array, begin?: number, end?: number): T; + static picker(array: Array, begin?: number, end?: number): (engine: TemporaryName.Engine) => T; + static shuffle(engine: TemporaryName.Engine, array: Array): Array; + static sample(engine: TemporaryName.Engine, population: Array, sampleSize: number): Array; + static die(sideCount: number): (engine: TemporaryName.Engine) => number; + static dice(sideCount: number, dieCount: number): (engine: TemporaryName.Engine) => number; + static uuid4(engine: TemporaryName.Engine): string; + static string(engine: TemporaryName.Engine, length: number): string; + static string(pool: string, length: number): (engine: TemporaryName.Engine, length: number) => string; + static hex(upperCase?: boolean): (engine: TemporaryName.Engine, length: number) => string; + static date(start: Date, end: Date): (engine: TemporaryName.Engine) => Date; + + integer(min: number, max: number): number; + real(min: number, max: number, inclusive: boolean): number; + bool(percentage?: number): (engine: TemporaryName.Engine) => boolean; + bool(numerator: number, denominator: number): boolean; + pick(engine: TemporaryName.Engine, array: Array, begin?: number, end?: number): T; + picker(array: Array, begin?: number, end?: number): (engine: TemporaryName.Engine) => T; + shuffle(engine: TemporaryName.Engine, array: Array): Array; + sample(engine: TemporaryName.Engine, population: Array, sampleSize: number): Array; + die(sideCount: number): (engine: TemporaryName.Engine) => number; + dice(sideCount: number, dieCount: number): number; + uuid4(engine: TemporaryName.Engine): string; + string(engine: TemporaryName.Engine, length: number): string; + string(pool: string, length: number): string; + hex(upperCase?: boolean): string; + date(start: Date, end: Date): Date; +} + +export = TemporaryName; +export as namespace Random; \ No newline at end of file diff --git a/random-js/random-js-tests.ts b/random-js/random-js-ambient-tests.ts similarity index 94% rename from random-js/random-js-tests.ts rename to random-js/random-js-ambient-tests.ts index 77c698e321..177a037dee 100644 --- a/random-js/random-js-tests.ts +++ b/random-js/random-js-ambient-tests.ts @@ -2,8 +2,7 @@ // Examples taken from the documentation at https://github.com/ckknight/random-js // create a Mersenne Twister-19937 that is auto-seeded based on time and other random values -import Engine = random.Engine; -import Random = random.Random; +import Engine = Random.Engine; var engine: Engine = Random.engines.mt19937().autoSeed(); // create a distribution that will consistently produce integers within inclusive range [0, 99]. diff --git a/random-js/random-js-commonjs-tests.ts b/random-js/random-js-commonjs-tests.ts new file mode 100644 index 0000000000..0508aafb32 --- /dev/null +++ b/random-js/random-js-commonjs-tests.ts @@ -0,0 +1,29 @@ +/// + +import Random = require('random-js'); + +// Examples taken from the documentation at https://github.com/ckknight/random-js +// create a Mersenne Twister-19937 that is auto-seeded based on time and other random values +import Engine = Random.Engine; + +var engine: Engine = Random.engines.mt19937().autoSeed(); +// create a distribution that will consistently produce integers within inclusive range [0, 99]. +var distribution: Function = Random.integer(0, 99); +// generate a number that is guaranteed to be within [0, 99] without any particular bias. +function generateNaturalLessThan100(): number { + return distribution(engine); +} + +// using essentially Math.random() +var engine2: Engine = Random.engines.nativeMath; +// lower-case Hex string distribution +var distribution2: Function = Random.hex(false); +// generate a 40-character hex string +function generateSHA1(): string { + return distribution(40); +} + +var r: Random = new Random(Random.engines.mt19937().seedWithArray([0x12345678, 0x90abcdef])); +var value = r.integer(0, 99); + +r = new Random(); // same as new Random(Random.engines.nativeMath) diff --git a/random-js/tsconfig.json b/random-js/tsconfig.json index 357505a668..e1b7b50c26 100644 --- a/random-js/tsconfig.json +++ b/random-js/tsconfig.json @@ -14,6 +14,7 @@ }, "files": [ "index.d.ts", - "random-js-tests.ts" + "random-js-ambient-tests.ts", + "random-js-commonjs-tests.ts" ] } \ No newline at end of file diff --git a/react-datepicker/package.json b/react-datepicker/package.json index 992b24d513..4c6d24a445 100644 --- a/react-datepicker/package.json +++ b/react-datepicker/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "moment": "2.14.*" + "moment": ">=2.14.0" } } \ No newline at end of file diff --git a/react-daterange-picker/package.json b/react-daterange-picker/package.json index bfdab7b7fe..4c6d24a445 100644 --- a/react-daterange-picker/package.json +++ b/react-daterange-picker/package.json @@ -1,5 +1,5 @@ { - "scripts": { - "postinstall": "cd ../moment-range && npm install" - } -} + "dependencies": { + "moment": ">=2.14.0" + } +} \ No newline at end of file diff --git a/react-daterange-picker/tsconfig.json b/react-daterange-picker/tsconfig.json index b0493165b7..658e569c10 100644 --- a/react-daterange-picker/tsconfig.json +++ b/react-daterange-picker/tsconfig.json @@ -8,6 +8,9 @@ "typeRoots": [ "../" ], + "paths": { + "*": ["*", "react-daterange-picker/node_modules/*"] + }, "types": ["moment-range", "react"], "noEmit": true, "forceConsistentCasingInFileNames": true, diff --git a/samchon-collection/samchon-collection.d.ts b/samchon-collection/samchon-collection.d.ts index 5f62a81d42..6d6d7e78e2 100644 --- a/samchon-collection/samchon-collection.d.ts +++ b/samchon-collection/samchon-collection.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Samchon Collection v0.0.2 +// Type definitions for Samchon Collection v0.0.4 // Project: https://github.com/samchon/framework // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ declare module "samchon-collection" { - import collection = samchon.collection; - export = collection; + import collections = samchon.collections; + export = collections; } diff --git a/samchon-framework/index.d.ts b/samchon-framework/index.d.ts index b34eec8e6f..fb3e02bf53 100644 --- a/samchon-framework/index.d.ts +++ b/samchon-framework/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Samchon Framework v2.0.0-beta.8 +// Type definitions for Samchon Framework v2.0.0-gamma.4 // Project: https://github.com/samchon/framework // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,63 +7,110 @@ declare module "samchon-framework" { - export = samchon; + export = samchon; } /** *

Samchon-Framework

* - *

- *

+ * + * * - *

Samchon, a SDN (Software Defined Network) framework.

+ * Samchon, a SDN (Software Defined Network) framework. * - *

With Samchon Framework, you can implement distributed processing system within framework of OOD like - * handling S/W objects (classes). You can realize cloud and distributed system very easily with provided - * system templates and even integration with C++ is possible.

+ * With Samchon Framework, you can implement distributed processing system within framework of OOD like handling S/W + * objects (classes). You can realize cloud and distributed system very easily with provided system templates and even + * integration with C++ is possible. * - *

The goal, ultimate utilization model of Samchon Framework is, building cloud system with NodeJS and - * takING heavy works to C++ distributed systems with provided modules (those are system templates).

+ * The goal, ultimate utilization model of Samchon Framework is, building cloud system with NodeJS and taking heavy works + * to C++ distributed systems with provided modules (those are system templates). * * @git https://github.com/samchon/framework * @author Jeongho Nam */ declare namespace samchon { /** - *

Running on Node.

+ * Running on Node. * - *

Test whether the JavaScript is running on Node.

+ * Test whether the JavaScript is running on Node. * * @references http://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser */ function is_node(): boolean; } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * A {@link Vector} who can detect element I/O events. * - *
    - *
  • insert typed events:
      - *
    • {@link assign}
    • - *
    • {@link insert}
    • - *
    • {@link push}
    • - *
    • {@link push_back}
    • - *
    • {@link unshift}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link assign}
    • - *
    • {@link clear}
    • - *
    • {@link erase}
    • - *
    • {@link pop_back}
    • - *
    • {@link shift}
    • - *
    • {@link pop}
    • - *
    • {@link splice}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link sort}
    • - *
  • - *
+ * Below is the list of methods who are dispatching {@link CollectionEvent}: + * - *insert* typed events: + * - {@link assign} + * - {@link insert} + * - {@link push} + * - {@link push_back} + * - {@link unshift} + * - *erase* typed events: + * - {@link assign} + * - {@link clear} + * - {@link erase} + * - {@link pop_back} + * - {@link shift} + * - {@link pop} + * - {@link splice} + * - *refresh* typed events: + * - {@link refresh} * + * #### [Inherited] {@link Vector} + * {@link Vector Vectors}s are sequence containers representing arrays that can change in size. + * + * Just like arrays, {@link Vector}s use contiguous storage locations for their elements, which means that their + * elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in + * arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically + * by the container. + * + * Internally, {@link Vector}s use a dynamically allocated array to store their elements. This array may need to + * be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array + * and moving all elements to it. This is a relatively expensive task in terms of processing time, and thus, + * {@link Vector}s do not reallocate each time an element is added to the container. + * + * Instead, {@link Vector} containers may allocate some extra storage to accommodate for possible growth, and + * thus the container may have an actual {@link capacity} greater than the storage strictly needed to contain its + * elements (i.e., its {@link size}). Libraries can implement different strategies for growth to balance between + * memory usage and reallocations, but in any case, reallocations should only happen at logarithmically growing + * intervals of {@link size} so that the insertion of individual elements at the end of the {@link Vector} can be + * provided with amortized constant time complexity (see {@link push_back push_back()}). + * + * Therefore, compared to arrays, {@link Vector}s consume more memory in exchange for the ability to manage + * storage and grow dynamically in an efficient way. + * + * Compared to the other dynamic sequence containers ({@link Deque}s, {@link List}s), {@link Vector Vectors} are + * very efficient accessing its elements (just like arrays) and relatively efficient adding or removing elements + * from its end. For operations that involve inserting or removing elements at positions other than the end, they + * perform worse than the others, and have less consistent iterators and references than {@link List}s. + * + * + * + * + * + *

Container properties

+ *
+ *
Sequence
+ *
+ * Elements in sequence containers are ordered in a strict linear sequence. Individual elements are + * accessed by their position in this sequence. + *
+ * + *
Dynamic array
+ *
+ * Allows direct access to any element in the sequence, even through pointer arithmetics, and provides + * relatively fast addition/removal of elements at the end of the sequence. + *
+ *
+ * + * @param Type of the elements. + * + * @reference http://www.cplusplus.com/reference/vector/vector + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class ArrayCollection extends std.Vector implements ICollection { @@ -74,7 +121,7 @@ declare namespace samchon.collection { /** * @inheritdoc */ - push(...items: U[]): number; + push(...items: T[]): number; /** * @inheritdoc */ @@ -170,6 +217,7 @@ declare namespace samchon.library { * A basic event class of Samchon Framework. * * @reference https://developer.mozilla.org/en-US/docs/Web/API/Event + * @handbook https://github.com/samchon/framework/wiki/TypeScript-Library-EventDispatcher * @author Jeongho Nam */ class BasicEvent { @@ -201,7 +249,7 @@ declare namespace samchon.library { /** * @inheritdoc */ - type: string; + readonly type: string; /** * @inheritdoc */ @@ -209,89 +257,98 @@ declare namespace samchon.library { /** * @inheritdoc */ - currentTarget: IEventDispatcher; + readonly currentTarget: IEventDispatcher; /** * @inheritdoc */ - isTrusted: boolean; + readonly isTrusted: boolean; /** * @inheritdoc */ - bubbles: boolean; + readonly bubbles: boolean; /** * @inheritdoc */ - cancelable: boolean; + readonly cancelable: boolean; /** * @inheritdoc */ - eventPhase: number; + readonly eventPhase: number; /** * @inheritdoc */ - defaultPrevented: boolean; + readonly defaultPrevented: boolean; /** * @inheritdoc */ - srcElement: Element; + readonly srcElement: Element; /** * @inheritdoc */ - cancelBubble: boolean; + readonly cancelBubble: boolean; /** * @inheritdoc */ - timeStamp: number; + readonly timeStamp: number; /** * Don't know what it is. */ - returnValue: boolean; + readonly returnValue: boolean; } } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * Type of function pointer for listener of {@link CollectionEvent CollectionEvents}. */ type CollectionEventListener = (event: CollectionEvent) => void; } -declare namespace samchon.collection { +declare namespace samchon.collections { /** + * An event occured in a {@link ICollection collection} object. + * + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class CollectionEvent extends library.BasicEvent { /** * @hidden */ - protected first_: std.Iterator; + private first_; + /** + * @hidden + */ + private last_; /** * @hidden */ - protected last_: std.Iterator; private temporary_container_; + /** + * @hidden + */ private origin_first_; /** * Initialization Constructor. * * @param type Type of collection event. - * @param first - * @param last + * @param first An {@link Iterator} to the initial position in this {@link CollectionEvent}. + * @param last An {@link Iterator} to the final position in this {@link CollectionEvent}. */ constructor(type: string, first: std.Iterator, last: std.Iterator); constructor(type: "insert", first: std.Iterator, last: std.Iterator); constructor(type: "erase", first: std.Iterator, last: std.Iterator); constructor(type: "refresh", first: std.Iterator, last: std.Iterator); /** - * Get associative target, the container. + * Associative target, the {@link ICollection collection}. */ - target: ICollection; + readonly target: ICollection; /** - * Get range of the first. + * An {@link Iterator} to the initial position in this {@link CollectionEvent}. */ - first: std.Iterator; + readonly first: std.Iterator; /** - * Get range of the last. + * An {@link Iterator} to the final position in this {@link CollectionEvent}. */ - last: std.Iterator; + readonly last: std.Iterator; /** * @inheritdoc */ @@ -301,34 +358,78 @@ declare namespace samchon.collection { /** * @hidden */ -declare namespace samchon.collection.CollectionEvent { +declare namespace samchon.collections.CollectionEvent { const INSERT: "insert"; const ERASE: "erase"; const REFRESH: "refresh"; } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * A {@link Deque} who can detect element I/O events. * - *

Below are list of methods who are dispatching {@link CollectionEvent}:

+ * Below is the list of methods who are dispatching {@link CollectionEvent}: + * - *insert* typed events: + * - {@link assign} + * - {@link insert} + * - {@link push} + * - {@link push_front} + * - {@link push_back} + * - *erase* typed events: + * - {@link assign} + * - {@link clear} + * - {@link erase} + * - {@link pop_front} + * - {@link pop_back} + * - *refresh* typed events: + * - {@link refresh} * - *
    - *
  • insert typed events:
      - *
    • {@link assign}
    • - *
    • {@link insert}
    • - *
    • {@link push}
    • - *
    • {@link push_front}
    • - *
    • {@link push_back}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link assign}
    • - *
    • {@link clear}
    • - *
    • {@link erase}
    • - *
    • {@link pop_front}
    • - *
    • {@link pop_back}
    • - *
  • - *
+ * #### [Inherited] {@link Deque} + * {@link Deque} (usually pronounced like "*deck*") is an irregular acronym of **d**ouble-**e**nded **q**ueue. + * Double-ended queues are sequence containers with dynamic sizes that can be expanded or contracted on both ends + * (either its front or its back). * + * Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any + * case, they allow for the individual elements to be accessed directly through random access iterators, with + * storage handled automatically by expanding and contracting the container as needed. + * + * Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion of + * elements also at the beginning of the sequence, and not only at its end. But, unlike {@link Vector Vectors}, + * {@link Deque Deques} are not guaranteed to store all its elements in contiguous storage locations: accessing + * elements in a deque by offsetting a pointer to another element causes undefined behavior. + * + * Both {@link Vector}s and {@link Deque}s provide a very similar interface and can be used for similar purposes, + * but internally both work in quite different ways: While {@link Vector}s use a single array that needs to be + * occasionally reallocated for growth, the elements of a {@link Deque} can be scattered in different chunks of + * storage, with the container keeping the necessary information internally to provide direct access to any of its + * elements in constant time and with a uniform sequential interface (through iterators). Therefore, + * {@link Deque Deques} are a little more complex internally than {@link Vector}s, but this allows them to grow + * more efficiently under certain circumstances, especially with very long sequences, where reallocations become + * more expensive. + * + * For operations that involve frequent insertion or removals of elements at positions other than the beginning or + * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than + * {@link List Lists}. + * + * + * + * + * + *

Container properties

+ *
+ *
Sequence
+ *
Elements in sequence containers are ordered in a strict linear sequence. Individual elements + * are accessed by their position in this sequence.
+ * + *
Dynamic array
+ *
Generally implemented as a dynamic array, it allows direct access to any element in the + * sequence and provides relatively fast addition/removal of elements at the beginning or the end + * of the sequence.
+ *
+ * + * @param Type of the elements. + * + * @reference http://www.cplusplus.com/reference/deque/deque/ + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class DequeCollection extends std.Deque implements ICollection { @@ -339,7 +440,7 @@ declare namespace samchon.collection { /** * @inheritdoc */ - push(...items: U[]): number; + push(...items: T[]): number; /** * @inheritdoc */ @@ -418,30 +519,72 @@ declare namespace samchon.collection { removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * A {@link HashMap} who can detect element I/O events. * - *
    - *
  • insert typed events:
      - *
    • {@link assign}
    • - *
    • {@link insert}
    • - *
    • {@link push}
    • - *
    • {@link set}
    • - *
    • {@link insert_or_assign}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link assign}
    • - *
    • {@link clear}
    • - *
    • {@link erase}
    • - *
    • {@link extract}
    • - *
  • - *
  • refresh typed events:
      - *
    • {@link set}
    • - *
    • {@link insert_or_assign}
    • - *
  • - *
+ * Below is the list of methods who are dispatching {@link MapCollectionEvent}: + * - *insert* typed events: + * - {@link assign} + * - {@link insert} + * - {@link insert_or_assign} + * - {@link emplace} + * - {@link set} + * - {@link push} + * - *erase* typed events: + * - {@link assign} + * - {@link clear} + * - {@link erase} + * - {@link extract} + * - *refresh* typed events: + * - {@link refresh} * + * #### [Inherited] {@link HashMap} + * {@link HashMap HashMaps} are associative containers that store elements formed by the combination of a + * *key value* and a *mapped value*, and which allows for fast retrieval of individual elements based on their + * *keys*. + * + * In an {@link HashMap}, the *key value* is generally used to uniquely identify the element, while the + * *mapped value* is an object with the content associated to this *key*. Types of *key* and *mapped value* may + * differ. + * + * Internally, the elements in the {@link HashMap} are not sorted in any particular order with respect to either + * their *key* or *mapped values*, but organized into *buckets* depending on their hash values to allow for fast + * access to individual elements directly by their *key values* (with a constant average time complexity on + * average). + * + * {@link HashMap} containers are faster than {@link TreeMap} containers to access individual elements by their + * *key*, although they are generally less efficient for range iteration through a subset of their elements. + * + * + * + * + * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their *key* and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their *key*.
+ * + *
Map
+ *
Each element associates a *key* to a *mapped value*: + * *Keys* are meant to identify the elements whose main content is the *mapped value*.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the key values. + * Each element in an {@link HashMap} is uniquely identified by its key value. + * @param Type of the mapped value. + * Each element in an {@link HashMap} is used to store some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/unordered_map/unordered_map + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class HashMapCollection extends std.HashMap implements ICollection> { @@ -507,23 +650,69 @@ declare namespace samchon.collection { removeEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * A {@link HashMultiMap} who can detect element I/O events. * - *
    - *
  • insert typed events:
      - *
    • {@link assign}
    • - *
    • {@link insert}
    • - *
    • {@link push}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link assign}
    • - *
    • {@link clear}
    • - *
    • {@link erase}
    • - *
  • - *
+ * Below is the list of methods who are dispatching {@link MapCollectionEvent}: + * - *insert* typed events: + * - {@link assign} + * - {@link insert} + * - {@link emplace} + * - {@link push} + * - *erase* typed events: + * - {@link assign} + * - {@link clear} + * - {@link erase} + * - *refresh* typed events: + * - {@link refresh} * + * #### [Inherited] {@link HashMultiMap} + * {@link HashMultiMap HashMultiMap}s are associative containers that store elements formed by the combination of + * a *key value* and a *mapped value*, much like {@link HashMultiMap} containers, but allowing different elements + * to have equivalent *keys*. + * + * In an {@link HashMultiMap}, the *key value* is generally used to uniquely identify the element, while the + * *mapped value* is an object with the content associated to this *key*. Types of *key* and *mapped value* may + * differ. + * + * Internally, the elements in the {@link HashMultiMap} are not sorted in any particular order with respect to + * either their *key* or *mapped values*, but organized into *buckets* depending on their hash values to allow for + * fast access to individual elements directly by their *key values* (with a constant average time complexity on + * average). + * + * Elements with equivalent *keys* are grouped together in the same bucket and in such a way that an iterator can + * iterate through all of them. Iterators in the container are doubly linked iterators. + * + * + * + * + * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their *key* and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their *key*.
+ * + *
Map
+ *
Each element associates a *key* to a *mapped value*: + * *Keys* are meant to identify the elements whose main content is the *mapped value*.
+ * + *
Multiple equivalent keys
+ *
The container can hold multiple elements with equivalent *keys*.
+ *
+ * + * @param Type of the key values. + * Each element in an {@link HashMultiMap} is identified by a key value. + * @param Type of the mapped value. + * Each element in an {@link HashMultiMap} is used to store some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/unordered_map/unordered_multimap + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class HashMultiMapCollection extends std.HashMap implements ICollection> { @@ -589,23 +778,64 @@ declare namespace samchon.collection { removeEventListener(type: "refresh", listener: MapCollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * A {@link HashMultiSet} who can detect element I/O events. * - *
    - *
  • insert typed events:
      - *
    • {@link assign}
    • - *
    • {@link insert}
    • - *
    • {@link push}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link assign}
    • - *
    • {@link clear}
    • - *
    • {@link erase}
    • - *
  • - *
+ * Below is the list of methods who are dispatching {@link CollectionEvent}: + * - *insert* typed events: + * - {@link assign} + * - {@link insert} + * - {@link push} + * - *erase* typed events: + * - {@link assign} + * - {@link clear} + * - {@link erase} + * - *refresh* typed events: + * - {@link refresh} * + * #### [Inherited] {@link HashMultiSet} + * {@link HashMultiSet HashMultiSets} are containers that store elements in no particular order, allowing fast + * retrieval of individual elements based on their value, much like {@link HashMultiSet} containers, but allowing + * different elements to have equivalent values. + * + * In an {@link HashMultiSet}, the value of an element is at the same time its *key*, used to identify it. *Keys* + * are immutable, therefore, the elements in an {@link HashMultiSet} cannot be modified once in the container - + * they can be inserted and removed, though. + * + * Internally, the elements in the {@link HashMultiSet} are not sorted in any particular, but organized into + * *buckets* depending on their hash values to allow for fast access to individual elements directly by their + * *values* (with a constant average time complexity on average). + * + * Elements with equivalent values are grouped together in the same bucket and in such a way that an iterator can + * iterate through all of them. Iterators in the container are doubly linked iterators. + * + * + * + * + * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their *key* and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their *key*.
+ * + *
Set
+ *
The value of an element is also the *key* used to identify it.
+ * + *
Multiple equivalent keys
+ *
The container can hold multiple elements with equivalent *keys*.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link UnorderedMultiSet} is also identified by this value.. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_multiset + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class HashMultiSetCollection extends std.HashMultiSet implements ICollection { @@ -671,24 +901,65 @@ declare namespace samchon.collection { removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * A {@link HashSet} who can detect element I/O events. * - *
    - *
  • insert typed events:
      - *
    • {@link assign}
    • - *
    • {@link insert}
    • - *
    • {@link push}
    • - *
  • - *
  • erase typed events:
      - *
    • {@link assign}
    • - *
    • {@link clear}
    • - *
    • {@link erase}
    • - *
    • {@link extract}
    • - *
  • - *
+ * Below is the list of methods who are dispatching {@link CollectionEvent}: + * - *insert* typed events: + * - {@link assign} + * - {@link insert} + * - {@link push} + * - {@link insert_or_assign} + * - *erase* typed events: + * - {@link assign} + * - {@link clear} + * - {@link erase} + * - {@link extract} + * - *refresh* typed events: + * - {@link refresh} * + * #### [Inherited] {@link HashSet} + * {@link HashSet HashSets} are containers that store unique elements in no particular order, and which allow for + * fast retrieval of individual elements based on their value. + * + * In an {@link HashSet}, the value of an element is at the same time its *key*, that identifies it uniquely. + * Keys are immutable, therefore, the elements in an {@link HashSet} cannot be modified once in the container - + * they can be inserted and removed, though. + * + * Internally, the elements in the {@link HashSet} are not sorted in any particular order, but organized into + * buckets depending on their hash values to allow for fast access to individual elements directly by their + * *values* (with a constant average time complexity on average). + * + * {@link HashSet} containers are faster than {@link TreeSet} containers to access individual elements by their + * *key*, although they are generally less efficient for range iteration through a subset of their elements. + * + * + * + * + * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their *key* and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their *key*.
+ * + *
Set
+ *
The value of an element is also the *key* used to identify it.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent *keys*.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link HashSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set + * @handbook [Collections](https://github.com/samchon/framework/wiki/TypeScript-STL#collections) * @author Jeongho Nam */ class HashSetCollection extends std.HashSet implements ICollection { @@ -754,75 +1025,73 @@ declare namespace samchon.collection { removeEventListener(type: "refresh", listener: CollectionEventListener, thisArg: Object): void; } } -declare namespace samchon.collection { +declare namespace samchon.collections { /** * An interface for {@link IContainer containers} who can detect element I/O events. * - *

Below are list of methods who are dispatching {@link CollectionEvent}:

- * - *