├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── browserify-umd.js ├── examples ├── CollectionsDemo │ ├── CollectionsDemo.csproj │ ├── Content │ │ ├── bootstrap-responsive.min.css │ │ ├── bootstrap.min.css │ │ ├── images │ │ │ ├── glyphicons-halflings-white.png │ │ │ └── glyphicons-halflings.png │ │ └── prettify.css │ ├── Scripts │ │ ├── bootstrap.min.js │ │ ├── jquery-1.9.1.min.js │ │ ├── lang-basic.js │ │ ├── prettify.js │ │ └── run_prettify.js │ ├── app.css │ ├── app.js │ ├── app.ts │ ├── index.htm │ ├── packages.config │ ├── web.Debug.config │ ├── web.Release.config │ └── web.config └── SimpleDemo │ └── index.ts ├── minify-umd.js ├── package-lock.json ├── package.json ├── src ├── lib │ ├── BSTree.ts │ ├── BSTreeKV.ts │ ├── Bag.ts │ ├── Dictionary.ts │ ├── FactoryDictionary.ts │ ├── Heap.ts │ ├── LinkedDictionary.ts │ ├── LinkedList.ts │ ├── MultiDictionary.ts │ ├── MultiRootTree.ts │ ├── PriorityQueue.ts │ ├── Queue.ts │ ├── Set.ts │ ├── Stack.ts │ ├── arrays.ts │ ├── index.ts │ └── util.ts └── test │ ├── arraysTest.ts │ ├── bagTest.ts │ ├── bsTreeKVTest.ts │ ├── bsTreeTest.ts │ ├── dictionaryTest.ts │ ├── factoryDictionaryTest.ts │ ├── heapTest.ts │ ├── linkedListTest.ts │ ├── multiDictionaryTest.ts │ ├── multiRootTreeTest.ts │ ├── priorityQueueTest.ts │ ├── queueTest.ts │ ├── runTests.html │ ├── setTest.ts │ ├── stackTest.ts │ └── utilTest.ts ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Compile time directories 2 | node_modules 3 | /temp 4 | /coverage 5 | /dist 6 | /typings 7 | 8 | # Editor configuration 9 | .vscode 10 | .settings 11 | .idea 12 | 13 | # Logs and compressed files 14 | *.log 15 | *.tgz 16 | 17 | # Demos 18 | collections.js.map 19 | demo/CollectionsDemo/app.js.map 20 | demo/packages/ 21 | demo/CollectionsDemo/obj/Debug/ 22 | lessons.txt 23 | demo/CollectionsDemo/collections.js 24 | 25 | # Windows image file caches 26 | Thumbs.db 27 | ehthumbs.db 28 | 29 | # Folder config file 30 | Desktop.ini 31 | 32 | # Recycle Bin used on file shares 33 | $RECYCLE.BIN/ 34 | 35 | # Windows Installer files 36 | *.cab 37 | *.msi 38 | *.msm 39 | *.msp 40 | 41 | # Windows shortcuts 42 | *.lnk 43 | 44 | # ========================= 45 | # Operating System Files 46 | # ========================= 47 | 48 | # OSX 49 | # ========================= 50 | 51 | .DS_Store 52 | .AppleDouble 53 | .LSOverride 54 | 55 | # Thumbnails 56 | ._* 57 | 58 | # Files that might appear on external disk 59 | .Spotlight-V100 60 | .Trashes 61 | 62 | # Directories potentially created on remote AFP share 63 | .AppleDB 64 | .AppleDesktop 65 | Network Trash Folder 66 | Temporary Items 67 | .apdisk 68 | 69 | # Logs 70 | logs 71 | *.log 72 | npm-debug.log* 73 | 74 | # Runtime data 75 | pids 76 | *.pid 77 | *.seed 78 | 79 | # Directory for instrumented libs generated by jscoverage/JSCover 80 | lib-cov 81 | 82 | # Coverage directory used by tools like istanbul 83 | coverage 84 | 85 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 86 | .grunt 87 | 88 | # node-waf configuration 89 | .lock-wscript 90 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | .vscode/ 3 | coverage/ 4 | dist/test/ 5 | examples/ 6 | node_modules/ 7 | src/ 8 | temp/ 9 | typings/ 10 | 11 | .gitattributes 12 | .gitignore 13 | .editorconfig 14 | browserify-karma.js 15 | browserify-umd.js 16 | DEVELOPING.md 17 | karma.conf.js 18 | minify-umd.js 19 | tsconfig.json 20 | tsd.json 21 | tslint.json 22 | *.tgz -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2017 Tomasz Ciborski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [TypeScript Collections](https://github.com/basarat/typescript-collections/) 2 | ==================== 3 | 4 | It is a complete, fully tested data structure library written in TypeScript. 5 | 6 | This project uses TypeScript Generics so you need TS 0.9 and above. 7 | 8 | [This projects supports UMD (Universal Module Definition)](https://github.com/umdjs/umd) 9 | 10 | [](https://nodei.co/npm/typescript-collections/) 11 | 12 | Included data structures 13 | --------------------- 14 | 15 | - Linked List 16 | - Dictionary - [Example](#a-sample-on-dictionary) 17 | - Multi Dictionary 18 | - Linked Dictionary 19 | - Default Dictionary - [Info](#default-dictionary) 20 | - Binary Search Tree 21 | - Binary Search Tree for Key-Value pairs 22 | - Stack 23 | - Queue 24 | - Set - [Example](#example) 25 | - Bag 26 | - Binary Heap 27 | - Priority Queue 28 | 29 | It also includes several functions for manipulating arrays. 30 | 31 | Usage 32 | -------------------- 33 | 34 | `npm install typescript-collections --save` 35 | 36 | ES6 `import ... from` 37 | 38 | ```typescript 39 | import * as Collections from 'typescript-collections'; 40 | ``` 41 | 42 | or TypeScript `import ... require` 43 | 44 | ```typescript 45 | import Collections = require('typescript-collections'); 46 | ``` 47 | 48 | or JavaScript `var ... require` 49 | 50 | ```js 51 | var Collections = require('typescript-collections'); 52 | ``` 53 | 54 |  55 | 56 | Visual Studio or other TypeScript IDE, will provide you with complete Intellisense (autocomplete) for your types. 57 | The compiler will ensure that the collections contain the correct elements. 58 | 59 | A sample Visual Studio project is in the demo folder. 60 | 61 | Also available on NuGet : 62 | Thanks to 63 | 64 | Example 65 | -------------------- 66 | 67 | ```typescript 68 | import * as Collections from 'typescript-collections'; 69 | 70 | var mySet = new Collections.Set(); 71 | mySet.add(123); 72 | mySet.add(123); // Duplicates not allowed in a set 73 | // The following will give error due to wrong type: 74 | // mySet.add("asdf"); // Can only add numbers since that is the type argument. 75 | 76 | var myQueue = new Collections.Queue(); 77 | myQueue.enqueue(1); 78 | myQueue.enqueue(2); 79 | 80 | console.log(myQueue.dequeue()); // prints 1 81 | console.log(myQueue.dequeue()); // prints 2 82 | ``` 83 | 84 | Typings resolution 85 | ------------------- 86 | 87 | Remember to set `"moduleResolution": "node"`, so TypeScript compiler can resolve typings in the `node_modules/typescript-collections` directory. 88 | 89 | In browser usage 90 | ------------------- 91 | 92 | You should include `umd.js` or `umd.min.js` from `dist/lib/` directory. 93 | 94 | ```html 95 | 96 | ``` 97 | 98 | A note on Equality 99 | ------------------- 100 | 101 | Equality is important for hashing (e.g. dictionary / sets). Javascript only allows strings to be keys for the base dictionary {}. 102 | This is why the implementation for these data structures uses the item's toString() method. 103 | 104 | makeString utility function (aka. JSON.stringify) 105 | ------------------- 106 | 107 | A simple function is provided for you when you need a quick toString that uses all properties. E.g: 108 | 109 | ```typescript 110 | import * as Collections from 'typescript-collections'; 111 | 112 | class Car { 113 | constructor(public company: string, public type: string, public year: number) { 114 | } 115 | toString() { 116 | // Short hand. Adds each own property 117 | return Collections.util.makeString(this); 118 | } 119 | } 120 | 121 | console.log(new Car("BMW", "A", 2016).toString()); 122 | ``` 123 | 124 | Output: 125 | 126 | ```text 127 | {company:BMW,type:A,year:2016} 128 | ``` 129 | 130 | A Sample on Dictionary 131 | --------------------- 132 | 133 | ```typescript 134 | import * as Collections from 'typescript-collections'; 135 | 136 | class Person { 137 | constructor(public name: string, public yearOfBirth: number,public city?:string) { 138 | } 139 | toString() { 140 | return this.name + "-" + this.yearOfBirth; // City is not a part of the key. 141 | } 142 | } 143 | 144 | class Car { 145 | constructor(public company: string, public type: string, public year: number) { 146 | } 147 | toString() { 148 | // Short hand. Adds each own property 149 | return Collections.util.makeString(this); 150 | } 151 | } 152 | var dict = new Collections.Dictionary(); 153 | dict.setValue(new Person("john", 1970,"melbourne"), new Car("honda", "city", 2002)); 154 | dict.setValue(new Person("gavin", 1984), new Car("ferrari", "F50", 2006)); 155 | console.log("Orig"); 156 | console.log(dict); 157 | 158 | // Changes the same john, since city is not part of key 159 | dict.setValue(new Person("john", 1970, "sydney"), new Car("honda", "accord", 2006)); 160 | // Add a new john 161 | dict.setValue(new Person("john", 1971), new Car("nissan", "micra", 2010)); 162 | console.log("Updated"); 163 | console.log(dict); 164 | 165 | // Showing getting / setting a single car: 166 | console.log("Single Item"); 167 | var person = new Person("john", 1970); 168 | console.log("-Person:"); 169 | console.log(person); 170 | 171 | var car = dict.getValue(person); 172 | console.log("-Car:"); 173 | console.log(car.toString()); 174 | ``` 175 | 176 | Output: 177 | 178 | ```text 179 | Orig 180 | { 181 | john-1970 : {company:honda,type:city,year:2002} 182 | gavin-1984 : {company:ferrari,type:F50,year:2006} 183 | } 184 | Updated 185 | { 186 | john-1970 : {company:honda,type:accord,year:2006} 187 | gavin-1984 : {company:ferrari,type:F50,year:2006} 188 | john-1971 : {company:nissan,type:micra,year:2010} 189 | } 190 | Single Item 191 | -Person: 192 | john-1970 193 | -Car: 194 | {company:honda,type:accord,year:2006} 195 | ``` 196 | 197 | Default Dictionary 198 | --------------------- 199 | 200 | Also known as `Factory Dictionary` [[ref.](https://github.com/basarat/typescript-collections/pull/47)] 201 | 202 | If a key doesn't exist, the Default Dictionary automatically creates it with `setDefault(defaultValue)`. 203 | 204 | Default Dictionary is a @michaelneu contribution which copies Python's [defaultDict](https://docs.python.org/2/library/collections.html#collections.defaultdict). 205 | 206 | Development and contributions 207 | -------------------- 208 | 209 | Compile, test and check coverage 210 | `npm run all` 211 | 212 | Supported platforms 213 | -------------------- 214 | 215 | - Every desktop and mobile browser (including IE6) 216 | - Node.js 217 | 218 | ```text 219 | If it supports JavaScript, it probably supports this library. 220 | ``` 221 | 222 | Contact 223 | -------------------- 224 | 225 | bas AT basarat.com 226 | 227 | Project is based on the excellent original javascript version called [buckets](https://github.com/mauriciosantos/buckets) 228 | -------------------------------------------------------------------------------- /browserify-umd.js: -------------------------------------------------------------------------------- 1 | "use strict;" 2 | 3 | var browserify = require("browserify"); 4 | var fs = require("fs"); 5 | var glob = require("glob"); 6 | var mkdirp = require("mkdirp"); 7 | var Umd = require("browserify-umdify"); 8 | var util = require("util"); 9 | 10 | mkdirp.sync("./temp"); 11 | 12 | var packageJson = require("./package.json"); 13 | var distOutFileUnversioned = "./dist/lib/umd.js"; 14 | var distOutUnversioned = fs.createWriteStream(distOutFileUnversioned, { encoding: "utf-8", flags: "w"}) 15 | 16 | var bundled = browserify({ 17 | extensions: [".js", ".json"], 18 | debug: true 19 | }) 20 | .require("./dist/lib/index.js", { expose: "typescript-collections" }) 21 | .bundle() 22 | .pipe(new Umd()); 23 | 24 | bundled.pipe(distOutUnversioned); 25 | -------------------------------------------------------------------------------- /examples/CollectionsDemo/CollectionsDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | {7CD2B711-89CB-4495-994C-7CF98D3C5025} 6 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 7 | Library 8 | bin 9 | v4.5 10 | full 11 | true 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | collections.js 21 | collections.ts 22 | 23 | 24 | collections.ts 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | app.ts 34 | 35 | 36 | 37 | collections.js.map 38 | collections.ts 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | web.config 49 | 50 | 51 | web.config 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | app.ts 60 | 61 | 62 | 63 | 10.0 64 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 65 | 66 | 67 | CollectionsDemo 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | True 76 | True 77 | 0 78 | / 79 | http://localhost:3657/ 80 | False 81 | False 82 | 83 | 84 | False 85 | 86 | 87 | 88 | 89 | 90 | ES3 91 | true 92 | true 93 | AMD 94 | 95 | 96 | ES3 97 | false 98 | false 99 | AMD 100 | 101 | 102 | 103 | copy "$(ProjectDir)..\\..\\collections.js" "$(ProjectDir)\\collections.js" /y 104 | 105 | -------------------------------------------------------------------------------- /examples/CollectionsDemo/Content/images/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basarat/typescript-collections/309bb1b6955b403b212309531607b8d17df152e5/examples/CollectionsDemo/Content/images/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /examples/CollectionsDemo/Content/images/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basarat/typescript-collections/309bb1b6955b403b212309531607b8d17df152e5/examples/CollectionsDemo/Content/images/glyphicons-halflings.png -------------------------------------------------------------------------------- /examples/CollectionsDemo/Content/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} -------------------------------------------------------------------------------- /examples/CollectionsDemo/Scripts/lang-basic.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^"(?:[^\n\r"\\]|\\.)*(?:"|$)/,a,'"'],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^REM[^\n\r]*/,a],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,a],["pln",/^[a-z][^\W_]?(?:\$|%)?/i,a],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i,a,"0123456789"],["pun", 3 | /^.[^\s\w"$%.]*/,a]]),["basic","cbm"]); 4 | -------------------------------------------------------------------------------- /examples/CollectionsDemo/Scripts/prettify.js: -------------------------------------------------------------------------------- 1 | !function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a= 3 | b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;ah[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com", 11 | /^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+ 12 | s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/, 13 | q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d= 14 | c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, 21 | V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^]+/],["dec",/^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", 22 | /^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^ 10 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | TypeScript Collections Demo 27 | 28 | 29 | Application Log 30 | 31 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 |