├── VERSION_PREFIX ├── .gitignore ├── bin ├── repl ├── docs ├── roundtrip ├── make_deps_js ├── test ├── build_jar ├── prelude ├── build ├── build_release ├── convert_json8k.js ├── convert.js ├── repl.js ├── read_write.js ├── convert_json.js ├── build_release_bench ├── build_dev_bench ├── build_dev_node ├── build_release_node ├── build_dev_browser ├── build_release_browser ├── build_dev_browser_amd ├── build_release_browser_amd ├── deps └── closure_deps_graph.clj ├── doctheme ├── partials │ ├── index.handlebars │ ├── files.handlebars │ ├── props.handlebars │ ├── module.handlebars │ ├── events.handlebars │ ├── attrs.handlebars │ ├── classes.handlebars │ ├── sidebar.handlebars │ └── method.handlebars ├── assets │ ├── css │ │ ├── logo.png │ │ ├── cognitect.jpg │ │ ├── external-small.png │ │ └── main.css │ ├── js │ │ ├── yui-prettify.js │ │ └── tabs.js │ └── vendor │ │ └── prettify │ │ ├── prettify-min.css │ │ ├── CHANGES.html │ │ ├── README.html │ │ ├── COPYING │ │ └── prettify-min.js ├── theme.json └── layouts │ └── main.handlebars ├── yuidoc.json ├── resources ├── bench.html ├── externs.js ├── index.html ├── test.html ├── prelude.txt ├── amd_externs.js ├── node_externs.js ├── example.tjs └── example.json ├── .github └── workflows │ └── test.yaml ├── src └── com │ └── cognitect │ ├── transit_amd.js │ └── transit │ ├── delimiters.js │ ├── impl │ ├── reader.js │ └── decoder.js │ ├── caching.js │ ├── util.js │ ├── eq.js │ └── handlers.js ├── package.json ├── SECURITY.md ├── bench ├── bson_compare.js ├── json.js ├── mapset.js └── bench.js ├── Gruntfile.js ├── pom.xml ├── README.md └── LICENSE /VERSION_PREFIX: -------------------------------------------------------------------------------- 1 | 0.8 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs 2 | deps 3 | node_modules 4 | target 5 | .idea -------------------------------------------------------------------------------- /bin/repl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ./bin/make_deps_js 3 | ./bin/repl.js -------------------------------------------------------------------------------- /doctheme/partials/index.handlebars: -------------------------------------------------------------------------------- 1 |

API Docs - Main Index

2 |

3 | -------------------------------------------------------------------------------- /doctheme/assets/css/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/transit-js/master/doctheme/assets/css/logo.png -------------------------------------------------------------------------------- /doctheme/assets/css/cognitect.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/transit-js/master/doctheme/assets/css/cognitect.jpg -------------------------------------------------------------------------------- /bin/docs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | node_modules/.bin/yuidoc src --themedir doctheme -o docs 8 | -------------------------------------------------------------------------------- /bin/roundtrip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | bin/build_release_node 8 | exec bin/read_write.js "$@" 9 | -------------------------------------------------------------------------------- /doctheme/assets/css/external-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roman01la/transit-js/master/doctheme/assets/css/external-small.png -------------------------------------------------------------------------------- /doctheme/partials/files.handlebars: -------------------------------------------------------------------------------- 1 |

{{fileName}}

2 | 3 |
4 | {{fileData}}
5 | 
6 | 7 | -------------------------------------------------------------------------------- /bin/make_deps_js: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | java -cp deps/closure-compiler/compiler.jar:deps/clojure/clojure-1.6.0.jar clojure.main -i bin/closure_deps_graph.clj -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | bin/make_deps_js 8 | bin/build_dev_node 9 | node_modules/.bin/grunt nodeunit 10 | -------------------------------------------------------------------------------- /bin/build_jar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd src 6 | 7 | jar cf transit.jar com 8 | 9 | mkdir -p ../target 10 | 11 | mv transit.jar ../target/ 12 | -------------------------------------------------------------------------------- /bin/prelude: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | prefix=`cat VERSION_PREFIX` 6 | suffix=`build/revision` 7 | version=$prefix.$suffix 8 | 9 | sed "s/\$VERSION/$version/g" resources/prelude.txt 10 | -------------------------------------------------------------------------------- /doctheme/theme.json: -------------------------------------------------------------------------------- 1 | { 2 | "yuiGridsUrl": "http://yui.yahooapis.com/3.8.0pr2/build/cssgrids/cssgrids-min.css", 3 | "yuiSeedUrl": "http://yui.yahooapis.com/combo?3.8.0pr2/build/yui/yui-min.js" 4 | } 5 | -------------------------------------------------------------------------------- /yuidoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "transit-js", 3 | "description": "A JavaScript implementation of the Transit format", 4 | "version": "0.8.812", 5 | "url": "http://github.com/cognitect/transit-js", 6 | "options": { 7 | "outdir": "docs" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /bin/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | java -jar deps/closure-compiler/compiler.jar -O WHITESPACE_ONLY \ 8 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 9 | --js_output_file=target/transit.js \ 10 | 'deps/closure-library/closure/**.js' 'src/**.js' 11 | -------------------------------------------------------------------------------- /resources/bench.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Benchmarks

4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bin/build_release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | java -jar deps/closure-compiler/compiler.jar -O ADVANCED --generate_exports \ 8 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 9 | --js_output_file=target/transit.js \ 10 | 'deps/closure-library/closure/**.js' 'src/**.js' 11 | -------------------------------------------------------------------------------- /bin/convert_json8k.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require("fs"), 4 | json = fs.readFileSync("resources/example.json", "utf-8"), 5 | transit = require("../target/transit.js"), 6 | r = transit.reader("json"), 7 | w = transit.writer("json"); 8 | 9 | fs.writeFileSync("resources/example.tjs", w.write(r.read(json))); 10 | -------------------------------------------------------------------------------- /bin/convert.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require("fs"), 4 | json = fs.readFileSync("../transit/seattle-data0.tjs", "utf-8"), 5 | transit = require("../target/transit.js"), 6 | r = transit.reader("json"), 7 | w = transit.writer("json"); 8 | 9 | fs.writeFileSync("../transit/seattle-data0.tjsm", w.write(r.read(json))); 10 | -------------------------------------------------------------------------------- /bin/repl.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node --harmony 2 | require("repl").start({useGlobal:true}); 3 | 4 | global.CLOSURE_NO_DEPS = true; 5 | require("../deps/closure-library/closure/goog/bootstrap/nodejs.js"); 6 | require("../deps/closure-library/closure/goog/transit_deps.js"); 7 | 8 | goog.require("com.cognitect.transit"); 9 | 10 | global.transit = com.cognitect.transit; 11 | -------------------------------------------------------------------------------- /bin/read_write.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | process.stdin.setEncoding("utf8"); 4 | 5 | var transit = require("../target/transit.js"), 6 | transport = process.argv[2] || "json", 7 | r = transit.reader(transport), 8 | w = transit.writer(transport); 9 | 10 | process.stdin.on("data", function(data, err) { 11 | process.stdout.write(w.write(r.read(data))); 12 | }); 13 | -------------------------------------------------------------------------------- /bin/convert_json.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require("fs"), 4 | fname = process.argv[2] || "example", 5 | json = fs.readFileSync("resources/"+fname+".json", "utf-8"), 6 | transit = require("../target/transit.js"), 7 | r = transit.reader("json"), 8 | w = transit.writer("json"); 9 | 10 | fs.writeFileSync("resources/"+fname+".tjs", w.write(r.read(json))); 11 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: [push] 3 | 4 | jobs: 5 | test: 6 | name: Test 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | with: 11 | fetch-depth: "0" 12 | 13 | - uses: DeLaGuardo/setup-clojure@3.1 14 | with: 15 | tools-deps: '1.10.1.763' 16 | 17 | - name: Run tests 18 | run: | 19 | ./bin/deps 20 | ./bin/test 21 | -------------------------------------------------------------------------------- /doctheme/partials/props.handlebars: -------------------------------------------------------------------------------- 1 | 2 |
3 | `{{name}}` <{{#crossLink type}}{{/crossLink}}>{{#if final}} (final){{/if}}{{#if static}} (static){{/if}}
4 | `{{file}}:{{line}}` 5 | {{{propertyDescription}}} 6 | {{#if example}} 7 |
Example
8 | {{{example}}} 9 | {{/if}} 10 |
11 | -------------------------------------------------------------------------------- /resources/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {Object} 3 | */ 4 | Object.value; 5 | /** 6 | * @type {Boolean} 7 | */ 8 | Object.done; 9 | /** 10 | * @type {Object} 11 | */ 12 | Object.rep; 13 | /** 14 | * @type {String} 15 | */ 16 | Object.tag; 17 | /** 18 | * @type {Object} 19 | */ 20 | Object.init; 21 | /** 22 | * @type {Boolean} 23 | */ 24 | Object.add; 25 | /** 26 | * @type {Object} 27 | */ 28 | Object.finalize; 29 | /** 30 | * @type {String} 31 | */ 32 | Object.fromArray; 33 | var module = {}; 34 | module.exports = {}; -------------------------------------------------------------------------------- /bin/build_release_bench: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | java -jar deps/closure-compiler/compiler.jar -O ADVANCED \ 10 | --output_wrapper ";(function(){%output%})();" --generate_exports \ 11 | -D TRANSIT_BROWSER_TARGET=true --externs resources/externs.js \ 12 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 13 | --js_output_file=target/transit.js \ 14 | 'deps/closure-library/closure/**.js' 'src/**.js' 15 | 16 | cat target/transit.js bench/seattle.js > target/transit.bench.js 17 | -------------------------------------------------------------------------------- /bin/build_dev_bench: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | java -jar deps/closure-compiler/compiler.jar -O SIMPLE --formatting PRETTY_PRINT \ 10 | --language_out=ECMASCRIPT_2020 \ 11 | --generate_exports --output_wrapper "$preludenl%output%" -D TRANSIT_NODE_TARGET=true \ 12 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 13 | --js_output_file=target/transit.js \ 14 | 'deps/closure-library/closure/**.js' 'src/**.js' 15 | 16 | cat target/transit.js bench/seattle.js > target/transit.bench.js 17 | -------------------------------------------------------------------------------- /resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Playground

4 | 5 | 6 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /doctheme/assets/js/yui-prettify.js: -------------------------------------------------------------------------------- 1 | YUI().use('node', function(Y) { 2 | var code = Y.all('.prettyprint.linenums'); 3 | if (code.size()) { 4 | code.each(function(c) { 5 | var lis = c.all('ol li'), 6 | l = 1; 7 | lis.each(function(n) { 8 | n.prepend(''); 9 | l++; 10 | }); 11 | }); 12 | var h = location.hash; 13 | location.hash = ''; 14 | h = h.replace('l', 'LINENUM_'); 15 | location.hash = h; 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /bin/build_dev_node: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | prefix=`cat VERSION_PREFIX` 10 | suffix=`build/revision` 11 | version=$prefix.$suffix 12 | prelude=`bin/prelude` 13 | preludenl=$prelude.$'\n' 14 | 15 | java -jar deps/closure-compiler/compiler.jar -O SIMPLE --formatting PRETTY_PRINT \ 16 | --language_out=ECMASCRIPT_2020 \ 17 | --generate_exports --output_wrapper "$preludenl%output%" -D TRANSIT_NODE_TARGET=true \ 18 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 19 | --js_output_file=target/transit.js \ 20 | 'deps/closure-library/closure/**.js' 'src/**.js' 21 | -------------------------------------------------------------------------------- /bin/build_release_node: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | prefix=`cat VERSION_PREFIX` 10 | suffix=`build/revision` 11 | version=$prefix.$suffix 12 | prelude=`bin/prelude` 13 | preludenl=$prelude.$'\n' 14 | 15 | java -jar deps/closure-compiler/compiler.jar -O ADVANCED --generate_exports \ 16 | --output_wrapper "$preludenl%output%" -D TRANSIT_NODE_TARGET=true \ 17 | -D TRANSIT_DEV=false --externs resources/node_externs.js \ 18 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 19 | --js_output_file=target/transit.js \ 20 | 'deps/closure-library/closure/**.js' 'src/**.js' 21 | -------------------------------------------------------------------------------- /bin/build_dev_browser: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | prefix=`cat VERSION_PREFIX` 10 | suffix=`build/revision` 11 | version=$prefix.$suffix 12 | prelude=`bin/prelude` 13 | preludenl=$prelude.$'\n' 14 | 15 | java -jar deps/closure-compiler/compiler.jar -O SIMPLE --formatting PRETTY_PRINT \ 16 | --language_out=ECMASCRIPT_2020 \ 17 | --output_wrapper "$preludenl;(function(){%output%})();" --generate_exports -D TRANSIT_BROWSER_TARGET=true \ 18 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 19 | --js_output_file=target/transit-$version.js \ 20 | 'deps/closure-library/closure/**.js' 'src/**.js' 21 | -------------------------------------------------------------------------------- /bin/build_release_browser: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | prefix=`cat VERSION_PREFIX` 10 | suffix=`build/revision` 11 | version=$prefix.$suffix 12 | prelude=`bin/prelude` 13 | preludenl=$prelude.$'\n' 14 | 15 | java -jar deps/closure-compiler/compiler.jar -O ADVANCED \ 16 | --output_wrapper "$preludenl;(function(){%output%})();" --generate_exports \ 17 | -D TRANSIT_BROWSER_TARGET=true -D TRANSIT_DEV=false --externs resources/externs.js \ 18 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \ 19 | --js_output_file=target/transit-$version-min.js \ 20 | 'deps/closure-library/closure/**.js' 'src/**.js' 21 | -------------------------------------------------------------------------------- /bin/build_dev_browser_amd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | prefix=`cat VERSION_PREFIX` 10 | suffix=`build/revision` 11 | version=$prefix.$suffix 12 | prelude=`bin/prelude` 13 | preludenl=$prelude.$'\n' 14 | 15 | java -jar deps/closure-compiler/compiler.jar -O SIMPLE --formatting PRETTY_PRINT \ 16 | --language_out=ECMASCRIPT_2020 \ 17 | --output_wrapper "$preludenl;(function(){%output%})();" --generate_exports -D TRANSIT_BROWSER_AMD_TARGET=true \ 18 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit.amd \ 19 | --js_output_file=target/transit-$version-amd.js \ 20 | 'deps/closure-library/closure/**.js' 'src/**.js' 21 | -------------------------------------------------------------------------------- /bin/build_release_browser_amd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | mkdir -p target 8 | 9 | prefix=`cat VERSION_PREFIX` 10 | suffix=`build/revision` 11 | version=$prefix.$suffix 12 | prelude=`bin/prelude` 13 | preludenl=$prelude.$'\n' 14 | 15 | java -jar deps/closure-compiler/compiler.jar -O ADVANCED \ 16 | --output_wrapper "$preludenl;(function(){%output%})();" --generate_exports \ 17 | -D TRANSIT_BROWSER_AMD_TARGET=true -D TRANSIT_DEV=false --externs resources/amd_externs.js \ 18 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit.amd \ 19 | --js_output_file=target/transit-$version-amd-min.js \ 20 | 'deps/closure-library/closure/**.js' 'src/**.js' 21 | -------------------------------------------------------------------------------- /doctheme/assets/vendor/prettify/prettify-min.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} -------------------------------------------------------------------------------- /resources/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Tests

4 | 5 | 6 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /resources/prelude.txt: -------------------------------------------------------------------------------- 1 | // transit-js $VERSION 2 | // http://transit-format.org 3 | // 4 | // Copyright 2014 Cognitect. All Rights Reserved. 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS-IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | -------------------------------------------------------------------------------- /bin/deps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd `dirname $0`/.. 6 | 7 | rm -rf deps 8 | rm -rf node_modules 9 | 10 | echo "Installing Node dependencies" 11 | 12 | npm install 13 | npm install grunt 14 | 15 | echo "Installing JVM dependencies" 16 | 17 | CLOSURE_RELEASE="20210302" 18 | mkdir -p deps/closure-compiler 19 | cd deps/closure-compiler 20 | echo "Fetching Google Closure compiler..." 21 | curl --retry 3 -O -s https://repo1.maven.org/maven2/com/google/javascript/closure-compiler/v$CLOSURE_RELEASE/closure-compiler-v$CLOSURE_RELEASE.jar || { echo "Download failed."; exit 1; } 22 | mv closure-compiler-**.jar compiler.jar 23 | cd ../.. 24 | 25 | git clone https://github.com/google/closure-library.git deps/closure-library 26 | 27 | mkdir -p deps/clojure 28 | curl -O https://repo1.maven.org/maven2/org/clojure/clojure/1.6.0/clojure-1.6.0.jar 29 | mv clojure-1.6.0.jar deps/clojure 30 | -------------------------------------------------------------------------------- /src/com/cognitect/transit_amd.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | "use strict"; 16 | 17 | goog.provide("com.cognitect.transit.amd"); 18 | goog.require("com.cognitect.transit"); 19 | 20 | if(TRANSIT_BROWSER_AMD_TARGET) { 21 | define("transit", [], function() { 22 | return com.cognitect.transit; 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /doctheme/partials/module.handlebars: -------------------------------------------------------------------------------- 1 | 2 |

{{moduleName}}

3 |
{{{moduleDescription}}}
4 | 5 |
6 |
7 | {{#if moduleClasses}} 8 |

This module has the following classes:

9 | 14 | {{/if}} 15 |
16 |
17 | {{#if subModules}} 18 |

This module has the following submodules:

19 | 24 | {{/if}} 25 |
26 |
27 |

28 | Module description found: `{{file}}:{{line}}` 29 | -------------------------------------------------------------------------------- /src/com/cognitect/transit/delimiters.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | goog.provide("com.cognitect.transit.delimiters"); 16 | 17 | goog.scope(function() { 18 | 19 | var delimiters = com.cognitect.transit.delimiters; 20 | 21 | /** 22 | * @const 23 | * @type {string} 24 | */ 25 | delimiters.ESC = "~"; 26 | 27 | /** 28 | * @const 29 | * @type {string} 30 | */ 31 | delimiters.TAG = "#"; 32 | 33 | /** 34 | * @const 35 | * @type {string} 36 | */ 37 | delimiters.SUB = "^"; 38 | 39 | /** 40 | * @const 41 | * @type {string} 42 | */ 43 | delimiters.RES = "`"; 44 | 45 | /** 46 | * @const 47 | * @type {string} 48 | */ 49 | delimiters.ESC_TAG = "~#"; 50 | 51 | }); 52 | -------------------------------------------------------------------------------- /bin/closure_deps_graph.clj: -------------------------------------------------------------------------------- 1 | (ns closure-deps-graph 2 | (:require [clojure.java.io :as io]) 3 | (:import [java.io File] 4 | [com.google.javascript.jscomp SourceFile BasicErrorManager] 5 | [com.google.javascript.jscomp.deps BrowserModuleResolver 6 | DepsGenerator DepsGenerator$InclusionStrategy ModuleLoader 7 | ModuleLoader$PathResolver])) 8 | 9 | (defn js-files-in 10 | "Return a sequence of all .js files in the given directory." 11 | [dir] 12 | (filter 13 | #(let [name (.getName ^File %)] 14 | (and (.endsWith name ".js") 15 | (not= \. (first name)))) 16 | (file-seq dir))) 17 | 18 | (spit (io/file "deps/closure-library/closure/goog/transit_deps.js") 19 | (.computeDependencyCalls 20 | (DepsGenerator. 21 | [] 22 | (map #(SourceFile/fromFile (.getAbsolutePath %)) 23 | (mapcat (comp js-files-in io/file) 24 | ["src" "deps/closure-library/closure/goog"])) 25 | DepsGenerator$InclusionStrategy/ALWAYS 26 | (.getAbsolutePath (io/file "deps/closure-library/closure/goog")) 27 | (proxy [BasicErrorManager] [] 28 | (report [level error] 29 | (println error)) 30 | (println [level error] 31 | (println error))) 32 | (ModuleLoader. nil [] [] 33 | BrowserModuleResolver/FACTORY 34 | ModuleLoader$PathResolver/ABSOLUTE)))) 35 | -------------------------------------------------------------------------------- /doctheme/layouts/main.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{htmlTitle}} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

{{title}}

17 |
18 |
19 | API Docs for: {{projectVersion}} 20 |
21 |
22 |
23 | 24 | 27 | 28 |
29 |
{{>layout_content}}
30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /doctheme/partials/events.handlebars: -------------------------------------------------------------------------------- 1 | 2 |
3 | `{{name}}` {{#if type}}<{{#crossLink type}}{{/crossLink}}>{{/if}} 4 | {{#if extended_from}}`/* Extended from {{extended_from}} */`{{/if}} 5 | {{#if overwritten_from}}`/* Overwritten from {{name}} */`{{/if}} 6 |
7 | `{{file}}:{{line}}` 8 | {{{eventDescription}}} 9 | {{#if params}} 10 | Extra event object properties: 11 | 33 | {{/if}} 34 |
35 | 36 | -------------------------------------------------------------------------------- /doctheme/assets/js/tabs.js: -------------------------------------------------------------------------------- 1 | YUI({ 2 | insertBefore: 'site_styles' 3 | }).use('tabview', function(Y) { 4 | var classdocs = Y.one('#classdocs'), 5 | tabviewIndexTable = {}; 6 | if (classdocs) { 7 | if (classdocs.all('li').size()) { 8 | var tabview = new Y.TabView({ srcNode: classdocs }); 9 | tabview.render(); 10 | classdocs.all('li a').each(function (item, index) { 11 | var hash = item.get(['hash']); 12 | type = hash.substring(1); 13 | if (!tabviewIndexTable[type]) { 14 | tabviewIndexTable[type] = index; 15 | } 16 | }) 17 | Y.all('.sidebox.on-page').each(function (item, index) { 18 | var children = item.all('li a'); 19 | children.each(function (cItem, cIndex) { 20 | return function () { 21 | var handleClick = function (e) { 22 | var node = Y.one(this), 23 | hash = node.get(['hash']), 24 | hashValue = hash.substring(1).split('_'), 25 | type = hashValue.shift(), 26 | ogKey = hashValue.join('_'); // in case the hash had other underscores 27 | if (tabviewIndexTable[type] > -1 && tabviewIndexTable[type] !== currentTab) { 28 | currentTab = tabviewIndexTable[type]; 29 | tabview.selectChild(tabviewIndexTable[type]); 30 | } 31 | } 32 | Y.on('click', handleClick, cItem) 33 | }() 34 | }) 35 | }); 36 | } 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "transit-js", 3 | "version": "0.8.773", 4 | "homepage": "https://github.com/cognitect/transit-js", 5 | "description": "Transit is a data format and a set of libraries for conveying values between applications written in different languages. This library provides support for marshalling Transit data to/from Javascript.", 6 | "keywords": [ 7 | "JSON", 8 | "serialization", 9 | "transit-format", 10 | "es6", 11 | "harmony", 12 | "map", 13 | "set", 14 | "polyfill" 15 | ], 16 | "author": "Cognitect", 17 | "license": "Apache-2.0", 18 | "repository": { 19 | "type": "git", 20 | "url": "git://github.com/cognitect/transit-js.git" 21 | }, 22 | "main": "target/transit.js", 23 | "bugs": { 24 | "url": "https://github.com/cognitect/transit-js/issues" 25 | }, 26 | "contributors": [ 27 | "David Nolen (https://github.com/swannodette)" 28 | ], 29 | "engines": { 30 | "node": ">= 0.10.0" 31 | }, 32 | "dependencies": { 33 | }, 34 | "devDependencies": { 35 | "nodeunit": "0.11.0", 36 | "yuidocjs": "0.10.2", 37 | "source-map-support": "0.3.2", 38 | "grunt-contrib-concat": "1.0.1", 39 | "grunt-contrib-nodeunit": "1.0.0", 40 | "grunt-contrib-uglify": "3.0.0", 41 | "grunt-contrib-jshint": "1.1.0", 42 | "grunt-contrib-watch": "1.0.0" 43 | }, 44 | "scripts": { 45 | "test": "echo \"Error: no test specified\" && exit 1" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /doctheme/partials/attrs.handlebars: -------------------------------------------------------------------------------- 1 | 2 |
3 | `{{name}}` {{#if type}}<{{#crossLink type}}{{/crossLink}}>{{/if}} 4 | {{#if extended_from}}`/* Extended from {{extended_from}} */`{{/if}} 5 | {{#if overwritten_from}}`/* Overwritten from {{name}} */`{{/if}} 6 |
7 | `{{file}}:{{line}}` 8 | {{{attrDescription}}} 9 | {{#if emit}} 10 |
11 | Fires: `{{name}}Change(e)` 12 |

Fires when the value for the configuration attribute `{{name}}` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

13 | Parameters:
14 | `e` <EventFacade> An Event Facade object with the following attribute specific properties added: 15 | 21 |
22 | {{/if}} 23 |
24 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy for Nubank Open Source Projects 2 | 3 | ## Supported Versions 4 | 5 | Nubank supports the latest version of each of our open-source projects. Once a new version is released, we stop providing patches for security issues in older versions. 6 | 7 | ## Reporting Security Issues 8 | 9 | Your efforts to responsibly disclose your findings are sincerely appreciated and will be taken into account to acknowledge your contributions. 10 | If you discover a vulnerability, please do the following: 11 | 12 | 1. E-mail your findings to [security@nubank.com.br](mailto:security@nubank.com.br). If the issue is sensitive, please use [our PGP key](https://nubank.com.br/.well-known/security.txt) to encrypt your communications with us. 13 | 2. Do not take advantage of the vulnerability or problem you have discovered. 14 | 3. Do not reveal the problem to others until it has been resolved. 15 | 4. Provide sufficient information to reproduce the problem so we can resolve it as quickly as possible. 16 | 5. You will receive a response from us acknowledging receipt of your vulnerability report. 17 | 6. You'll receive regular updates about our progress. 18 | 7. Once the issue is resolved, we would like to mention your name in any dispatches about the issue so that we can credit you for your discovery. Please engage in responsible privacy practices when disclosing bugs to us, and we'll handle each report with utmost urgency. 19 | 20 | ## Preferred Languages 21 | 22 | We prefer all communications to be in English. 23 | 24 | ## Policy Adherence 25 | 26 | We greatly value your assistance in discovering and reporting vulnerabilities, and look forward to working with users who wish to help ensure Nubank's open-source projects' safety and security. Thank you for supporting Nubank's mission and helping ensure the highest levels of security for our community! 27 | -------------------------------------------------------------------------------- /bench/bson_compare.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | var bson = require("bson"), 16 | BSON = bson.BSONPure.BSON, 17 | Long = bson.Long, 18 | transit = require("../target/transit.js"), 19 | w = transit.writer(); 20 | 21 | function time(f, iters) { 22 | iters = iters || 1; 23 | var avg = []; 24 | for(var i = 0; i < iters; i++) { 25 | var s = new Date(); 26 | f(); 27 | var el = (new Date()).valueOf()-s.valueOf(); 28 | if(iters == 1) { 29 | console.log("Elapsed "+el+"ms"); 30 | console.log("----------"); 31 | } else { 32 | avg.push(el); 33 | } 34 | } 35 | if(iters != 1) { 36 | console.log("Average Elapsed "+(avg.reduce(sum)/iters)+"ms"); 37 | console.log("----------"); 38 | } 39 | } 40 | 41 | var doc = {long: Long.fromNumber(100)} 42 | 43 | console.log("BSON serialize Object 1KV with long", BSON.serialize(doc, false, true, false)); 44 | time(function() { 45 | for(var i = 0; i < 100000; i++) { 46 | BSON.serialize(doc, false, true, false); 47 | } 48 | }); 49 | 50 | var tjs = transit.map(["long", transit.integer("100")]); 51 | console.log("transist.write map 1KV with long", w.write(tjs)); 52 | time(function() { 53 | for(var i = 0; i < 100000; i++) { 54 | w.write(tjs); 55 | } 56 | }); 57 | 58 | -------------------------------------------------------------------------------- /doctheme/partials/classes.handlebars: -------------------------------------------------------------------------------- 1 |

Class {{moduleName}}

2 | {{#if uses}} 3 | Uses: 4 | {{#each uses}} 5 | {{this}} 6 | {{/each}} 7 |
8 | {{/if}} 9 | {{#if extension_for}} 10 | Extension For: 11 | {{#each extension_for}} 12 | {{this}} 13 | {{/each}} 14 |
15 | {{/if}} 16 | {{#if extends}} 17 | Extends: {{#crossLink extends}}{{/crossLink}}
18 | {{/if}} 19 | Class defined in: `{{file}}:{{line}}` 20 |
{{{classDescription}}}
21 | 22 | {{#if is_constructor}} 23 | {{#is_constructor}} 24 | {{>method}} 25 | {{/is_constructor}} 26 | {{/if}} 27 | 28 |
29 | 43 |
44 | {{#if methods}} 45 |
46 | {{#methods}} 47 | {{>method}} 48 | {{/methods}} 49 |
50 | {{/if}} 51 | {{#if properties}} 52 |
53 | {{#properties}} 54 | {{>props}} 55 | {{/properties}} 56 |
57 | {{/if}} 58 | {{#if attrs}} 59 |
60 | {{#attrs}} 61 | {{>attrs}} 62 | {{/attrs}} 63 |
64 | {{/if}} 65 | {{#if events}} 66 |
67 | {{#events}} 68 | {{>events}} 69 | {{/events}} 70 |
71 | {{/if}} 72 |
73 |
74 | -------------------------------------------------------------------------------- /bench/json.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Copyright 2014 Cognitect. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS-IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | process.stdin.setEncoding("utf8"); 18 | 19 | var fs = require("fs"), 20 | fname = process.argv[2] || "example", 21 | iter = process.argv[3] ? parseInt(process.argv[3], 10) : 100, 22 | transit = require("../target/transit.js"), 23 | r = transit.reader(), 24 | w = transit.writer(), 25 | jstr = fs.readFileSync("resources/"+fname+".json", "utf-8"); 26 | tstr = fs.readFileSync("resources/"+fname+".tjs", "utf-8"); 27 | 28 | function time(f, iters) { 29 | iters = iters || 1; 30 | for(var i = 0; i < iters; i++) { 31 | var s = new Date(); 32 | f(); 33 | console.log("Elapsed "+((new Date()).valueOf()-s.valueOf())+"ms"); 34 | console.log("----------"); 35 | } 36 | } 37 | 38 | console.log("JSON.parse "+iter+" iters"); 39 | time(function() { 40 | for(var i = 0; i < iter; i++) { 41 | JSON.parse(jstr); 42 | } 43 | }, 5); 44 | 45 | console.log("transit read "+iter+" iters"); 46 | time(function() { 47 | for(var i = 0; i < iter; i++) { 48 | r.read(tstr); 49 | } 50 | }, 5); 51 | 52 | console.log("JSON.stringify "+iter+" iters"); 53 | var dataJSON = JSON.parse(jstr); 54 | time(function() { 55 | for(var i = 0; i < iter; i++) { 56 | JSON.stringify(dataJSON); 57 | } 58 | }, 5); 59 | 60 | console.log("transit.write "+iter+" iters"); 61 | var dataTransit = r.read(tstr); 62 | time(function() { 63 | for(var i = 0; i < iter; i++) { 64 | w.write(dataTransit); 65 | } 66 | }, 5); 67 | -------------------------------------------------------------------------------- /doctheme/partials/sidebar.handlebars: -------------------------------------------------------------------------------- 1 | 13 | 14 | {{#if methods}} 15 | 27 | {{/if}} 28 | 29 | {{#if events}} 30 | 42 | {{/if}} 43 | 44 | {{#if props}} 45 | 57 | {{/if}} 58 | 59 | {{#if attributes}} 60 | 72 | {{/if}} 73 | 74 | {{#if fileTree}} 75 | 83 | {{/if}} 84 | 85 | -------------------------------------------------------------------------------- /resources/amd_externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {Object} 3 | */ 4 | Object.value; 5 | /** 6 | * @type {Boolean} 7 | */ 8 | Object.done; 9 | /** 10 | * @type {Object} 11 | */ 12 | Object.rep; 13 | /** 14 | * @type {String} 15 | */ 16 | Object.tag; 17 | /** 18 | * @type {Object} 19 | */ 20 | Object.init; 21 | /** 22 | * @type {Boolean} 23 | */ 24 | Object.add; 25 | /** 26 | * @type {Object} 27 | */ 28 | Object.finalize; 29 | /** 30 | * @type {String} 31 | */ 32 | Object.fromArray; 33 | var module = {}; 34 | module.exports = {}; 35 | var define = function() {}; 36 | var transit = {}; 37 | transit.reader = function(){}; 38 | transit.writer = function(){}; 39 | transit.makeBuilder = function(){}; 40 | transit.makeWriteHandler = function(){}; 41 | transit.date = function(){}; 42 | transit.integer = function(){}; 43 | transit.isInteger = function(){}; 44 | transit.uuid = function(){}; 45 | transit.isUUID = function(){}; 46 | transit.bigInt = function(){}; 47 | transit.isBigInt = function(){}; 48 | transit.bigDec = function(){}; 49 | transit.isBigDec = function(){}; 50 | transit.keyword = function(){}; 51 | transit.isKeyword = function(){}; 52 | transit.symbol = function(){}; 53 | transit.isSymbol = function(){}; 54 | transit.binary = function(){}; 55 | transit.isBinary = function(){}; 56 | transit.uri = function(){}; 57 | transit.isURI = function(){}; 58 | transit.map = function(){}; 59 | transit.isMap = function(){}; 60 | transit.set = function(){}; 61 | transit.isSet = function(){}; 62 | transit.list = function(){}; 63 | transit.isList = function(){}; 64 | transit.quoted = function(){}; 65 | transit.isQuoted = function(){}; 66 | transit.tagged = function(){}; 67 | transit.isTaggedValue = function(){}; 68 | transit.link = function(){}; 69 | transit.isLink = function(){}; 70 | transit.hash = function(){}; 71 | transit.hashMapLike = function(){}; 72 | transit.hashArrayLike = function(){}; 73 | transit.equals = function(){}; 74 | transit.extendToEQ = function(){}; 75 | transit.mapToObject = function(){}; 76 | transit.objectToMap = function(){}; 77 | transit.decoder = function(){}; 78 | transit.UUIDfromString = function(){}; 79 | transit.randomUUID = function(){}; 80 | transit.stringableKeys = function(){}; 81 | transit.readCache = function() {}; 82 | transit.writeCache = function() {}; 83 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /*global module:false*/ 2 | module.exports = function(grunt) { 3 | 4 | // Project configuration. 5 | grunt.initConfig({ 6 | // Metadata. 7 | pkg: grunt.file.readJSON('package.json'), 8 | banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + 9 | '<%= grunt.template.today("yyyy-mm-dd") %>\n' + 10 | '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + 11 | '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + 12 | ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n', 13 | // Task configuration. 14 | concat: { 15 | options: { 16 | banner: '<%= banner %>', 17 | stripBanners: true 18 | }, 19 | dist: { 20 | src: ['lib/<%= pkg.name %>.js'], 21 | dest: 'dist/<%= pkg.name %>.js' 22 | } 23 | }, 24 | uglify: { 25 | options: { 26 | banner: '<%= banner %>' 27 | }, 28 | dist: { 29 | src: '<%= concat.dist.dest %>', 30 | dest: 'dist/<%= pkg.name %>.min.js' 31 | } 32 | }, 33 | jshint: { 34 | options: { 35 | curly: true, 36 | eqeqeq: true, 37 | immed: true, 38 | latedef: true, 39 | newcap: true, 40 | noarg: true, 41 | sub: true, 42 | undef: true, 43 | unused: true, 44 | boss: true, 45 | eqnull: true, 46 | globals: {} 47 | }, 48 | gruntfile: { 49 | src: 'Gruntfile.js' 50 | }, 51 | lib_test: { 52 | src: ['lib/**/*.js', 'test/**/*.js'] 53 | } 54 | }, 55 | nodeunit: { 56 | files: ['test/**/*.js'] 57 | }, 58 | watch: { 59 | gruntfile: { 60 | files: '<%= jshint.gruntfile.src %>', 61 | tasks: ['jshint:gruntfile'] 62 | }, 63 | lib_test: { 64 | files: '<%= jshint.lib_test.src %>', 65 | tasks: ['jshint:lib_test', 'nodeunit'] 66 | } 67 | } 68 | }); 69 | 70 | // These plugins provide necessary tasks. 71 | grunt.loadNpmTasks('grunt-contrib-concat'); 72 | grunt.loadNpmTasks('grunt-contrib-uglify'); 73 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 74 | grunt.loadNpmTasks('grunt-contrib-jshint'); 75 | grunt.loadNpmTasks('grunt-contrib-watch'); 76 | 77 | // Default task. 78 | grunt.registerTask('default', ['jshint', 'nodeunit', 'concat', 'uglify']); 79 | 80 | }; 81 | -------------------------------------------------------------------------------- /src/com/cognitect/transit/impl/reader.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | goog.provide("com.cognitect.transit.impl.reader"); 16 | goog.require("com.cognitect.transit.impl.decoder"); 17 | goog.require("com.cognitect.transit.caching"); 18 | 19 | goog.scope(function () { 20 | 21 | var reader = com.cognitect.transit.impl.reader, 22 | decoder = com.cognitect.transit.impl.decoder, 23 | caching = com.cognitect.transit.caching; 24 | 25 | /** 26 | * A JSON unmarshaller 27 | * @constructor 28 | */ 29 | reader.JSONUnmarshaller = function Transit$JSONUnmarshaller(opts) { 30 | this.decoder = new decoder.Decoder(opts); 31 | }; 32 | 33 | /** 34 | * @param {string} str a JSON string 35 | * @param {caching.ReadCache} cache a read cache 36 | * @returns {*} 37 | */ 38 | reader.JSONUnmarshaller.prototype.unmarshal = function (str, cache) { 39 | return this.decoder.decode(JSON.parse(str), cache); 40 | }; 41 | 42 | /** 43 | * A transit reader 44 | * @constructor 45 | * @param {reader.JSONUnmarshaller} unmarshaller 46 | * @param {Object=} options 47 | */ 48 | reader.Reader = function Transit$Reader(unmarshaller, options) { 49 | this.unmarshaller = unmarshaller; 50 | this.options = options || {}; 51 | this.cache = this.options["cache"] ? this.options["cache"] : new caching.ReadCache(); 52 | }; 53 | 54 | /** 55 | * @param {string} str a string to be read 56 | * @returns {*} 57 | */ 58 | reader.Reader.prototype.read = function (str) { 59 | var ret = this.unmarshaller.unmarshal(str, this.cache) 60 | this.cache.clear(); 61 | return ret; 62 | }; 63 | reader.Reader.prototype["read"] = reader.Reader.prototype.read; 64 | 65 | }); 66 | -------------------------------------------------------------------------------- /resources/node_externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {Object} 3 | */ 4 | Object.value; 5 | /** 6 | * @type {Boolean} 7 | */ 8 | Object.done; 9 | /** 10 | * @type {Object} 11 | */ 12 | Object.rep; 13 | /** 14 | * @type {String} 15 | */ 16 | Object.tag; 17 | /** 18 | * @type {Object} 19 | */ 20 | Object.init; 21 | /** 22 | * @type {Boolean} 23 | */ 24 | Object.add; 25 | /** 26 | * @type {Object} 27 | */ 28 | Object.finalize; 29 | /** 30 | * @type {String} 31 | */ 32 | Object.fromArray; 33 | var module = {}; 34 | module.exports = {}; 35 | module.exports.reader = function() {}; 36 | module.exports.writer = function() {}; 37 | module.exports.makeWriteHandler = function() {}; 38 | module.exports.makeBuilder = function() {}; 39 | module.exports.date = function() {}; 40 | module.exports.uuid = function() {}; 41 | module.exports.isUUID = function() {}; 42 | module.exports.integer = function() {}; 43 | module.exports.isInteger = function() {}; 44 | module.exports.bigInt = function() {}; 45 | module.exports.isBigInt = function() {}; 46 | module.exports.bigDec = function() {}; 47 | module.exports.isBigDec = function() {}; 48 | module.exports.keyword = function() {}; 49 | module.exports.isKeyword = function() {}; 50 | module.exports.symbol = function() {}; 51 | module.exports.isSymbol = function() {}; 52 | module.exports.binary = function() {}; 53 | module.exports.isBinary = function() {}; 54 | module.exports.uri = function() {}; 55 | module.exports.isURI = function() {}; 56 | module.exports.map = function() {}; 57 | module.exports.isMap = function() {}; 58 | module.exports.set = function() {}; 59 | module.exports.isSet = function() {}; 60 | module.exports.list = function() {}; 61 | module.exports.isList = function() {}; 62 | module.exports.quoted = function() {}; 63 | module.exports.isQuoted = function() {}; 64 | module.exports.tagged = function() {}; 65 | module.exports.isTaggedValue = function() {}; 66 | module.exports.link = function() {}; 67 | module.exports.isLink = function() {}; 68 | module.exports.hash = function() {}; 69 | module.exports.hashMapLike = function() {}; 70 | module.exports.hashArrayLike = function() {}; 71 | module.exports.equals = function() {}; 72 | module.exports.extendToEQ = function() {}; 73 | module.exports.mapToObject = function() {}; 74 | module.exports.objectToMap = function() {}; 75 | module.exports.decoder = function() {}; 76 | module.exports.UUIDfromString = function() {}; 77 | module.exports.randomUUID = function() {}; 78 | module.exports.stringableKeys = function() {}; 79 | module.exports.readCache = function() {}; 80 | module.exports.writeCache = function() {}; 81 | -------------------------------------------------------------------------------- /doctheme/partials/method.handlebars: -------------------------------------------------------------------------------- 1 | 2 |
3 | {{#if final}}final {{/if}}`{{name}}`( `{{paramsList}} ` ) {{#if access}}`/* {{access}} method */`{{/if}} 4 |
5 | 6 | {{#if overwritten_from}} 7 | Defined in {{overwritten_from/class}} but overwritten locally: 8 | {{else}} 9 | {{#if extended_from}} Defined in {{extended_from}}: {{/if}} 10 | {{/if}} 11 | `{{file}}:{{line}}` 12 |
13 | {{{methodDescription}}} 14 | {{#if params}} 15 | Parameters: 16 | 46 | {{/if}} 47 | {{#if return}} 48 | {{#return}} 49 |
Returns: {{#if type}}<{{#crossLink type}}{{/crossLink}}> {{/if}}{{{description}}}
50 | {{/return}} 51 | {{/if}} 52 | {{#if throws}} 53 | {{#throws}} 54 |
Throws: {{#if type}}<{{#crossLink type}}{{/crossLink}}> {{/if}}{{{description}}}
55 | {{/throws}} 56 | {{/if}} 57 | {{#if example}} 58 |
Example
59 | {{{example}}} 60 | {{/if}} 61 |
62 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.cognitect 5 | transit-js 6 | jar 7 | dev 8 | transit-js 9 | Transit is a data format and a set of libraries for conveying values between applications written in different languages. This library provides support for marshalling Transit data to/from Javascript. 10 | http://github.com/cognitect/transit-js 11 | 12 | 13 | The Apache Software License, Version 2.0 14 | http://www.apache.org/licenses/LICENSE-2.0.txt 15 | 16 | 17 | 18 | 19 | David Nolen 20 | david.nolen@cognitect.com 21 | Cognitect 22 | http://cognitect.com 23 | 24 | 25 | 26 | scm:git:git@github.com:cognitect/transit-js.git 27 | scm:git:git@github.com:cognitect/transit-js.git 28 | git@github.com:cognitect/transit-js.git 29 | 30 | 31 | 32 | 33 | src 34 | 35 | 36 | src 37 | 38 | 39 | 40 | 41 | org.codehaus.mojo 42 | versions-maven-plugin 43 | 2.1 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-javadoc-plugin 48 | 2.9.1 49 | 50 | 51 | attach-javadocs 52 | 53 | jar 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.apache.maven.plugins 62 | maven-source-plugin 63 | 2.2.1 64 | 65 | 66 | attach-sources 67 | 68 | jar-no-fork 69 | 70 | 71 | 72 | 73 | 74 | org.sonatype.plugins 75 | nexus-staging-maven-plugin 76 | 1.6.2 77 | true 78 | 79 | ossrh 80 | https://oss.sonatype.org/ 81 | true 82 | 83 | 84 | 85 | org.apache.maven.plugins 86 | maven-gpg-plugin 87 | 1.5 88 | 89 | 90 | sign-artifacts 91 | verify 92 | 93 | sign 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/com/cognitect/transit/caching.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | goog.provide("com.cognitect.transit.caching"); 16 | goog.require("com.cognitect.transit.delimiters"); 17 | 18 | goog.scope(function() { 19 | 20 | var caching = com.cognitect.transit.caching, 21 | d = com.cognitect.transit.delimiters; 22 | 23 | /** 24 | * @const 25 | * @type {number} 26 | */ 27 | caching.MIN_SIZE_CACHEABLE = 3; 28 | 29 | /** 30 | * @const 31 | * @type {number} 32 | */ 33 | caching.BASE_CHAR_IDX = 48; 34 | 35 | /** 36 | * @const 37 | * @type {number} 38 | */ 39 | caching.CACHE_CODE_DIGITS = 44; 40 | 41 | /** 42 | * @const 43 | * @type {number} 44 | */ 45 | caching.MAX_CACHE_ENTRIES = caching.CACHE_CODE_DIGITS*caching.CACHE_CODE_DIGITS; 46 | 47 | /** 48 | * @const 49 | * @type {number} 50 | */ 51 | caching.MAX_CACHE_SIZE = 4096; 52 | 53 | caching.isCacheable = function(string, asMapKey) { 54 | if(string.length > caching.MIN_SIZE_CACHEABLE) { 55 | if(asMapKey) { 56 | return true; 57 | } else { 58 | var c0 = string.charAt(0), 59 | c1 = string.charAt(1); 60 | if(c0 === d.ESC) { 61 | return c1 === ":" || c1 === "$" || c1 === "#"; 62 | } else { 63 | return false; 64 | } 65 | } 66 | } else { 67 | return false; 68 | } 69 | }; 70 | 71 | // ============================================================================= 72 | // WriteCache 73 | 74 | caching.idxToCode = function(idx) { 75 | var hi = Math.floor(idx / caching.CACHE_CODE_DIGITS), 76 | lo = idx % caching.CACHE_CODE_DIGITS, 77 | loc = String.fromCharCode(lo + caching.BASE_CHAR_IDX) 78 | if(hi === 0) { 79 | return d.SUB + loc; 80 | } else { 81 | return d.SUB + String.fromCharCode(hi + caching.BASE_CHAR_IDX) + loc; 82 | } 83 | }; 84 | 85 | /** 86 | * @constructor 87 | */ 88 | caching.WriteCache = function() { 89 | this.idx = 0; 90 | this.gen = 0; 91 | this.cacheSize = 0; 92 | this.cache = {}; 93 | }; 94 | 95 | caching.WriteCache.prototype.write = function(string, asMapKey) { 96 | if(caching.isCacheable(string, asMapKey)) { 97 | if(this.cacheSize === caching.MAX_CACHE_SIZE) { 98 | this.clear(); 99 | this.gen = 0; 100 | this.cache = {}; 101 | } else if(this.idx === caching.MAX_CACHE_ENTRIES) { 102 | this.clear(); 103 | } 104 | var entry = this.cache[string]; 105 | if(entry == null) { 106 | this.cache[string] = [caching.idxToCode(this.idx), this.gen]; 107 | this.idx++; 108 | return string; 109 | } else if(entry[1] != this.gen) { 110 | entry[1] = this.gen; 111 | entry[0] = caching.idxToCode(this.idx); 112 | this.idx++; 113 | return string; 114 | } else { 115 | return entry[0]; 116 | } 117 | } else { 118 | return string; 119 | } 120 | }; 121 | 122 | caching.WriteCache.prototype.clear = function Transit$WriteCache() { 123 | this.idx = 0; 124 | this.gen++; 125 | }; 126 | 127 | caching.writeCache = function() { 128 | return new caching.WriteCache(); 129 | }; 130 | 131 | // ============================================================================= 132 | // ReadCache 133 | 134 | caching.isCacheCode = function(string) { 135 | return (string.charAt(0) === d.SUB) && (string.charAt(1) !== " "); 136 | }; 137 | 138 | caching.codeToIdx = function(code) { 139 | if(code.length === 2) { 140 | return code.charCodeAt(1) - caching.BASE_CHAR_IDX; 141 | } else { 142 | var hi = (code.charCodeAt(1) - caching.BASE_CHAR_IDX) * caching.CACHE_CODE_DIGITS, 143 | lo = (code.charCodeAt(2) - caching.BASE_CHAR_IDX); 144 | return hi + lo; 145 | } 146 | }; 147 | 148 | /** 149 | * @constructor 150 | */ 151 | caching.ReadCache = function Transit$ReadCache() { 152 | this.idx = 0; 153 | this.cache = []; 154 | }; 155 | 156 | caching.ReadCache.prototype.write = function(obj, asMapKey) { 157 | if(this.idx == caching.MAX_CACHE_ENTRIES) { 158 | this.idx = 0; 159 | } 160 | this.cache[this.idx] = obj; 161 | this.idx++; 162 | return obj; 163 | }; 164 | 165 | caching.ReadCache.prototype.read = function(string, asMapKey) { 166 | return this.cache[caching.codeToIdx(string)]; 167 | }; 168 | 169 | caching.ReadCache.prototype.clear = function() { 170 | this.idx = 0; 171 | }; 172 | 173 | caching.readCache = function() { 174 | return new caching.ReadCache(); 175 | }; 176 | 177 | }); 178 | -------------------------------------------------------------------------------- /src/com/cognitect/transit/util.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | goog.provide("com.cognitect.transit.util"); 16 | goog.require("goog.object"); 17 | 18 | goog.scope(function () { 19 | 20 | var util = com.cognitect.transit.util, 21 | gobject = goog.object; 22 | 23 | if (typeof Object.keys != "undefined") { 24 | util.objectKeys = function (obj) { 25 | return Object.keys(obj); 26 | }; 27 | } else { 28 | util.objectKeys = function (obj) { 29 | return gobject.getKeys(obj); 30 | }; 31 | } 32 | 33 | if (typeof Array.isArray != "undefined") { 34 | util.isArray = function (obj) { 35 | return Array.isArray(obj); 36 | }; 37 | } else { 38 | util.isArray = function (obj) { 39 | return goog.typeOf(obj) === "array"; 40 | }; 41 | } 42 | 43 | /** 44 | * @const 45 | * @type {string} 46 | */ 47 | util.chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 48 | 49 | util.randInt = function (ub) { 50 | return Math.round(Math.random() * ub); 51 | }; 52 | 53 | util.randHex = function () { 54 | return util.randInt(15).toString(16); 55 | }; 56 | 57 | util.randomUUID = function () { 58 | var rhex = (0x8 | (0x3 & util.randInt(14))).toString(16), 59 | ret = util.randHex() + util.randHex() + util.randHex() + util.randHex() + 60 | util.randHex() + util.randHex() + util.randHex() + util.randHex() + "-" + 61 | util.randHex() + util.randHex() + util.randHex() + util.randHex() + "-" + 62 | "4" + util.randHex() + util.randHex() + util.randHex() + "-" + 63 | rhex + util.randHex() + util.randHex() + util.randHex() + "-" + 64 | util.randHex() + util.randHex() + util.randHex() + util.randHex() + 65 | util.randHex() + util.randHex() + util.randHex() + util.randHex() + 66 | util.randHex() + util.randHex() + util.randHex() + util.randHex(); 67 | return ret; 68 | }; 69 | 70 | // https://github.com/davidchambers/Base64.js 71 | 72 | util.btoa = function (input) { 73 | if (typeof btoa != "undefined") { 74 | return btoa(input); 75 | } else { 76 | var str = String(input); 77 | for ( 78 | var block, charCode, idx = 0, map = util.chars, output = ''; 79 | str.charAt(idx | 0) || (map = '=', idx % 1); 80 | output += map.charAt(63 & block >> 8 - idx % 1 * 8) 81 | ) { 82 | charCode = str.charCodeAt(idx += 3 / 4); 83 | if (charCode > 0xFF) { 84 | throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); 85 | } 86 | block = block << 8 | charCode; 87 | } 88 | return output; 89 | } 90 | }; 91 | 92 | /** 93 | * @suppress {uselessCode} 94 | */ 95 | util.atob = function (input) { 96 | if (typeof atob != "undefined") { 97 | return atob(input); 98 | } else { 99 | var str = String(input).replace(/=+$/, ''); 100 | if (str.length % 4 == 1) { 101 | throw new Error("'atob' failed: The string to be decoded is not correctly encoded."); 102 | } 103 | for ( 104 | var bc = 0, bs, buffer, idx = 0, output = ''; 105 | buffer = str.charAt(idx++); 106 | ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, 107 | bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 108 | ) { 109 | buffer = util.chars.indexOf(buffer); 110 | } 111 | return output; 112 | } 113 | }; 114 | 115 | util.Uint8ToBase64 = function (u8Arr) { 116 | var CHUNK_SIZE = 0x8000, 117 | index = 0, 118 | length = u8Arr.length, 119 | result = '', 120 | slice = null; 121 | 122 | while (index < length) { 123 | slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length)); 124 | result += String.fromCharCode.apply(null, slice); 125 | index += CHUNK_SIZE; 126 | } 127 | 128 | return util.btoa(result); 129 | }; 130 | 131 | util.Base64ToUint8 = function (base64) { 132 | var binary_string = util.atob(base64), 133 | len = binary_string.length, 134 | bytes = new Uint8Array(len); 135 | 136 | for (var i = 0; i < len; i++) { 137 | var ascii = binary_string.charCodeAt(i); 138 | bytes[i] = ascii; 139 | } 140 | 141 | return bytes; 142 | }; 143 | 144 | }); 145 | -------------------------------------------------------------------------------- /resources/example.tjs: -------------------------------------------------------------------------------- 1 | [["^ ","id",0,"guid","e384ff1d-f4bd-4988-8e21-347752320651","isActive",true,"balance","$2,487.22","picture","http://placehold.it/32x32","age",36,"eyeColor","blue","name","Myra Turner","gender","female","company","BILLMED","email","myraturner@billmed.com","phone","+1 (982) 559-2761","address","482 Chase Court, Williamson, Texas, 8866","about","Aliqua dolor ad duis magna. Eiusmod exercitation magna exercitation est duis nostrud nulla laborum adipisicing labore nulla occaecat non mollit. Laboris duis est esse eiusmod mollit ex excepteur excepteur do culpa irure minim. Et et est enim sint aliquip elit proident tempor magna labore elit do exercitation.\r\n","registered","2014-01-14T08:18:13 +05:00","latitude",51.882021,"longitude",-101.425544,"tags",["qui","aute","eiusmod","incididunt","qui","consectetur","et"],"friends",[["^ ","id",0,"^&","Angelita Sawyer"],["^ ","id",1,"^&","Bobbi Bruce"],["^ ","id",2,"^&","Jamie Hyde"]],"greeting","Hello, Myra Turner! You have 3 unread messages.","favoriteFruit","strawberry"],["^ ","id",1,"^!","3d3bc861-0984-4528-9d53-1e34cc70fa30","^\"",true,"^#","$1,213.54","^$","http://placehold.it/32x32","age",32,"^%","blue","^&","Elisa Long","^'","female","^(","IZZBY","^)","elisalong@izzby.com","^*","+1 (977) 557-2578","^+","351 Meserole Avenue, Linwood, Pennsylvania, 5750","^,","Mollit aliquip mollit proident nulla dolore sit amet sit pariatur deserunt. Aute consequat qui excepteur aute labore ut ea ea voluptate excepteur id ullamco elit. Nostrud cillum laboris labore ad. Incididunt qui consequat fugiat deserunt ut est mollit. Nostrud dolor proident sint ea dolor consectetur consectetur ullamco culpa quis amet esse nulla. Deserunt do velit dolor quis sunt laboris cupidatat anim exercitation.\r\n","^-","2014-05-14T16:48:45 +04:00","^.",60.423509,"^/",-143.17331,"^0",["officia","sunt","ullamco","labore","exercitation","consequat","anim"],"^1",[["^ ","id",0,"^&","Dixon Kirkland"],["^ ","id",1,"^&","Richard Hinton"],["^ ","id",2,"^&","Stokes Franco"]],"^2","Hello, Elisa Long! You have 3 unread messages.","^3","strawberry"],["^ ","id",2,"^!","0bfb7831-0fb2-4801-bf45-1b2aa02ec13e","^\"",true,"^#","$3,977.72","^$","http://placehold.it/32x32","age",20,"^%","brown","^&","Crystal Wilkerson","^'","female","^(","ZIPAK","^)","crystalwilkerson@zipak.com","^*","+1 (934) 465-3461","^+","190 Lincoln Road, Ballico, New Mexico, 2369","^,","Dolor velit amet nisi sint consequat qui nostrud veniam dolor excepteur quis excepteur. Veniam ad dolor minim reprehenderit ullamco anim ipsum sunt non commodo. Reprehenderit deserunt anim dolor cillum officia ea. Dolore ipsum sunt eiusmod nostrud nostrud voluptate magna sit esse incididunt sunt aute aliquip. Dolor tempor labore officia officia ipsum sint anim exercitation esse pariatur cupidatat.\r\n","^-","2014-02-03T02:25:11 +05:00","^.",86.894988,"^/",76.403233,"^0",["non","ullamco","consectetur","commodo","sunt","proident","ex"],"^1",[["^ ","id",0,"^&","Knight Lawrence"],["^ ","id",1,"^&","Judith Daniels"],["^ ","id",2,"^&","Lee Trujillo"]],"^2","Hello, Crystal Wilkerson! You have 2 unread messages.","^3","strawberry"],["^ ","id",3,"^!","d3f201f8-2225-4bc6-9790-87b6011627a3","^\"",false,"^#","$2,945.55","^$","http://placehold.it/32x32","age",38,"^%","blue","^&","Kate Leonard","^'","female","^(","BEDLAM","^)","kateleonard@bedlam.com","^*","+1 (970) 463-2157","^+","212 Vista Place, Ventress, Massachusetts, 4835","^,","Quis qui anim id sunt non do. Velit id do aliquip id reprehenderit ad laboris consectetur magna. Aute fugiat et sit exercitation sunt qui in duis sit ex amet incididunt sit do. Eiusmod occaecat minim anim consequat reprehenderit et pariatur. Eiusmod sunt laborum in nulla amet non minim amet. Culpa do id sint nostrud incididunt mollit laboris ad eu consectetur ut in elit adipisicing.\r\n","^-","2014-01-05T20:20:28 +05:00","^.",75.542171,"^/",135.538445,"^0",["non","et","Lorem","officia","anim","dolor","proident"],"^1",[["^ ","id",0,"^&","Debora Patel"],["^ ","id",1,"^&","Rosalyn May"],["^ ","id",2,"^&","Keith Munoz"]],"^2","Hello, Kate Leonard! You have 6 unread messages.","^3","banana"],["^ ","id",4,"^!","c998f926-d7c5-4000-a8e3-81409e05101a","^\"",false,"^#","$1,380.79","^$","http://placehold.it/32x32","age",26,"^%","green","^&","Love Hurley","^'","male","^(","ZERBINA","^)","lovehurley@zerbina.com","^*","+1 (961) 479-3084","^+","229 Sutter Avenue, Harrison, West Virginia, 9621","^,","Consectetur ea sunt Lorem est culpa dolor ea. Ipsum fugiat nostrud proident Lorem consectetur reprehenderit fugiat mollit. Reprehenderit dolore officia duis commodo exercitation Lorem aute proident aute ex sit proident. Incididunt voluptate irure voluptate reprehenderit ea dolor enim tempor eu exercitation consectetur duis. Velit velit velit consequat qui quis. Aliqua proident velit quis sint sit cupidatat ea nisi elit.\r\n","^-","2014-05-26T12:12:50 +04:00","^.",-14.523953,"^/",-142.275524,"^0",["occaecat","nostrud","quis","pariatur","tempor","et","cillum"],"^1",[["^ ","id",0,"^&","Bettie Meyers"],["^ ","id",1,"^&","Knapp Wise"],["^ ","id",2,"^&","Rosanna Bond"]],"^2","Hello, Love Hurley! You have 5 unread messages.","^3","apple"],["^ ","id",5,"^!","4f4b6cdf-2e11-464c-a496-d3020e0981af","^\"",false,"^#","$2,782.47","^$","http://placehold.it/32x32","age",31,"^%","blue","^&","Mayo Murray","^'","male","^(","CODACT","^)","mayomurray@codact.com","^*","+1 (943) 478-2468","^+","964 Lott Place, Needmore, Iowa, 854","^,","Magna irure non eiusmod mollit ullamco occaecat cupidatat est eiusmod. Irure ex ea ea aliqua aute veniam proident cillum deserunt. Ipsum aute deserunt et deserunt esse do quis anim occaecat eiusmod nostrud fugiat sit. Aute aute adipisicing labore amet mollit eiusmod non laborum elit ex deserunt incididunt sunt aliqua.\r\n","^-","2014-04-22T21:45:00 +04:00","^.",-44.620984,"^/",112.695424,"^0",["cupidatat","irure","cupidatat","labore","pariatur","ipsum","sit"],"^1",[["^ ","id",0,"^&","Hunter Pace"],["^ ","id",1,"^&","Stevens Simpson"],["^ ","id",2,"^&","Martina Olsen"]],"^2","Hello, Mayo Murray! You have 3 unread messages.","^3","strawberry"]] -------------------------------------------------------------------------------- /resources/example.json: -------------------------------------------------------------------------------- 1 | [{"id":0,"guid":"e384ff1d-f4bd-4988-8e21-347752320651","isActive":true,"balance":"$2,487.22","picture":"http://placehold.it/32x32","age":36,"eyeColor":"blue","name":"Myra Turner","gender":"female","company":"BILLMED","email":"myraturner@billmed.com","phone":"+1 (982) 559-2761","address":"482 Chase Court, Williamson, Texas, 8866","about":"Aliqua dolor ad duis magna. Eiusmod exercitation magna exercitation est duis nostrud nulla laborum adipisicing labore nulla occaecat non mollit. Laboris duis est esse eiusmod mollit ex excepteur excepteur do culpa irure minim. Et et est enim sint aliquip elit proident tempor magna labore elit do exercitation.\r\n","registered":"2014-01-14T08:18:13 +05:00","latitude":51.882021,"longitude":-101.425544,"tags":["qui","aute","eiusmod","incididunt","qui","consectetur","et"],"friends":[{"id":0,"name":"Angelita Sawyer"},{"id":1,"name":"Bobbi Bruce"},{"id":2,"name":"Jamie Hyde"}],"greeting":"Hello, Myra Turner! You have 3 unread messages.","favoriteFruit":"strawberry"},{"id":1,"guid":"3d3bc861-0984-4528-9d53-1e34cc70fa30","isActive":true,"balance":"$1,213.54","picture":"http://placehold.it/32x32","age":32,"eyeColor":"blue","name":"Elisa Long","gender":"female","company":"IZZBY","email":"elisalong@izzby.com","phone":"+1 (977) 557-2578","address":"351 Meserole Avenue, Linwood, Pennsylvania, 5750","about":"Mollit aliquip mollit proident nulla dolore sit amet sit pariatur deserunt. Aute consequat qui excepteur aute labore ut ea ea voluptate excepteur id ullamco elit. Nostrud cillum laboris labore ad. Incididunt qui consequat fugiat deserunt ut est mollit. Nostrud dolor proident sint ea dolor consectetur consectetur ullamco culpa quis amet esse nulla. Deserunt do velit dolor quis sunt laboris cupidatat anim exercitation.\r\n","registered":"2014-05-14T16:48:45 +04:00","latitude":60.423509,"longitude":-143.17331,"tags":["officia","sunt","ullamco","labore","exercitation","consequat","anim"],"friends":[{"id":0,"name":"Dixon Kirkland"},{"id":1,"name":"Richard Hinton"},{"id":2,"name":"Stokes Franco"}],"greeting":"Hello, Elisa Long! You have 3 unread messages.","favoriteFruit":"strawberry"},{"id":2,"guid":"0bfb7831-0fb2-4801-bf45-1b2aa02ec13e","isActive":true,"balance":"$3,977.72","picture":"http://placehold.it/32x32","age":20,"eyeColor":"brown","name":"Crystal Wilkerson","gender":"female","company":"ZIPAK","email":"crystalwilkerson@zipak.com","phone":"+1 (934) 465-3461","address":"190 Lincoln Road, Ballico, New Mexico, 2369","about":"Dolor velit amet nisi sint consequat qui nostrud veniam dolor excepteur quis excepteur. Veniam ad dolor minim reprehenderit ullamco anim ipsum sunt non commodo. Reprehenderit deserunt anim dolor cillum officia ea. Dolore ipsum sunt eiusmod nostrud nostrud voluptate magna sit esse incididunt sunt aute aliquip. Dolor tempor labore officia officia ipsum sint anim exercitation esse pariatur cupidatat.\r\n","registered":"2014-02-03T02:25:11 +05:00","latitude":86.894988,"longitude":76.403233,"tags":["non","ullamco","consectetur","commodo","sunt","proident","ex"],"friends":[{"id":0,"name":"Knight Lawrence"},{"id":1,"name":"Judith Daniels"},{"id":2,"name":"Lee Trujillo"}],"greeting":"Hello, Crystal Wilkerson! You have 2 unread messages.","favoriteFruit":"strawberry"},{"id":3,"guid":"d3f201f8-2225-4bc6-9790-87b6011627a3","isActive":false,"balance":"$2,945.55","picture":"http://placehold.it/32x32","age":38,"eyeColor":"blue","name":"Kate Leonard","gender":"female","company":"BEDLAM","email":"kateleonard@bedlam.com","phone":"+1 (970) 463-2157","address":"212 Vista Place, Ventress, Massachusetts, 4835","about":"Quis qui anim id sunt non do. Velit id do aliquip id reprehenderit ad laboris consectetur magna. Aute fugiat et sit exercitation sunt qui in duis sit ex amet incididunt sit do. Eiusmod occaecat minim anim consequat reprehenderit et pariatur. Eiusmod sunt laborum in nulla amet non minim amet. Culpa do id sint nostrud incididunt mollit laboris ad eu consectetur ut in elit adipisicing.\r\n","registered":"2014-01-05T20:20:28 +05:00","latitude":75.542171,"longitude":135.538445,"tags":["non","et","Lorem","officia","anim","dolor","proident"],"friends":[{"id":0,"name":"Debora Patel"},{"id":1,"name":"Rosalyn May"},{"id":2,"name":"Keith Munoz"}],"greeting":"Hello, Kate Leonard! You have 6 unread messages.","favoriteFruit":"banana"},{"id":4,"guid":"c998f926-d7c5-4000-a8e3-81409e05101a","isActive":false,"balance":"$1,380.79","picture":"http://placehold.it/32x32","age":26,"eyeColor":"green","name":"Love Hurley","gender":"male","company":"ZERBINA","email":"lovehurley@zerbina.com","phone":"+1 (961) 479-3084","address":"229 Sutter Avenue, Harrison, West Virginia, 9621","about":"Consectetur ea sunt Lorem est culpa dolor ea. Ipsum fugiat nostrud proident Lorem consectetur reprehenderit fugiat mollit. Reprehenderit dolore officia duis commodo exercitation Lorem aute proident aute ex sit proident. Incididunt voluptate irure voluptate reprehenderit ea dolor enim tempor eu exercitation consectetur duis. Velit velit velit consequat qui quis. Aliqua proident velit quis sint sit cupidatat ea nisi elit.\r\n","registered":"2014-05-26T12:12:50 +04:00","latitude":-14.523953,"longitude":-142.275524,"tags":["occaecat","nostrud","quis","pariatur","tempor","et","cillum"],"friends":[{"id":0,"name":"Bettie Meyers"},{"id":1,"name":"Knapp Wise"},{"id":2,"name":"Rosanna Bond"}],"greeting":"Hello, Love Hurley! You have 5 unread messages.","favoriteFruit":"apple"},{"id":5,"guid":"4f4b6cdf-2e11-464c-a496-d3020e0981af","isActive":false,"balance":"$2,782.47","picture":"http://placehold.it/32x32","age":31,"eyeColor":"blue","name":"Mayo Murray","gender":"male","company":"CODACT","email":"mayomurray@codact.com","phone":"+1 (943) 478-2468","address":"964 Lott Place, Needmore, Iowa, 854","about":"Magna irure non eiusmod mollit ullamco occaecat cupidatat est eiusmod. Irure ex ea ea aliqua aute veniam proident cillum deserunt. Ipsum aute deserunt et deserunt esse do quis anim occaecat eiusmod nostrud fugiat sit. Aute aute adipisicing labore amet mollit eiusmod non laborum elit ex deserunt incididunt sunt aliqua.\r\n","registered":"2014-04-22T21:45:00 +04:00","latitude":-44.620984,"longitude":112.695424,"tags":["cupidatat","irure","cupidatat","labore","pariatur","ipsum","sit"],"friends":[{"id":0,"name":"Hunter Pace"},{"id":1,"name":"Stevens Simpson"},{"id":2,"name":"Martina Olsen"}],"greeting":"Hello, Mayo Murray! You have 3 unread messages.","favoriteFruit":"strawberry"}] 2 | -------------------------------------------------------------------------------- /doctheme/assets/vendor/prettify/CHANGES.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Change Log 5 | 6 | 7 | README 8 | 9 |

Known Issues

10 | 22 | 23 |

Change Log

24 |

29 March 2007

25 | 56 |

4 Jul 2008

57 | 63 |

5 Jul 2008

64 | 67 |

14 Jul 2008

68 | 76 |

6 Jan 2009

77 | 93 |

21 May 2009

94 | 101 |

14 August 2009

102 | 105 |

3 October 2009

106 | 109 |

19 July 2010

110 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /src/com/cognitect/transit/eq.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | goog.provide("com.cognitect.transit.eq"); 16 | goog.require("com.cognitect.transit.util"); 17 | 18 | goog.scope(function() { 19 | 20 | var eq = com.cognitect.transit.eq, 21 | util = com.cognitect.transit.util; 22 | 23 | /** 24 | * @const 25 | * @type {string} 26 | */ 27 | eq.hashCodeProperty = "transit$hashCode$"; 28 | 29 | /** 30 | * @type {number} 31 | */ 32 | eq.hashCodeCounter = 1; 33 | 34 | eq.equals = function (x, y) { 35 | if(x == null) { 36 | return y == null; 37 | } else if(x === y) { 38 | return true; 39 | } else if(typeof x === "object") { 40 | if(util.isArray(x)) { 41 | if(util.isArray(y)) { 42 | if(x.length === y.length) { 43 | for(var i = 0; i < x.length; i++) { 44 | if(!eq.equals(x[i], y[i])) { 45 | return false; 46 | } 47 | } 48 | return true; 49 | } else { 50 | return false; 51 | } 52 | } else { 53 | return false; 54 | } 55 | } else if(x.com$cognitect$transit$equals) { 56 | return x.com$cognitect$transit$equals(y); 57 | } else if((y != null) && (typeof y === "object")) { 58 | if(y.com$cognitect$transit$equals) { 59 | return y.com$cognitect$transit$equals(x); 60 | } else { 61 | var xklen = 0, 62 | yklen = util.objectKeys(y).length; 63 | for(var p in x) { 64 | if(!x.hasOwnProperty(p)) continue; 65 | xklen++; 66 | if(!y.hasOwnProperty(p)) { 67 | return false; 68 | } else { 69 | if(!eq.equals(x[p], y[p])) { 70 | return false; 71 | } 72 | } 73 | } 74 | return xklen === yklen; 75 | } 76 | } else { 77 | return false; 78 | } 79 | } else { 80 | return false 81 | } 82 | }; 83 | 84 | eq.hashCombine = function(seed, hash) { 85 | return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2)); 86 | }; 87 | 88 | eq.stringCodeCache = {}; 89 | eq.stringCodeCacheSize = 0; 90 | 91 | /** 92 | * @const 93 | * @type {number} 94 | */ 95 | eq.STR_CACHE_MAX = 256; 96 | 97 | eq.hashString = function(str) { 98 | // a la goog.string.HashCode 99 | // http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1206 100 | var cached = eq.stringCodeCache[str]; 101 | if(cached != null) { 102 | return cached; 103 | } 104 | var code = 0; 105 | for (var i = 0; i < str.length; ++i) { 106 | code = 31 * code + str.charCodeAt(i); 107 | code %= 0x100000000; 108 | } 109 | eq.stringCodeCacheSize++; 110 | if(eq.stringCodeCacheSize >= eq.STR_CACHE_MAX) { 111 | eq.stringCodeCache = {}; 112 | eq.stringCodeCacheSize = 1; 113 | } 114 | eq.stringCodeCache[str] = code; 115 | return code; 116 | }; 117 | 118 | eq.hashMapLike = function(m) { 119 | var code = 0; 120 | // ES6 Map-like case 121 | if(m.forEach != null) { 122 | m.forEach(function(val, key, m) { 123 | code = (code + (eq.hashCode(key) ^ eq.hashCode(val))) % 4503599627370496; 124 | }); 125 | } else { 126 | // JS Object case 127 | var keys = util.objectKeys(m); 128 | for(var i = 0; i < keys.length; i++) { 129 | var key = keys[i]; 130 | var val = m[key]; 131 | code = (code + (eq.hashCode(key) ^ eq.hashCode(val))) % 4503599627370496; 132 | } 133 | } 134 | return code; 135 | }; 136 | 137 | eq.hashArrayLike = function(arr) { 138 | var code = 0; 139 | if(util.isArray(arr)) { 140 | for(var i = 0; i < arr.length; i++) { 141 | code = eq.hashCombine(code, eq.hashCode(arr[i])); 142 | } 143 | } else if(arr.forEach) { 144 | arr.forEach(function(x, i) { 145 | code = eq.hashCombine(code, eq.hashCode(x)); 146 | }); 147 | } 148 | return code; 149 | }; 150 | 151 | eq.hashCode = function(x) { 152 | if(x == null) { 153 | return 0; 154 | } else { 155 | switch(typeof x) { 156 | case 'number': 157 | return x; 158 | break; 159 | case 'boolean': 160 | return x === true ? 1 : 0; 161 | break; 162 | case 'string': 163 | return eq.hashString(x); 164 | break; 165 | case 'function': 166 | var code = x[eq.hashCodeProperty]; 167 | if(code) { 168 | return code; 169 | } else { 170 | code = eq.hashCodeCounter; 171 | if(typeof Object.defineProperty != "undefined") { 172 | Object.defineProperty(x, eq.hashCodeProperty, { 173 | value: code, 174 | enumerable: false 175 | }); 176 | } else { 177 | x[eq.hashCodeProperty] = code; 178 | } 179 | eq.hashCodeCounter++; 180 | return code; 181 | } 182 | break; 183 | default: 184 | if(x instanceof Date) { 185 | return x.valueOf(); 186 | } else if(util.isArray(x)) { 187 | return eq.hashArrayLike(x); 188 | } if(x.com$cognitect$transit$hashCode) { 189 | return x.com$cognitect$transit$hashCode(); 190 | } else { 191 | return eq.hashMapLike(x); 192 | } 193 | break; 194 | } 195 | } 196 | } 197 | 198 | eq.extendToEQ = function(obj, opts) { 199 | obj.com$cognitect$transit$hashCode = opts["hashCode"]; 200 | obj.com$cognitect$transit$equals = opts["equals"]; 201 | return obj; 202 | } 203 | 204 | }); 205 | -------------------------------------------------------------------------------- /doctheme/assets/vendor/prettify/README.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Javascript code prettifier 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | Languages : CH 20 |

Javascript code prettifier

21 | 22 |

Setup

23 |
    24 |
  1. Download a distribution 25 |
  2. Include the script and stylesheets in your document 26 | (you will need to make sure the css and js file are on your server, and 27 | adjust the paths in the script and link tag) 28 |
     29 | <link href="prettify.css" type="text/css" rel="stylesheet" />
     30 | <script type="text/javascript" src="prettify.js"></script>
    31 |
  3. Add onload="prettyPrint()" to your 32 | document's body tag. 33 |
  4. Modify the stylesheet to get the coloring you prefer
  5. 34 |
35 | 36 |

Usage

37 |

Put code snippets in 38 | <pre class="prettyprint">...</pre> 39 | or <code class="prettyprint">...</code> 40 | and it will automatically be pretty printed. 41 | 42 | 43 | 44 | 47 |
The original 45 | Prettier 46 |
class Voila {
 49 | public:
 50 |   // Voila
 51 |   static const string VOILA = "Voila";
 52 | 
 53 |   // will not interfere with embedded tags.
 54 | }
55 | 56 |
class Voila {
 57 | public:
 58 |   // Voila
 59 |   static const string VOILA = "Voila";
 60 | 
 61 |   // will not interfere with embedded tags.
 62 | }
63 |
64 | 65 |

FAQ

66 |

Which languages does it work for?

67 |

The comments in prettify.js are authoritative but the lexer 68 | should work on a number of languages including C and friends, 69 | Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. 70 | It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl 71 | and Ruby, but, because of commenting conventions, doesn't work on 72 | Smalltalk, or CAML-like languages.

73 | 74 |

LISPy languages are supported via an extension: 75 | lang-lisp.js.

77 |

And similarly for 78 | CSS, 80 | Haskell, 82 | Lua, 84 | OCAML, SML, F#, 86 | Visual Basic, 88 | SQL, 90 | Protocol Buffers, and 92 | WikiText.. 94 | 95 |

If you'd like to add an extension for your favorite language, please 96 | look at src/lang-lisp.js and file an 97 | issue including your language extension, and a testcase.

99 | 100 |

How do I specify which language my code is in?

101 |

You don't need to specify the language since prettyprint() 102 | will guess. You can specify a language by specifying the language extension 103 | along with the prettyprint class like so:

104 |
<pre class="prettyprint lang-html">
106 |   The lang-* class specifies the language file extensions.
107 |   File extensions supported by default include
108 |     "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
109 |     "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
110 |     "xhtml", "xml", "xsl".
111 | </pre>
112 | 113 |

It doesn't work on <obfuscated code sample>?

114 |

Yes. Prettifying obfuscated code is like putting lipstick on a pig 115 | — i.e. outside the scope of this tool.

116 | 117 |

Which browsers does it work with?

118 |

It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. 119 | Look at the test page to see if it 120 | works in your browser.

121 | 122 |

What's changed?

123 |

See the change log

124 | 125 |

Why doesn't Prettyprinting of strings work on WordPress?

126 |

Apparently wordpress does "smart quoting" which changes close quotes. 127 | This causes end quotes to not match up with open quotes. 128 |

This breaks prettifying as well as copying and pasting of code samples. 129 | See 130 | WordPress's help center for info on how to stop smart quoting of code 132 | snippets.

133 | 134 |

How do I put line numbers in my code?

135 |

You can use the linenums class to turn on line 136 | numbering. If your code doesn't start at line number 1, you can 137 | add a colon and a line number to the end of that class as in 138 | linenums:52. 139 | 140 |

For example 141 |

<pre class="prettyprint linenums:4"
142 | >// This is line 4.
143 | foo();
144 | bar();
145 | baz();
146 | boo();
147 | far();
148 | faz();
149 | <pre>
150 | produces 151 |
// This is line 4.
153 | foo();
154 | bar();
155 | baz();
156 | boo();
157 | far();
158 | faz();
159 | 
160 | 161 |

How do I prevent a portion of markup from being marked as code?

162 |

You can use the nocode class to identify a span of markup 163 | that is not code. 164 |

<pre class=prettyprint>
165 | int x = foo();  /* This is a comment  <span class="nocode">This is not code</span>
166 |   Continuation of comment */
167 | int y = bar();
168 | </pre>
169 | produces 170 |
171 | int x = foo();  /* This is a comment  This is not code
172 |   Continuation of comment */
173 | int y = bar();
174 | 
175 | 176 |

For a more complete example see the issue22 177 | testcase.

178 | 179 |

I get an error message "a is not a function" or "opt_whenDone is not a function"

180 |

If you are calling prettyPrint via an event handler, wrap it in a function. 181 | Instead of doing 182 |

183 | addEventListener('load', prettyPrint, false); 185 |
186 | wrap it in a closure like 187 |
188 | addEventListener('load', function (event) { prettyPrint() }, false); 190 |
191 | so that the browser does not pass an event object to prettyPrint which 192 | will confuse it. 193 | 194 |


195 | 196 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /bench/mapset.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //require("es6-shim"); 16 | var transit = require("../target/transit.js"); 17 | 18 | function sum(a, b) { return a+b; }; 19 | 20 | function time(f, iters) { 21 | iters = iters || 1; 22 | var avg = []; 23 | for(var i = 0; i < iters; i++) { 24 | var s = new Date(); 25 | f(); 26 | var el = (new Date()).valueOf()-s.valueOf(); 27 | if(iters == 1) { 28 | console.log("Elapsed "+el+"ms"); 29 | console.log("----------"); 30 | } else { 31 | avg.push(el); 32 | } 33 | } 34 | if(iters != 1) { 35 | console.log("Average Elapsed "+(avg.reduce(sum)/iters)+"ms"); 36 | console.log("----------"); 37 | } 38 | } 39 | 40 | console.log("Add 8 entries, 1000 iters, string key, es6-shim Map"); 41 | time(function() { 42 | for(var j = 0; j < 10000; j++) { 43 | var m = new Map(); 44 | for(var i = 0; i < 4; i++) { 45 | m.set("foo"+i, i); 46 | } 47 | } 48 | }); 49 | 50 | console.log("Add 8 entries, 1000 iters, string key, transit map"); 51 | time(function() { 52 | for(var j = 0; j < 10000; j++) { 53 | var m = transit.map(); 54 | for(var i = 0; i < 4; i++) { 55 | m.set("foo"+i, i); 56 | } 57 | } 58 | }); 59 | 60 | 61 | console.log("Add 1e4 entries, array key, es6-shim Map"); 62 | time(function() { 63 | var m = new Map(); 64 | for(var i = 0; i < 10000; i++) { 65 | m.set(["foo"+i], i); 66 | } 67 | }); 68 | 69 | console.log("Add 1e4 entries, array key, transit map"); 70 | time(function() { 71 | var m = transit.map(); 72 | for(var i = 0; i < 10000; i++) { 73 | m.set(["foo"+i], i); 74 | } 75 | }); 76 | 77 | var es6m = new Map(), 78 | ks = []; 79 | for(var i = 0; i < 10000; i++) { 80 | var k = ["foo"+i]; 81 | es6m.set(k, i); 82 | ks.push(k); 83 | } 84 | 85 | var tm = transit.map(); 86 | for(var i = 0; i < 10000; i++) { 87 | tm.set(ks[i], i); 88 | } 89 | 90 | console.log("has 1e4 entries es6-shim Map"); 91 | time(function() { 92 | var has = true; 93 | for(var i = 0; i < 10000; i++) { 94 | has = has && es6m.has(ks[i]); 95 | } 96 | console.log(has); 97 | }); 98 | 99 | console.log("has 1e4 entries transit map"); 100 | time(function() { 101 | var has = true; 102 | for(var i = 0; i < 10000; i++) { 103 | has = has && tm.has(ks[i]); 104 | } 105 | console.log(has); 106 | }); 107 | 108 | es6m = new Map(); 109 | for(var i = 0; i < 1000000; i++) { 110 | es6m.set(i, i); 111 | } 112 | 113 | tm = transit.map(); 114 | for(var i = 0; i < 1000000; i++) { 115 | tm.set(i, i); 116 | } 117 | 118 | console.log("forEach 1e6 entries es6-shim Map"); 119 | if(es6m.forEach) { 120 | time(function() { 121 | var s = 0; 122 | es6m.forEach(function(v, k) { 123 | s = s + v; 124 | }); 125 | console.log(s); 126 | }); 127 | } 128 | 129 | console.log("forEach 1e6 entries transit map"); 130 | time(function() { 131 | var s = 0; 132 | tm.forEach(function(v, k) { 133 | s = s + v; 134 | }); 135 | console.log(s); 136 | }); 137 | 138 | var smalles6m = new Map(), 139 | ks = []; 140 | for(var i = 0; i < 32; i++) { 141 | var k = ["foo"+i]; 142 | smalles6m.set(k, i); 143 | ks.push(k); 144 | } 145 | 146 | var smalltm = transit.map(); 147 | for(var i = 0; i < 32; i++) { 148 | smalltm.set(ks[i], i); 149 | } 150 | 151 | console.log("has 32 entries es6-shim Map, 1000000 iters"); 152 | time(function() { 153 | var has = true; 154 | for(var i = 0; i < 1000000; i++) { 155 | has = has && smalles6m.has(ks[i % 32]); 156 | } 157 | console.log(has); 158 | }); 159 | 160 | console.log("has 32 entries transit map, 1000000 iters"); 161 | time(function() { 162 | var has = true; 163 | for(var i = 0; i < 1000000; i++) { 164 | has = has && smalltm.has(ks[i % 32]); 165 | } 166 | console.log(has); 167 | }); 168 | 169 | var o4 = { 170 | "foo0": Math.round(Math.random()), 171 | "foo1": Math.round(Math.random()), 172 | "foo2": Math.round(Math.random()), 173 | "foo3": Math.round(Math.random()) 174 | }; 175 | 176 | var m4 = transit.map( 177 | ["foo0", Math.round(Math.random()), 178 | "foo1", Math.round(Math.random()), 179 | "foo2", Math.round(Math.random()), 180 | "foo3", Math.round(Math.random())] 181 | ); 182 | 183 | console.log("4 entry object random access, 1000000 iters"); 184 | time(function() { 185 | var s = 0; 186 | for(var i = 0; i < 1000000; i++) { 187 | s += o4["foo"+(i % 4)]; 188 | } 189 | }, 10); 190 | 191 | console.log("4 entry transit.map random access, 1000000 iters"); 192 | time(function() { 193 | var s = 0; 194 | for(var i = 0; i < 1000000; i++) { 195 | s += m4.get("foo"+(i % 4)); 196 | } 197 | }, 10); 198 | 199 | var o8 = { 200 | "foo0": Math.round(Math.random()), 201 | "foo1": Math.round(Math.random()), 202 | "foo2": Math.round(Math.random()), 203 | "foo3": Math.round(Math.random()), 204 | "foo4": Math.round(Math.random()), 205 | "foo5": Math.round(Math.random()), 206 | "foo6": Math.round(Math.random()), 207 | "foo7": Math.round(Math.random()) 208 | }; 209 | 210 | var m8 = transit.map( 211 | ["foo0", Math.round(Math.random()), 212 | "foo1", Math.round(Math.random()), 213 | "foo2", Math.round(Math.random()), 214 | "foo3", Math.round(Math.random()), 215 | "foo4", Math.round(Math.random()), 216 | "foo5", Math.round(Math.random()), 217 | "foo6", Math.round(Math.random()), 218 | "foo7", Math.round(Math.random())] 219 | ); 220 | 221 | console.log("8 entry object random access, 1000000 iters"); 222 | time(function() { 223 | var s = 0; 224 | for(var i = 0; i < 1000000; i++) { 225 | s += o8["foo"+(i % 8)]; 226 | } 227 | }, 10); 228 | 229 | console.log("8 entry transit.map random access, 1000000 iters"); 230 | time(function() { 231 | var s = 0; 232 | for(var i = 0; i < 1000000; i++) { 233 | s += m8.get("foo"+(i % 8)); 234 | } 235 | }, 10); 236 | 237 | var r16 = []; 238 | for(var i = 0; i < 1000000; i++) { 239 | r16.push(Math.floor(Math.random()*16)); 240 | } 241 | 242 | var o16 = {}; 243 | for(var i = 0 ; i < 16; i++) { 244 | o16["foo"+i] = Math.round(Math.random()); 245 | } 246 | 247 | var arr16 = []; 248 | for(var i = 0; i < 16; i++) { 249 | arr16.push("foo"+i, Math.round(Math.random())); 250 | } 251 | var m16 = transit.map(arr16, false, false); 252 | 253 | console.log("16 entry object random access, 1000000 iters"); 254 | time(function() { 255 | var s = 0; 256 | for(var i = 0; i < 1000000; i++) { 257 | s += o16["foo"+r16[i]]; 258 | } 259 | }, 10); 260 | 261 | console.log("16 entry transit array map random access, 1000000 iters"); 262 | time(function() { 263 | var s = 0; 264 | for(var i = 0; i < 1000000; i++) { 265 | s += m16.get("foo"+r16[i]); 266 | } 267 | }, 10); 268 | 269 | var r32 = []; 270 | for(var i = 0; i < 1000000; i++) { 271 | r32.push(Math.floor(Math.random()*32)); 272 | } 273 | 274 | var o32 = {}; 275 | for(var i = 0 ; i < 32; i++) { 276 | o32["foo"+i] = Math.round(Math.random()); 277 | } 278 | 279 | var arr32 = []; 280 | for(var i = 0; i < 32; i++) { 281 | arr32.push("foo"+i, Math.round(Math.random())); 282 | } 283 | var m32 = transit.map(arr32, false, false); 284 | 285 | console.log("32 entry object random access, 1000000 iters"); 286 | time(function() { 287 | var s = 0; 288 | for(var i = 0; i < 1000000; i++) { 289 | s += o32["foo"+r32[i]]; 290 | } 291 | }, 10); 292 | 293 | console.log("32 entry transit array map random access, 1000000 iters"); 294 | time(function() { 295 | var s = 0; 296 | for(var i = 0; i < 1000000; i++) { 297 | s += m32.get("foo"+r32[i]); 298 | } 299 | },10); 300 | 301 | var tm16 = transit.map(); 302 | for(var i = 0; i < 16; i++) { 303 | tm16.set("foo"+i, Math.round(Math.random())); 304 | } 305 | 306 | var tm32 = transit.map(); 307 | for(var i = 0; i < 32; i++) { 308 | tm32.set("foo"+i, Math.round(Math.random())); 309 | } 310 | 311 | console.log("16 entry transit hash map random access, 1000000 iters"); 312 | time(function() { 313 | var s = 0; 314 | for(var i = 0; i < 1000000; i++) { 315 | s += tm16.get("foo"+r16[i]); 316 | } 317 | },10); 318 | 319 | console.log("32 entry transit hash map random access, 1000000 iters"); 320 | time(function() { 321 | var s = 0; 322 | for(var i = 0; i < 1000000; i++) { 323 | s += tm32.get("foo"+r32[i]); 324 | } 325 | },10); 326 | -------------------------------------------------------------------------------- /bench/bench.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Cognitect. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS-IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | "use strict"; 16 | 17 | var transit = require("../target/transit.js"); 18 | 19 | function time(f, iters) { 20 | iters = iters || 1; 21 | for(var i = 0; i < iters; i++) { 22 | var s = new Date(); 23 | f(); 24 | console.log("Elapsed "+((new Date()).valueOf()-s.valueOf())+"ms"); 25 | console.log("----------"); 26 | } 27 | } 28 | 29 | console.log("1e6 iters, transit.uuid"); 30 | time(function() { 31 | for(var i = 0; i < 1000000; i++) { 32 | transit.uuid("531a379e-31bb-4ce1-8690-158dceb64be6"); 33 | } 34 | }); 35 | 36 | console.log("1e6 iters, transit.hash(\"foo\")"); 37 | time(function() { 38 | for(var i = 0; i < 1000000; i++) { 39 | transit.hash("foo"); 40 | } 41 | }); 42 | 43 | console.log("1e6 iters, transit.hash([1,2,3])"); 44 | var arr = [1,2,3]; 45 | time(function() { 46 | for(var i = 0; i < 1000000; i++) { 47 | transit.hash(arr); 48 | } 49 | }); 50 | 51 | console.log("1e6 iters, transit.equals(\"foo\", \"foo\")"); 52 | time(function() { 53 | for(var i = 0; i < 1000000; i++) { 54 | transit.equals("foo", "foo"); 55 | } 56 | }); 57 | 58 | console.log("1e6 iters, transit.equals(\"foo\", \"bar\")"); 59 | time(function() { 60 | for(var i = 0; i < 1000000; i++) { 61 | transit.equals("foo", "bar"); 62 | } 63 | }); 64 | 65 | console.log("1e6 iters, transit.equals([1,2,3], [1,2,3])"); 66 | time(function() { 67 | var arr0 = [1,2,3], 68 | arr1 = [1,2,3]; 69 | for(var i = 0; i < 1000000; i++) { 70 | transit.equals(arr0, arr1); 71 | } 72 | }); 73 | 74 | console.log("1e6 iters, transit.equals([1,2,3], [3,2,3])"); 75 | time(function() { 76 | var arr0 = [1,2,3], 77 | arr1 = [3,2,3]; 78 | for(var i = 0; i < 1000000; i++) { 79 | transit.equals(arr0, arr1); 80 | } 81 | }); 82 | 83 | console.log("1e6 iters, transit.equals(transit.keyword(\"foo\"), transit.keyword(\"foo\"))"); 84 | time(function() { 85 | var k0 = transit.keyword("foo"), 86 | k1 = transit.keyword("foo"); 87 | for(var i = 0; i < 1000000; i++) { 88 | transit.equals(k0, k1); 89 | } 90 | }); 91 | 92 | console.log("1e6 iters, transit.equals(transit.date(1399471321791), transit.date(1399471321791))"); 93 | time(function() { 94 | var d0 = transit.date(1399471321791), 95 | d1 = transit.date(1399471321791); 96 | for(var i = 0; i < 1000000; i++) { 97 | transit.equals(d0, d1); 98 | } 99 | }); 100 | 101 | console.log("1e6 iters, transit.equals(transit.keyword(\"foo\"), transit.keyword(\"bar\"))"); 102 | time(function() { 103 | var k0 = transit.keyword("foo"), 104 | k1 = transit.keyword("bar"); 105 | for(var i = 0; i < 1000000; i++) { 106 | transit.equals(k0, k1); 107 | } 108 | }); 109 | 110 | console.log("1e6 iters, transit.equals({foo: \"bar\"}, {foo: \"bar\"})"); 111 | time(function() { 112 | var obj0 = {foo: "bar"}, 113 | obj1 = {foo: "bar"}; 114 | for(var i = 0; i < 1000000; i++) { 115 | transit.equals(obj0, obj1); 116 | } 117 | }); 118 | 119 | console.log("1e6 iters, TransitMap tm0.get(\"foo\")"); 120 | var tm0 = transit.map(["foo", "transit map string lookup"]); 121 | console.log(tm0.get("foo")); 122 | time(function() { 123 | for(var i = 0; i < 1000000; i++) { 124 | tm0.get("foo"); 125 | } 126 | }); 127 | 128 | console.log("1e5 iters, TransitMap tm0.get([1,2])"); 129 | var tm1 = transit.map([[1,2], "transit map array lookup"]); 130 | console.log(tm1.get([1,2])); 131 | time(function() { 132 | var key = [1,2]; 133 | for(var i = 0; i < 100000; i++) { 134 | tm1.get(key); 135 | } 136 | }); 137 | 138 | console.log("1e6 iters, Complex TransitSet \"bar\""); 139 | var ts = transit.set(["foo",1,"bar",[1,2]]) 140 | console.log(ts.has("bar")); 141 | time(function() { 142 | var key = "bar"; 143 | for(var i = 0; i < 1000000; i++) { 144 | ts.has(key); 145 | } 146 | }); 147 | 148 | console.log("1e5 iters, JSON read transit map with two keyword/string value pairs"); 149 | var json = "{\"~:foo\":\"bar\",\"~:baz\":\"woz\"}"; 150 | console.log(JSON.parse(json)); 151 | time(function() { 152 | for(var i = 0; i < 100000; i++) { 153 | JSON.parse(json); 154 | } 155 | }); 156 | 157 | console.log("1e5 iters, top level read, map two keyword/string value pairs"); 158 | json = "{\"~:foo\":\"bar\",\"~:baz\":\"woz\"}"; 159 | var reader = transit.reader("json"); 160 | console.log(reader.read(json)); 161 | time(function() { 162 | for(var i = 0; i < 100000; i++) { 163 | reader.read(json) 164 | } 165 | }); 166 | 167 | console.log("1e5 iters, top level JSON-M read, map with two keyword/string value pairs"); 168 | json = "[\"^ \", \"~:foo\", \"bar\", \"~:baz\", \"woz\"]"; 169 | console.log(reader.read(json)); 170 | time(function() { 171 | for(var i = 0; i < 100000; i++) { 172 | reader.read(json); 173 | } 174 | }); 175 | 176 | console.log("1e5 iters, JSON read transit map with two keyword/number value pairs"); 177 | json = "{\"~:foo\":1,\"~:bar\":2}"; 178 | console.log(JSON.parse(json)); 179 | time(function() { 180 | for(var i = 0; i < 100000; i++) { 181 | JSON.parse(json); 182 | } 183 | }); 184 | 185 | console.log("1e5 iters, top level read, map two keyword/number value pairs"); 186 | reader = transit.reader("json"); 187 | console.log(reader.read(json)); 188 | time(function() { 189 | for(var i = 0; i < 100000; i++) { 190 | reader.read(json); 191 | } 192 | }); 193 | 194 | console.log("1e5 iters, top level read, read keyword"); 195 | var kws = "\"~:foo\""; 196 | reader = transit.reader("json"); 197 | console.log(reader.read(kws)) 198 | time(function() { 199 | for(var i = 0; i < 100000; i++) { 200 | reader.read(kws); 201 | } 202 | }); 203 | 204 | console.log("1e5 iters, JSON.stringify, map two keyword/number value pairs"); 205 | var m = {foo:1,bar:2}; 206 | console.log(JSON.stringify(m)); 207 | time(function() { 208 | for(var i = 0; i < 100000; i++) { 209 | JSON.stringify(m); 210 | } 211 | }); 212 | 213 | console.log("1e5 iters, top level write, map two keyword/number value pairs"); 214 | var writer = transit.writer("json"); 215 | console.log(writer.write(m)); 216 | time(function() { 217 | for(var i = 0; i < 100000; i++) { 218 | writer.write(m); 219 | } 220 | }); 221 | 222 | console.log("1 iter, JSON.stringfy JS object with 100000 kv pairs"); 223 | var largeMap = {}; 224 | for(var i = 0; i < 100000; i++) { 225 | largeMap["foo"+i] = ["bar"+i, i]; 226 | } 227 | time(function() { 228 | JSON.stringify(largeMap); 229 | }); 230 | 231 | console.log("1 iter, transit write large JS object with 100000 kv pairs, complex"); 232 | largeMap = {}, 233 | writer = transit.writer("json"); 234 | for(var i = 0; i < 100000; i++) { 235 | largeMap["~:foo"+i] = [transit.keyword("bar"+i),i]; 236 | } 237 | time(function() { 238 | writer.write(largeMap); 239 | }); 240 | 241 | console.log("1 iter, transit write large JS object with 100000 kv pairs, simple"); 242 | largeMap = {}; 243 | writer = transit.writer("json"); 244 | for(var i = 0; i < 100000; i++) { 245 | largeMap["~:foo"+i] = 1; 246 | } 247 | time(function() { 248 | writer.write(largeMap); 249 | }); 250 | 251 | console.log("1 iter, JSON.parse JS object with 100000 kv pairs"); 252 | arr = []; 253 | for(var i = 0; i < 100000; i++) { 254 | arr.push("\"foo"+i+"\":[\"bar"+i+"\","+i+"]") 255 | } 256 | largeMap = "{"+arr.join(",")+"}", 257 | json = JSON.parse(largeMap); 258 | console.log(Object.keys(json).length); 259 | console.log(json["foo0"]); 260 | time(function() { 261 | JSON.parse(largeMap); 262 | }); 263 | 264 | console.log("1 iter, transit read large transit map with 100000 kv pairs"); 265 | arr = [], 266 | reader = transit.writer("json"); 267 | for(var i = 0; i < 100000; i++) { 268 | arr.push("\"~:foo"+i+"\":[\"~:bar"+i+"\","+i+"]"); 269 | } 270 | largeMap = "{"+arr.join(",")+"}", 271 | reader = transit.reader("json"); 272 | var largeTransitMap = reader.read(largeMap); 273 | console.log(Object.keys(largeTransitMap).length); 274 | console.log(largeTransitMap["`~:foo0"]); 275 | time(function() { 276 | reader.read(largeMap); 277 | }); 278 | 279 | console.log("100 iters, JSON.parse seattle file"); 280 | var fs = require("fs"); 281 | json = fs.readFileSync("../transit/seattle-data0.tjs", "utf-8"); 282 | time(function() { 283 | for(var i = 0; i < 100; i++) { 284 | JSON.parse(json); 285 | } 286 | }); 287 | 288 | console.log("100 iters, transit read seattle file"); 289 | time(function() { 290 | for(var i = 0; i < 100; i++) { 291 | reader.read(json); 292 | } 293 | }); 294 | 295 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # transit-js 2 | 3 | Transit is a data format and a set of libraries for conveying values between 4 | applications written in different languages. This library provides support for 5 | marshalling Transit data to/from JavaScript. transit-js will work with any 6 | [ECMAScript-262 Edition 7 | 3](http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf) 8 | or newer JavaScript implementation provided that a [JSON](http://www.json.org) 9 | module that supplies `parse` and `stringify` methods is present. transit-js does 10 | not currently support encoding to [MessagePack](http://msgpack.org). Unlike the 11 | Java and Clojure implementations it relies on the non-streaming JSON parsing 12 | mechanism of the host JavaScript environment. 13 | 14 | * [Rationale](http://blog.cognitect.com/blog/2014/7/22/transit) 15 | * [Getting Started](https://github.com/cognitect/transit-js/wiki/Getting-Started), Get up and running ASAP 16 | * [API docs](http://cognitect.github.io/transit-js/classes/transit.html) 17 | * [Specification](http://github.com/cognitect/transit-format) 18 | * [Take a tour!](http://cognitect.github.io/transit-tour) 19 | * [FAQ](http://github.com/cognitect/transit-js/wiki/FAQ), for common transit-js specific questions 20 | 21 | This implementation's major.minor version number corresponds to the version of 22 | the Transit specification it supports. 23 | 24 | _NOTE: Transit is intended primarily as a wire protocol for transferring data between applications. If storing Transit data durably, readers and writers are expected to use the same version of Transit and you are responsible for migrating/transforming/re-storing that data when and if the transit format changes._ 25 | 26 | ## Releases and Dependency Information 27 | 28 | * Latest release: 0.8.874 29 | * [All Released Versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.cognitect%22%20AND%20a%3A%22transit-js%22) 30 | 31 | ### JavaScript 32 | 33 | You can include either the 34 | [release](http://cdn.cognitect.com/transit/transit-0.8.874-min.js) (10K gzipped) 35 | or [development](http://cdn.cognitect.com/transit/transit-0.8.874.js) build of 36 | transit-js on your webpage. We also provide [Require.js](http://requirejs.org) 37 | compatible 38 | [release](http://cdn.cognitect.com/transit/transit-0.8.874-amd-min.js) and 39 | [dev](http://cdn.cognitect.com/transit/transit-0.8.874-amd.js) builds. 40 | 41 | ### Node.js 42 | 43 | transit-js is released to [npm](https://www.npmjs.org). Add transit-js to your 44 | `package.json` dependencies: 45 | 46 | ```javascript 47 | {... 48 | "dependencies": { 49 | "transit-js": "0.8.874" 50 | } 51 | ...} 52 | ``` 53 | 54 | ### Bower 55 | 56 | You can also include transit-js in your `bower.json` dependencies: 57 | 58 | ```javascript 59 | {... 60 | "dependencies": { 61 | "transit-js": "0.8.874" 62 | } 63 | ...} 64 | ``` 65 | 66 | ### Maven 67 | 68 | [Maven](http://maven.apache.org/) dependency information: 69 | 70 | ```xml 71 | 72 | com.cognitect 73 | transit-js 74 | 0.8.874 75 | 76 | ``` 77 | 78 | ## Documentation 79 | 80 | Comprehensive documentation can be found [here](http://cognitect.github.io/transit-js/classes/transit.html). 81 | 82 | ## Overview 83 | 84 | transit-js supports the conveyance of semantically rich and extensible 85 | data between heterogenous software systems whose components include 86 | JavaScript servers and clients. 87 | 88 | #### Beyond JSON 89 | 90 | The [Transit rationale](http://blog.cognitect.com/blog/2014/7/22/transit) covers 91 | many of the reasons to put aside the limitations of JSON. As with the other 92 | Transit implementations, transit-js supports conveying a larger range of scalar 93 | and non-scalar values than permitted by JSON. Of these types, the transit-js 94 | handling of the map representation is the most novel from the perspective of a 95 | JavaScript applications developer. 96 | 97 | #### Transit Maps 98 | 99 | Transit representations of maps are decoded by transit-js into a high 100 | performance data structure that largely mirrors the [ECMAScript Edition 101 | 6](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) 102 | [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) 103 | data type. Doing so allows natural indexing of data using common scalars like 64 104 | bit integers and dates without requiring the out of band application logic often 105 | encountered in systems that marshal JSON. 106 | 107 | The adaptive implementation of transit-js maps delivers performance comparable 108 | to plain JavaScript objects and native ES6 Map implementations. 109 | 110 | ## Usage 111 | 112 | Please see the [Getting 113 | Started](https://github.com/cognitect/transit-js/wiki/Getting-Started) page. For 114 | an interactive guide check out the 115 | [tour](http://cognitect.github.io/transit-tour). 116 | 117 | From the browser transit-js is available at the top level: 118 | 119 | ```javascript 120 | var t = transit; 121 | 122 | function roundtrip(x) { 123 | var r = t.reader("json"), 124 | w = t.writer("json"); 125 | return r.read(w.write(x)); 126 | } 127 | 128 | function testRoundtrip() { 129 | var arr1 = ["red", "green", "blue"], 130 | arr2 = ["apple", "pear", "grape"], 131 | data = t.map(); 132 | data.set(t.integer(1), arr1); 133 | data.set(t.integer(2), arr2); 134 | return t.equals(data, roundtrip(data)); 135 | } 136 | ``` 137 | 138 | From Node.js you must require transit-js (assuming you've 139 | included it in your project dependencies): 140 | 141 | ```javascript 142 | var t = require("transit-js"); 143 | 144 | function roundtrip(x) { 145 | var r = t.reader("json"), 146 | w = t.writer("json"); 147 | return r.read(w.write(x)); 148 | } 149 | 150 | function testRoundtrip() { 151 | var arr1 = ["red", "green", "blue"], 152 | arr2 = ["apple", "pear", "grape"], 153 | data = t.map(); 154 | data.set(t.integer(1), arr1); 155 | data.set(t.integer(2), arr2); 156 | return t.equals(data, roundtrip(data)); 157 | } 158 | ``` 159 | 160 | ## Default Type Mapping 161 | 162 | Abbreviations: 163 | * t = transit 164 | 165 | |Transit type|Write accepts|Read returns| 166 | |------------|-------------|------------| 167 | |null|null|null| 168 | |string|String|String| 169 | |boolean|Boolean|Boolean| 170 | |integer|Number, t.integer|Number, t.integer| 171 | |decimal|Number|Number| 172 | |keyword|t.keyword|t.keyword| 173 | |symbol|t.symbol|t.symbol| 174 | |big integer|t.tagged|t.tagged| 175 | |big decimal|t.tagged|t.tagged| 176 | |bytes|Buffer, Uint8Array, t.tagged|Buffer, Uint8Array, t.tagged| 177 | |time|Date|Date| 178 | |uri|t.tagged|t.tagged| 179 | |uuid|t.uuid|t.uuid| 180 | |char|String|String| 181 | |array|Array|Array| 182 | |list|t.tagged|t.tagged| 183 | |set|t.set|t.set| 184 | |map|t.map|t.map| 185 | |link|t.tagged|t.tagged| 186 | |cmap|t.map|t.map| 187 | 188 | ## Contributing 189 | 190 | This library is open source, developed internally by Cognitect. We welcome 191 | discussions of potential problems and enhancement suggestions on the 192 | [transit-format mailing 193 | list](https://groups.google.com/forum/#!forum/transit-format). Issues can be 194 | filed using GitHub [issues](https://github.com/cognitect/transit-js/issues) for 195 | this project. Because transit is incorporated into products and client projects, 196 | we prefer to do development internally and are not accepting pull requests or 197 | patches. 198 | 199 | ## Development 200 | 201 | ### Dependencies 202 | 203 | Building and testing transit-js requires 204 | [Node.js](http://nodejs.org). Install the project's additional 205 | development dependencies with the following command from the repo 206 | directory: 207 | 208 | ``` 209 | bin/deps 210 | ``` 211 | 212 | In order to build transit-js for 213 | [ClojureScript](http://github.com/clojure/clojurescript), 214 | [Maven](http://maven.apache.org) must be installed. 215 | 216 | ### Running the tests 217 | 218 | ``` 219 | bin/test 220 | ``` 221 | 222 | In order to run the `bin/verify` tests from 223 | [transit-format](https://github.com/cognitect/transit-format), you must first 224 | clone transit-format into the same parent directory as your transit-js checkout. 225 | Then build the production Node.js build: 226 | 227 | ``` 228 | bin/build_release_node 229 | ``` 230 | 231 | ### Build 232 | 233 | #### Version 234 | 235 | The build version is automatically incremented. To determine the current build 236 | version: 237 | 238 | ``` 239 | build/revision 240 | ``` 241 | 242 | #### Build for Node.js 243 | 244 | ``` 245 | bin/build_release_node 246 | ``` 247 | 248 | #### Build for Browser 249 | 250 | ``` 251 | bin/build_release_browser 252 | ``` 253 | 254 | #### Building the documentation 255 | 256 | ``` 257 | bin/docs 258 | ``` 259 | 260 | #### Build JAR for ClojureScript 261 | 262 | Assuming you have a 263 | [JDK](http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-sdk-6u3-jdk-7u1-downloads-523391.html) 264 | and [Maven](http://maven.apache.org) installed, the following will install a JAR 265 | suitable for use from ClojureScript into your local Maven repository. 266 | 267 | ``` 268 | build/package_local 269 | ``` 270 | 271 | ## Copyright and License 272 | 273 | Copyright © 2014-2020 Cognitect 274 | 275 | Licensed under the Apache License, Version 2.0 (the "License"); 276 | you may not use this file except in compliance with the License. 277 | You may obtain a copy of the License at 278 | 279 | http://www.apache.org/licenses/LICENSE-2.0 280 | 281 | Unless required by applicable law or agreed to in writing, software 282 | distributed under the License is distributed on an "AS IS" BASIS, 283 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 284 | See the License for the specific language governing permissions and 285 | limitations under the License. 286 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /doctheme/assets/vendor/prettify/COPYING: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /doctheme/assets/css/main.css: -------------------------------------------------------------------------------- 1 | /* 2 | Font sizes for all selectors other than the body are given in percentages, 3 | with 100% equal to 13px. To calculate a font size percentage, multiply the 4 | desired size in pixels by 7.6923076923. 5 | 6 | Here's a quick lookup table: 7 | 8 | 10px - 76.923% 9 | 11px - 84.615% 10 | 12px - 92.308% 11 | 13px - 100% 12 | 14px - 107.692% 13 | 15px - 115.385% 14 | 16px - 123.077% 15 | 17px - 130.769% 16 | 18px - 138.462% 17 | 19px - 146.154% 18 | 20px - 153.846% 19 | */ 20 | 21 | html { 22 | background: #fff; 23 | color: #333; 24 | overflow-y: scroll; 25 | } 26 | 27 | body { 28 | font: 13px/1.4 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Bitstream Vera Sans', 'Helvetica', 'Arial', sans-serif; 29 | margin: 0; 30 | padding: 0; 31 | } 32 | 33 | /* -- Links ----------------------------------------------------------------- */ 34 | a { 35 | color: #356de4; 36 | text-decoration: none; 37 | } 38 | 39 | a:hover { text-decoration: underline; } 40 | 41 | /* "Jump to Table of Contents" link is shown to assistive tools, but hidden from 42 | sight until it's focused. */ 43 | .jump { 44 | position: absolute; 45 | padding: 3px 6px; 46 | left: -99999px; 47 | top: 0; 48 | } 49 | 50 | .jump:focus { left: 40%; } 51 | 52 | /* -- Paragraphs ------------------------------------------------------------ */ 53 | p { margin: 1.3em 0; } 54 | dd p, td p { margin-bottom: 0; } 55 | dd p:first-child, td p:first-child { margin-top: 0; } 56 | 57 | /* -- Headings -------------------------------------------------------------- */ 58 | h1, h2, h3, h4, h5, h6 { 59 | color: #D98527;/*was #f80*/ 60 | font-family: 'Trebuchet MS', sans-serif; 61 | font-weight: bold; 62 | line-height: 1.1; 63 | margin: 1.1em 0 0.5em; 64 | } 65 | 66 | h1 { 67 | font-size: 184.6%; 68 | color: #30418C; 69 | margin: 0.75em 0 0.5em; 70 | } 71 | 72 | h2 { 73 | font-size: 153.846%; 74 | color: #E48A2B; 75 | } 76 | 77 | h3 { font-size: 138.462%; } 78 | 79 | h4 { 80 | border-bottom: 1px solid #DBDFEA; 81 | color: #E48A2B; 82 | font-size: 115.385%; 83 | font-weight: normal; 84 | padding-bottom: 2px; 85 | } 86 | 87 | h5, h6 { font-size: 107.692%; } 88 | 89 | /* -- Code and examples ----------------------------------------------------- */ 90 | code, kbd, pre, samp { 91 | font-family: Menlo, Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; 92 | font-size: 92.308%; 93 | line-height: 1.35; 94 | } 95 | 96 | p code, p kbd, p samp, li code { 97 | background: #FCFBFA; 98 | border: 1px solid #EFEEED; 99 | padding: 0 3px; 100 | } 101 | 102 | a code, a kbd, a samp, 103 | pre code, pre kbd, pre samp, 104 | table code, table kbd, table samp, 105 | .intro code, .intro kbd, .intro samp, 106 | .toc code, .toc kbd, .toc samp { 107 | background: none; 108 | border: none; 109 | padding: 0; 110 | } 111 | 112 | pre.code, pre.terminal, pre.cmd { 113 | overflow-x: auto; 114 | *overflow-x: scroll; 115 | padding: 0.3em 0.6em; 116 | } 117 | 118 | pre.code { 119 | background: #FCFBFA; 120 | border: 1px solid #EFEEED; 121 | border-left-width: 5px; 122 | } 123 | 124 | pre.terminal, pre.cmd { 125 | background: #F0EFFC; 126 | border: 1px solid #D0CBFB; 127 | border-left: 5px solid #D0CBFB; 128 | } 129 | 130 | /* Don't reduce the font size of // elements inside
131 |    blocks. */
132 | pre code, pre kbd, pre samp { font-size: 100%; }
133 | 
134 | /* Used to denote text that shouldn't be selectable, such as line numbers or
135 |    shell prompts. Guess which browser this doesn't work in. */
136 | .noselect {
137 |     -moz-user-select: -moz-none;
138 |     -khtml-user-select: none;
139 |     -webkit-user-select: none;
140 |     -o-user-select: none;
141 |     user-select: none;
142 | }
143 | 
144 | /* -- Lists ----------------------------------------------------------------- */
145 | dd { margin: 0.2em 0 0.7em 1em; }
146 | dl { margin: 1em 0; }
147 | dt { font-weight: bold; }
148 | 
149 | /* -- Tables ---------------------------------------------------------------- */
150 | caption, th { text-align: left; }
151 | 
152 | table {
153 |     border-collapse: collapse;
154 |     width: 100%;
155 | }
156 | 
157 | td, th {
158 |     border: 1px solid #fff;
159 |     padding: 5px 12px;
160 |     vertical-align: top;
161 | }
162 | 
163 | td { background: #E6E9F5; }
164 | td dl { margin: 0; }
165 | td dl dl { margin: 1em 0; }
166 | td pre:first-child { margin-top: 0; }
167 | 
168 | th {
169 |     background: #D2D7E6;/*#97A0BF*/
170 |     border-bottom: none;
171 |     border-top: none;
172 |     color: #000;/*#FFF1D5*/
173 |     font-family: 'Trebuchet MS', sans-serif;
174 |     font-weight: bold;
175 |     line-height: 1.3;
176 |     white-space: nowrap;
177 | }
178 | 
179 | 
180 | /* -- Layout and Content ---------------------------------------------------- */
181 | #doc {
182 |     margin: auto;
183 |     min-width: 1024px;
184 | }
185 | 
186 | #main { width: 754px; }
187 | #sidebar { width: 270px; margin: 0 15px; }
188 | 
189 | .content { padding: 0 20px 0 25px; }
190 | 
191 | /* -- Sidebar --------------------------------------------------------------- */
192 | .sidebox {
193 |     background: #F9F9FC;/*E6E9F5*/
194 |     border: 1px solid #D4D8EB;
195 | 
196 |     -moz-border-radius: 4px;
197 |     -webkit-border-radius: 4px;
198 |     border-radius: 4px;
199 |     -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
200 |     -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
201 |     box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
202 |     font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Helvetica', 'Arial', sans-serif;
203 |     margin: 0 0 15px 0;
204 |     padding-bottom: 1px;
205 | }
206 | 
207 | .sidebox h2 {
208 |     background: #E5E6F1;
209 |     -moz-border-radius: 4px 4px 0 0;
210 |     -webkit-border-radius: 4px 4px 0 0;
211 |     border-radius: 4px 4px 0 0;
212 |     color: #5E6BA4;
213 |     font-weight: bold;
214 |     font-size: 107.692%;
215 |     margin: 0;
216 |     padding: 4px 7px 5px;
217 | }
218 | 
219 | .sidebox .bd {
220 |     font-size: 84.615%;
221 |     padding: 0 5px 0 8px;
222 | }
223 | 
224 | .sidebox li { list-style-type: disc; color:#D4D5E3; }
225 | 
226 | .sidebox ol, .sidebox ul {
227 |     margin-left: 0;
228 |     padding-left: 16px;
229 | }
230 | 
231 | .sidebox ol ol, .sidebox ol ul,
232 | .sidebox ul ol, .sidebox ul ul {
233 |     margin: 0;
234 |     padding-left: 16px;
235 | }
236 | 
237 | /* -- Table of Contents ----------------------------------------------------- */
238 | 
239 | /* The #toc id refers to the single global table of contents, while the .toc
240 |    class refers to generic TOC lists that could be used throughout the page. */
241 | 
242 | .toc code, .toc kbd, .toc samp { font-size: 100%; }
243 | .toc li { font-weight: bold; }
244 | .toc li li { font-weight: normal; }
245 | 
246 | /* -- Intro and Example Boxes ----------------------------------------------- */
247 | .intro, .example { margin-bottom: 2em; }
248 | 
249 | .example {
250 |     -moz-border-radius: 4px;
251 |     -webkit-border-radius: 4px;
252 |     border-radius: 4px;
253 |     -moz-box-shadow: 0 0 5px #bfbfbf;
254 |     -webkit-box-shadow: 0 0 5px #bfbfbf;
255 |     box-shadow: 0 0 5px #bfbfbf;
256 |     padding: 1em;
257 | }
258 | 
259 | .intro {
260 |     background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
261 | }
262 | 
263 | /* -- Other Styles ---------------------------------------------------------- */
264 | 
265 | /* These are probably YUI-specific, and should be moved out of Selleck's default
266 |    theme. */
267 | 
268 | .button {
269 |     border: 1px solid #dadada;
270 |     -moz-border-radius: 3px;
271 |     -webkit-border-radius: 3px;
272 |     border-radius: 3px;
273 |     color: #444;
274 |     display: inline-block;
275 |     font-family: Helvetica, Arial, sans-serif;
276 |     font-size: 92.308%;
277 |     font-weight: bold;
278 |     padding: 4px 13px 3px;
279 |     -moz-text-shadow: 1px 1px 0 #fff;
280 |     -webkit-text-shadow: 1px 1px 0 #fff;
281 |     text-shadow: 1px 1px 0 #fff;
282 |     white-space: nowrap;
283 | 
284 |     background: #EFEFEF; /* old browsers */
285 |     background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
286 |     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
287 |     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
288 | }
289 | 
290 | .button:hover {
291 |     border-color: #466899;
292 |     color: #fff;
293 |     text-decoration: none;
294 |     -moz-text-shadow: 1px 1px 0 #222;
295 |     -webkit-text-shadow: 1px 1px 0 #222;
296 |     text-shadow: 1px 1px 0 #222;
297 | 
298 |     background: #6396D8; /* old browsers */
299 |     background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
300 |     background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
301 |     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
302 | }
303 | 
304 | .newwindow { text-align: center; }
305 | 
306 | .header .version em {
307 |     display: block;
308 |     text-align: right;
309 | }
310 | 
311 | .yui3-skin-sam #classdocs .yui3-tabview-panel {
312 |     background-color: transparent;
313 | }
314 | 
315 | .yui3-skin-sam #classdocs .yui3-tabview-panel {
316 |     border: none;
317 | }
318 | 
319 | .yui3-skin-sam .yui3-tabview .yui3-tab,
320 | .yui3-skin-sam .yui3-tabview .yui3-tab-selected,
321 | .yui3-skin-sam .yui3-tabview .yui3-tab-hover {
322 |     background: -moz-linear-gradient(center top , #F4F0EC 0%, #D6D2CE 100%) repeat scroll 0 0 transparent;
323 |     border-bottom: 1px solid #DEDCD9;
324 |     border-right: 1px solid #CDCBC8;
325 |     border-left: 1px solid #CDCBC8;
326 |     border-top: 1px solid #DADADA;
327 |     color: #333333;
328 |     text-decoration: none;
329 | }
330 | .yui3-skin-sam .yui3-tabview .yui3-tab-label,
331 | .yui3-skin-sam .yui3-tabview .yui3-tab-selected .yui3-tab-label {
332 |     border: none;
333 |     background: none;
334 |     font-size: 100%;
335 |     color: #000;
336 | }
337 | 
338 | .yui3-skin-sam .yui3-tabview .yui3-tab-selected,
339 | .yui3-skin-sam .yui3-tabview .yui3-tab-hover {
340 |     background: none;
341 |     background-color: #fff;
342 |     border-bottom-color: #FFFFFF;
343 |     border-top: 2px solid #8193C9;
344 |     font-weight: bold;
345 |     color: #000;
346 | 
347 | }
348 | 
349 | .yui3-skin-sam .yui3-tabview-list {
350 |     border-color: #DFDFDF;
351 |     border-width: 0 0 1px; 
352 | }
353 | 
354 | 
355 | a.external {
356 |     background-image: url(external-small.png);
357 |     background-repeat: no-repeat;
358 |     background-position: 0 0;
359 |     padding-left: 16px;
360 | }
361 | 
362 | #classdocs .item {
363 |     border-bottom: 1px solid #466899;
364 |     margin: 1em 0;
365 |     padding: 1.5em;
366 | }
367 | 
368 | #classdocs .item .params p,
369 |     #classdocs .item .returns p,{
370 |     display: inline;
371 | }
372 | 
373 | #classdocs .item em code, #classdocs .item em.comment {
374 |     color: green;
375 | }
376 | 
377 | #classdocs .item em.comment a {
378 |     color: green;
379 |     text-decoration: underline;
380 | }
381 | 
382 | #classdocs .foundat {
383 |     font-size: 11px;
384 |     font-style: normal;
385 | }
386 | 
387 | .attrs .emits {
388 |     margin-left: 2em;
389 |     padding: .5em;
390 |     border-left: 1px dashed #ccc;
391 | }
392 | 
393 | abbr {
394 |     border-bottom: 1px dashed #ccc;
395 |     font-size: 80%;
396 |     cursor: help;
397 | }
398 | 
399 | .prettyprint li.L0, 
400 | .prettyprint li.L1, 
401 | .prettyprint li.L2, 
402 | .prettyprint li.L3, 
403 | .prettyprint li.L5, 
404 | .prettyprint li.L6, 
405 | .prettyprint li.L7, 
406 | .prettyprint li.L8 {
407 |     list-style: decimal;
408 | }
409 | 
410 | ul li p {
411 |     margin-top: 0;
412 | }
413 | 
414 | .method .name {
415 |     font-size: 110%;
416 | }
417 | 
418 | #hd {
419 |     background: -moz-linear-gradient(center top , #DCDBD9 0%, #F6F5F3 100%) repeat scroll 0 0 transparent;
420 |     border-bottom: 1px solid #DFDFDF;
421 |     padding: 0 15px 1px 20px;
422 |     margin-bottom: 15px;
423 | }
424 | 
425 | #hd img {
426 |     margin-right: 10px;
427 |     vertical-align: middle;
428 | }
429 | 
430 | 


--------------------------------------------------------------------------------
/src/com/cognitect/transit/impl/decoder.js:
--------------------------------------------------------------------------------
  1 | // Copyright 2014 Cognitect. All Rights Reserved.
  2 | //
  3 | // Licensed under the Apache License, Version 2.0 (the "License");
  4 | // you may not use this file except in compliance with the License.
  5 | // You may obtain a copy of the License at
  6 | //
  7 | //      http://www.apache.org/licenses/LICENSE-2.0
  8 | //
  9 | // Unless required by applicable law or agreed to in writing, software
 10 | // distributed under the License is distributed on an "AS-IS" BASIS,
 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 | // See the License for the specific language governing permissions and
 13 | // limitations under the License.
 14 | 
 15 | goog.provide("com.cognitect.transit.impl.decoder");
 16 | goog.require("com.cognitect.transit.util");
 17 | goog.require("com.cognitect.transit.delimiters");
 18 | goog.require("com.cognitect.transit.caching");
 19 | goog.require("com.cognitect.transit.types");
 20 | 
 21 | goog.scope(function () {
 22 | 
 23 |     var decoder = com.cognitect.transit.impl.decoder,
 24 |         util    = com.cognitect.transit.util,
 25 |         d       = com.cognitect.transit.delimiters,
 26 |         caching = com.cognitect.transit.caching,
 27 |         types   = com.cognitect.transit.types;
 28 | 
 29 |     // =========================================================================
 30 |     // Decoder
 31 | 
 32 |     /**
 33 |      * @constructor
 34 |      */
 35 |     decoder.Tag = function Transit$Tag(s) {
 36 |         this.str = s;
 37 |     };
 38 | 
 39 |     decoder.tag = function (s) {
 40 |         return new decoder.Tag(s);
 41 |     };
 42 | 
 43 |     decoder.isTag = function (x) {
 44 |         return x && (x instanceof decoder.Tag);
 45 |     };
 46 | 
 47 |     decoder.isGroundHandler = function (handler) {
 48 |         switch (handler) {
 49 |             case "_":
 50 |             case "s":
 51 |             case "?":
 52 |             case "i":
 53 |             case "d":
 54 |             case "b":
 55 |             case "'":
 56 |             case "array":
 57 |             case "map":
 58 |                 return true;
 59 |         }
 60 |         return false;
 61 |     };
 62 | 
 63 |     /**
 64 |      * A transit decoder
 65 |      * @constructor
 66 |      */
 67 |     decoder.Decoder = function Transit$Decoder(options) {
 68 |         this.options = options || {};
 69 |         this.handlers = {};
 70 |         for (var h in this.defaults.handlers) {
 71 |             this.handlers[h] = this.defaults.handlers[h];
 72 |         }
 73 |         for (var h in this.options["handlers"]) {
 74 |             if (decoder.isGroundHandler(h)) {
 75 |                 throw new Error("Cannot override handler for ground type \"" + h + "\"");
 76 |             }
 77 |             this.handlers[h] = this.options["handlers"][h];
 78 |         }
 79 |         this.preferStrings = this.options["preferStrings"] != null ? this.options["preferStrings"] : this.defaults.preferStrings;
 80 |         this.preferBuffers = this.options["preferBuffers"] != null ? this.options["preferBuffers"] : this.defaults.preferBuffers;
 81 |         this.defaultHandler = this.options["defaultHandler"] || this.defaults.defaultHandler;
 82 |         /* NOT PUBLIC */
 83 |         this.mapBuilder = this.options["mapBuilder"];
 84 |         this.arrayBuilder = this.options["arrayBuilder"];
 85 |     };
 86 | 
 87 | 
 88 |     decoder.Decoder.prototype.defaults = {
 89 |         handlers: {
 90 |             "_": function (v, d) {
 91 |                 return types.nullValue();
 92 |             },
 93 |             "?": function (v, d) {
 94 |                 return types.boolValue(v);
 95 |             },
 96 |             "b": function (v, d) {
 97 |                 return types.binary(v, d);
 98 |             },
 99 |             "i": function (v, d) {
100 |                 return types.intValue(v);
101 |             },
102 |             "n": function (v, d) {
103 |                 return types.bigInteger(v);
104 |             },
105 |             "d": function (v, d) {
106 |                 return types.floatValue(v);
107 |             },
108 |             "f": function (v, d) {
109 |                 return types.bigDecimalValue(v);
110 |             },
111 |             "c": function (v, d) {
112 |                 return types.charValue(v);
113 |             },
114 |             ":": function (v, d) {
115 |                 return types.keyword(v);
116 |             },
117 |             "$": function (v, d) {
118 |                 return types.symbol(v);
119 |             },
120 |             "r": function (v, d) {
121 |                 return types.uri(v);
122 |             },
123 |             "z": function (v, d) {
124 |                 return types.specialDouble(v);
125 |             },
126 | 
127 |             // tagged
128 |             "'": function (v, d) {
129 |                 return v;
130 |             },
131 |             "m": function (v, d) {
132 |                 return types.date(v);
133 |             },
134 |             "t": function (v, d) {
135 |                 return types.verboseDate(v);
136 |             },
137 |             "u": function (v, d) {
138 |                 return types.uuid(v);
139 |             },
140 |             "set": function (v, d) {
141 |                 return types.set(v);
142 |             },
143 |             "list": function (v, d) {
144 |                 return types.list(v);
145 |             },
146 |             "link": function (v, d) {
147 |                 return types.link(v);
148 |             },
149 |             "cmap": function (v, d) {
150 |                 return types.map(v, false);
151 |             }
152 |         },
153 |         defaultHandler: function (c, val) {
154 |             return types.taggedValue(c, val);
155 |         },
156 |         preferStrings: true,
157 |         preferBuffers: true
158 |     };
159 | 
160 |     /**
161 |      * @param {*} node
162 |      * @param {*} cache
163 |      * @param {boolean=} asMapKey
164 |      * @param {boolean=} tagValue
165 |      * @returns {*}
166 |      */
167 |     decoder.Decoder.prototype.decode = function (node, cache, asMapKey, tagValue) {
168 |         if (node == null) return null;
169 | 
170 |         var t = typeof node;
171 | 
172 |         switch (t) {
173 |             case "string":
174 |                 return this.decodeString(node, cache, asMapKey, tagValue);
175 |                 break;
176 |             case "object":
177 |                 if (util.isArray(node)) {
178 |                     if (node[0] === "^ ") {
179 |                         return this.decodeArrayHash(node, cache, asMapKey, tagValue);
180 |                     } else {
181 |                         return this.decodeArray(node, cache, asMapKey, tagValue);
182 |                     }
183 |                 } else {
184 |                     return this.decodeHash(node, cache, asMapKey, tagValue);
185 |                 }
186 |                 break;
187 |         }
188 | 
189 |         return node;
190 |     };
191 |     decoder.Decoder.prototype["decode"] = decoder.Decoder.prototype.decode;
192 | 
193 |     decoder.Decoder.prototype.decodeString = function (string, cache, asMapKey, tagValue) {
194 |         if (caching.isCacheable(string, asMapKey)) {
195 |             var val = this.parseString(string, cache, false);
196 |             if (cache) {
197 |                 cache.write(val, asMapKey);
198 |             }
199 |             return val;
200 |         } else if (caching.isCacheCode(string)) {
201 |             return cache.read(string, asMapKey);
202 |         } else {
203 |             return this.parseString(string, cache, asMapKey);
204 |         }
205 |     };
206 | 
207 |     decoder.Decoder.prototype.decodeHash = function (hash, cache, asMapKey, tagValue) {
208 |         var ks = util.objectKeys(hash),
209 |             key = ks[0],
210 |             tag = ks.length == 1 ? this.decode(key, cache, false, false) : null;
211 | 
212 |         if (decoder.isTag(tag)) {
213 |             var val = hash[key],
214 |                 handler = this.handlers[tag.str];
215 |             if (handler != null) {
216 |                 return handler(this.decode(val, cache, false, true), this);
217 |             } else {
218 |                 return types.taggedValue(tag.str, this.decode(val, cache, false, false));
219 |             }
220 |         } else if (this.mapBuilder) {
221 |             if ((ks.length < (types.SMALL_ARRAY_MAP_THRESHOLD * 2)) && this.mapBuilder.fromArray) {
222 |                 var nodep = [];
223 |                 for (var i = 0; i < ks.length; i++) {
224 |                     var strKey = ks[i];
225 |                     nodep.push(this.decode(strKey, cache, true, false));
226 |                     nodep.push(this.decode(hash[strKey], cache, false, false));
227 |                 }
228 |                 return this.mapBuilder.fromArray(nodep, hash);
229 |             } else {
230 |                 var ret = this.mapBuilder.init(hash);
231 |                 for (var i = 0; i < ks.length; i++) {
232 |                     var strKey = ks[i];
233 |                     ret = this.mapBuilder.add(ret,
234 |                         this.decode(strKey, cache, true, false),
235 |                         this.decode(hash[strKey], cache, false, false),
236 |                         hash);
237 |                 }
238 |                 return this.mapBuilder.finalize(ret, hash);
239 |             }
240 |         } else {
241 |             var nodep = [];
242 | 
243 |             for (var i = 0; i < ks.length; i++) {
244 |                 var strKey = ks[i];
245 |                 nodep.push(this.decode(strKey, cache, true, false));
246 |                 nodep.push(this.decode(hash[strKey], cache, false, false));
247 |             }
248 | 
249 |             return types.map(nodep, false);
250 |         }
251 |     };
252 | 
253 |     decoder.Decoder.prototype.decodeArrayHash = function (node, cache, asMapKey, tagValue) {
254 |         if (this.mapBuilder) {
255 |             if ((node.length < ((types.SMALL_ARRAY_MAP_THRESHOLD * 2) + 1)) && this.mapBuilder.fromArray) {
256 |                 var nodep = [];
257 |                 for (var i = 1; i < node.length; i += 2) {
258 |                     nodep.push(this.decode(node[i], cache, true, false));
259 |                     nodep.push(this.decode(node[i + 1], cache, false, false));
260 |                 }
261 |                 return this.mapBuilder.fromArray(nodep, node);
262 |             } else {
263 |                 var ret = this.mapBuilder.init(node);
264 |                 for (var i = 1; i < node.length; i += 2) {
265 |                     ret = this.mapBuilder.add(ret,
266 |                         this.decode(node[i], cache, true, false),
267 |                         this.decode(node[i + 1], cache, false, false),
268 |                         node)
269 |                 }
270 |                 return this.mapBuilder.finalize(ret, node);
271 |             }
272 |         } else {
273 |             var nodep = [];
274 | 
275 |             // collect keys
276 |             for (var i = 1; i < node.length; i += 2) {
277 |                 nodep.push(this.decode(node[i], cache, true, false));
278 |                 nodep.push(this.decode(node[i + 1], cache, false, false));
279 |             }
280 | 
281 |             return types.map(nodep, false);
282 |         }
283 |     };
284 | 
285 |     decoder.Decoder.prototype.decodeArray = function (node, cache, asMapKey, tagValue) {
286 |         if (tagValue) {
287 |             var ret = [];
288 |             for (var i = 0; i < node.length; i++) {
289 |                 ret.push(this.decode(node[i], cache, asMapKey, false));
290 |             }
291 |             return ret;
292 |         } else {
293 |             var cacheIdx = cache && cache.idx;
294 |             // tagged value as 2-array case
295 |             if ((node.length === 2) &&
296 |                 (typeof node[0] === "string")) {
297 |                 var tag = this.decode(node[0], cache, false, false);
298 |                 if (decoder.isTag(tag)) {
299 |                     var val = node[1],
300 |                         handler = this.handlers[tag.str];
301 |                     if (handler != null) {
302 |                         var ret = handler(this.decode(val, cache, asMapKey, true), this);
303 |                         return ret;
304 |                     } else {
305 |                         return types.taggedValue(tag.str, this.decode(val, cache, asMapKey, false))
306 |                     }
307 |                 }
308 |             }
309 | 
310 |             // rewind cache
311 |             if (cache && (cacheIdx != cache.idx)) {
312 |                 cache.idx = cacheIdx;
313 |             }
314 | 
315 |             if (this.arrayBuilder) {
316 |                 // NOTE: hard coded for ClojureScript for now - David
317 |                 if (node.length <= 32 && this.arrayBuilder.fromArray) {
318 |                     var arr = [];
319 |                     for (var i = 0; i < node.length; i++) {
320 |                         arr.push(this.decode(node[i], cache, asMapKey, false));
321 |                     }
322 |                     return this.arrayBuilder.fromArray(arr, node);
323 |                 } else {
324 |                     var ret = this.arrayBuilder.init(node);
325 |                     for (var i = 0; i < node.length; i++) {
326 |                         ret = this.arrayBuilder.add(ret, this.decode(node[i], cache, asMapKey, false), node);
327 |                     }
328 |                     return this.arrayBuilder.finalize(ret, node);
329 |                 }
330 |             } else {
331 |                 var ret = [];
332 |                 for (var i = 0; i < node.length; i++) {
333 |                     ret.push(this.decode(node[i], cache, asMapKey, false));
334 |                 }
335 |                 return ret;
336 |             }
337 |         }
338 |     };
339 | 
340 |     decoder.Decoder.prototype.parseString = function (string, cache, asMapKey) {
341 |         if (string.charAt(0) === d.ESC) {
342 |             var c = string.charAt(1);
343 |             if (c === d.ESC || c === d.SUB || c === d.RES) {
344 |                 return string.substring(1);
345 |             } else if (c === d.TAG) {
346 |                 return decoder.tag(string.substring(2));
347 |             } else {
348 |                 var handler = this.handlers[c];
349 |                 if (handler == null) {
350 |                     return this.defaultHandler(c, string.substring(2));
351 |                 } else {
352 |                     return handler(string.substring(2), this);
353 |                 }
354 |             }
355 |         } else {
356 |             return string;
357 |         }
358 |     };
359 | 
360 |     decoder.decoder = function (options) {
361 |         return new decoder.Decoder(options);
362 |     };
363 | 
364 | });
365 | 


--------------------------------------------------------------------------------
/src/com/cognitect/transit/handlers.js:
--------------------------------------------------------------------------------
  1 | // Copyright 2014 Cognitect. All Rights Reserved.
  2 | //
  3 | // Licensed under the Apache License, Version 2.0 (the "License");
  4 | // you may not use this file except in compliance with the License.
  5 | // You may obtain a copy of the License at
  6 | //
  7 | //      http://www.apache.org/licenses/LICENSE-2.0
  8 | //
  9 | // Unless required by applicable law or agreed to in writing, software
 10 | // distributed under the License is distributed on an "AS-IS" BASIS,
 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 | // See the License for the specific language governing permissions and
 13 | // limitations under the License.
 14 | 
 15 | goog.provide("com.cognitect.transit.handlers");
 16 | goog.require("com.cognitect.transit.util");
 17 | goog.require("com.cognitect.transit.types");
 18 | goog.require("goog.math.Long");
 19 | 
 20 | goog.scope(function () {
 21 | 
 22 |     var handlers = com.cognitect.transit.handlers,
 23 |         util     = com.cognitect.transit.util,
 24 |         types    = com.cognitect.transit.types,
 25 |         Long     = goog.math.Long;
 26 | 
 27 |     handlers.ctorGuid = 0;
 28 | 
 29 |     /**
 30 |      * @const
 31 |      * @type {string}
 32 |      */
 33 |     handlers.ctorGuidProperty = "transit$guid$" + util.randomUUID();
 34 | 
 35 |     handlers.typeTag = function (ctor) {
 36 |         if (ctor == null) {
 37 |             return "null";
 38 |         } else if (ctor === String) {
 39 |             return "string";
 40 |         } else if (ctor === Boolean) {
 41 |             return "boolean";
 42 |         } else if (ctor === Number) {
 43 |             return "number";
 44 |         } else if (ctor === Array) {
 45 |             return "array";
 46 |         } else if (ctor === Object) {
 47 |             return "map";
 48 |         } else {
 49 |             var tag = ctor[handlers.ctorGuidProperty];
 50 |             if (tag == null) {
 51 |                 if (typeof Object.defineProperty != "undefined") {
 52 |                     tag = ++handlers.ctorGuid;
 53 |                     Object.defineProperty(ctor, handlers.ctorGuidProperty, {
 54 |                         value: tag,
 55 |                         enumerable: false
 56 |                     });
 57 |                 } else {
 58 |                     ctor[handlers.ctorGuidProperty] = tag = ++handlers.ctorGuid;
 59 |                 }
 60 |             }
 61 |             return tag;
 62 |         }
 63 |     };
 64 | 
 65 |     handlers.constructor = function (x) {
 66 |         if (x == null) {
 67 |             return null;
 68 |         } else {
 69 |             return x.constructor;
 70 |         }
 71 |     };
 72 | 
 73 |     handlers.padZeros = function (n, m) {
 74 |         var s = n.toString();
 75 |         for (var i = s.length; i < m; i++) {
 76 |             s = "0" + s;
 77 |         }
 78 |         return s;
 79 |     };
 80 | 
 81 |     handlers.stringableKeys = function (m) {
 82 |         var stringable = false,
 83 |             ks = util.objectKeys(m);
 84 | 
 85 |         for (var i = 0; i < ks.length; i++) {
 86 |         }
 87 | 
 88 |         return true;
 89 |     };
 90 | 
 91 |     /**
 92 |      * @constructor
 93 |      */
 94 |     handlers.NilHandler = function Transit$NilHandler() {
 95 |     };
 96 |     handlers.NilHandler.prototype.tag = function (v) {
 97 |         return "_";
 98 |     };
 99 |     handlers.NilHandler.prototype.rep = function (v) {
100 |         return null;
101 |     };
102 |     handlers.NilHandler.prototype.stringRep = function (v) {
103 |         return "null";
104 |     };
105 | 
106 |     /**
107 |      * @constructor
108 |      */
109 |     handlers.StringHandler = function Transit$StringHandler() {
110 |     };
111 |     handlers.StringHandler.prototype.tag = function (v) {
112 |         return "s";
113 |     };
114 |     handlers.StringHandler.prototype.rep = function (v) {
115 |         return v;
116 |     };
117 |     handlers.StringHandler.prototype.stringRep = function (v) {
118 |         return v;
119 |     };
120 | 
121 |     /**
122 |      * @constructor
123 |      */
124 |     handlers.NumberHandler = function Transit$NumberHandler() {
125 |     };
126 |     handlers.NumberHandler.prototype.tag = function (v) {
127 |         return "i";
128 |     };
129 |     handlers.NumberHandler.prototype.rep = function (v) {
130 |         return v;
131 |     };
132 |     handlers.NumberHandler.prototype.stringRep = function (v) {
133 |         return v.toString();
134 |     };
135 | 
136 |     /**
137 |      * @constructor
138 |      */
139 |     handlers.IntegerHandler = function Transit$IntegerHandler() {
140 |     };
141 |     handlers.IntegerHandler.prototype.tag = function (v) {
142 |         return "i";
143 |     };
144 |     handlers.IntegerHandler.prototype.rep = function (v) {
145 |         return v.toString();
146 |     };
147 |     handlers.IntegerHandler.prototype.stringRep = function (v) {
148 |         return v.toString();
149 |     };
150 | 
151 |     /**
152 |      * @constructor
153 |      */
154 |     handlers.BooleanHandler = function Transit$BooleanHandler() {
155 |     };
156 |     handlers.BooleanHandler.prototype.tag = function (v) {
157 |         return "?";
158 |     };
159 |     handlers.BooleanHandler.prototype.rep = function (v) {
160 |         return v;
161 |     };
162 |     handlers.BooleanHandler.prototype.stringRep = function (v) {
163 |         return v.toString();
164 |     };
165 | 
166 |     /**
167 |      * @constructor
168 |      */
169 |     handlers.ArrayHandler = function Transit$ArrayHandler() {
170 |     };
171 |     handlers.ArrayHandler.prototype.tag = function (v) {
172 |         return "array";
173 |     };
174 |     handlers.ArrayHandler.prototype.rep = function (v) {
175 |         return v;
176 |     };
177 |     handlers.ArrayHandler.prototype.stringRep = function (v) {
178 |         return null;
179 |     };
180 | 
181 |     /**
182 |      * @constructor
183 |      */
184 |     handlers.MapHandler = function Transit$MapHandler() {
185 |     };
186 |     handlers.MapHandler.prototype.tag = function (v) {
187 |         return "map";
188 |     };
189 |     handlers.MapHandler.prototype.rep = function (v) {
190 |         return v;
191 |     };
192 |     handlers.MapHandler.prototype.stringRep = function (v) {
193 |         return null;
194 |     };
195 | 
196 |     /**
197 |      * @constructor
198 |      */
199 |     handlers.VerboseDateHandler = function Transit$VerboseDateHandler() {
200 |     };
201 |     handlers.VerboseDateHandler.prototype.tag = function (v) {
202 |         return "t";
203 |     };
204 |     handlers.VerboseDateHandler.prototype.rep = function (v) {
205 |         return v.getUTCFullYear() + "-" + handlers.padZeros(v.getUTCMonth() + 1, 2) + "-" +
206 |             handlers.padZeros(v.getUTCDate(), 2) + "T" + handlers.padZeros(v.getUTCHours(), 2) + ":" +
207 |             handlers.padZeros(v.getUTCMinutes(), 2) + ":" + handlers.padZeros(v.getUTCSeconds(), 2) + "." +
208 |             handlers.padZeros(v.getUTCMilliseconds(), 3) + "Z";
209 |     };
210 |     handlers.VerboseDateHandler.prototype.stringRep = function (v, h) {
211 |         return h.rep(v);
212 |     };
213 | 
214 |     /**
215 |      * @constructor
216 |      */
217 |     handlers.DateHandler = function Transit$DateHandler() {
218 |     };
219 |     handlers.DateHandler.prototype.tag = function (v) {
220 |         return "m";
221 |     };
222 |     handlers.DateHandler.prototype.rep = function (v) {
223 |         return v.valueOf();
224 |     };
225 |     handlers.DateHandler.prototype.stringRep = function (v) {
226 |         return v.valueOf().toString();
227 |     };
228 |     handlers.DateHandler.prototype.getVerboseHandler = function (v) {
229 |         return new handlers.VerboseDateHandler();
230 |     };
231 | 
232 |     /**
233 |      * @constructor
234 |      */
235 |     handlers.UUIDHandler = function Transit$UUIDHandler() {
236 |     };
237 |     handlers.UUIDHandler.prototype.tag = function (v) {
238 |         return "u";
239 |     };
240 |     handlers.UUIDHandler.prototype.rep = function (v) {
241 |         return v.toString();
242 |     };
243 |     handlers.UUIDHandler.prototype.stringRep = function (v) {
244 |         return v.toString();
245 |     };
246 | 
247 |     /**
248 |      * @constructor
249 |      */
250 |     handlers.KeywordHandler = function Transit$KeywordHandler() {
251 |     };
252 |     handlers.KeywordHandler.prototype.tag = function (v) {
253 |         return ":";
254 |     };
255 |     handlers.KeywordHandler.prototype.rep = function (v) {
256 |         return v._name;
257 |     }; // NOTE: should be fqn
258 |     handlers.KeywordHandler.prototype.stringRep = function (v, h) {
259 |         return h.rep(v);
260 |     };
261 | 
262 |     /**
263 |      * @constructor
264 |      */
265 |     handlers.SymbolHandler = function Transit$SymbolHandler() {
266 |     };
267 |     handlers.SymbolHandler.prototype.tag = function (v) {
268 |         return "$";
269 |     };
270 |     handlers.SymbolHandler.prototype.rep = function (v) {
271 |         return v._name;
272 |     }; // NOTE: should be str
273 |     handlers.SymbolHandler.prototype.stringRep = function (v, h) {
274 |         return h.rep(v);
275 |     };
276 | 
277 |     /**
278 |      * @constructor
279 |      */
280 |     handlers.TaggedHandler = function Transit$TaggedHandler() {
281 |     };
282 |     handlers.TaggedHandler.prototype.tag = function (v) {
283 |         return v.tag;
284 |     };
285 |     handlers.TaggedHandler.prototype.rep = function (v) {
286 |         return v.rep;
287 |     };
288 |     handlers.TaggedHandler.prototype.stringRep = function (v, h) {
289 |         return null;
290 |     };
291 | 
292 |     /**
293 |      * @constructor
294 |      */
295 |     handlers.TransitSetHandler = function Transit$TransitSetHandler() {
296 |     };
297 |     handlers.TransitSetHandler.prototype.tag = function (v) {
298 |         return "set";
299 |     };
300 |     handlers.TransitSetHandler.prototype.rep = function (v) {
301 |         var arr = [];
302 |         v.forEach(function (key, set) {
303 |             arr.push(key);
304 |         });
305 |         return types.taggedValue("array", arr);
306 |     };
307 |     handlers.TransitSetHandler.prototype.stringRep = function (v, h) {
308 |         return null;
309 |     };
310 | 
311 |     /**
312 |      * @constructor
313 |      */
314 |     handlers.TransitArrayMapHandler = function Transit$ArrayMapHandler() {
315 |     };
316 |     handlers.TransitArrayMapHandler.prototype.tag = function (v) {
317 |         return "map";
318 |     };
319 |     handlers.TransitArrayMapHandler.prototype.rep = function (v) {
320 |         return v;
321 |     };
322 |     handlers.TransitArrayMapHandler.prototype.stringRep = function (v, h) {
323 |         return null;
324 |     };
325 | 
326 |     /**
327 |      * @constructor
328 |      */
329 |     handlers.TransitMapHandler = function Transit$MapHandler() {
330 |     };
331 |     handlers.TransitMapHandler.prototype.tag = function (v) {
332 |         return "map";
333 |     };
334 |     handlers.TransitMapHandler.prototype.rep = function (v) {
335 |         return v;
336 |     };
337 |     handlers.TransitMapHandler.prototype.stringRep = function (v, h) {
338 |         return null;
339 |     };
340 | 
341 |     /**
342 |      * @constructor
343 |      */
344 |     handlers.BufferHandler = function Transit$BufferHandler() {
345 |     };
346 |     handlers.BufferHandler.prototype.tag = function (v) {
347 |         return "b";
348 |     };
349 |     handlers.BufferHandler.prototype.rep = function (v) {
350 |         return v.toString("base64");
351 |     };
352 |     handlers.BufferHandler.prototype.stringRep = function (v, h) {
353 |         return null;
354 |     };
355 | 
356 |     /**
357 |      * @constructor
358 |      */
359 |     handlers.Uint8ArrayHandler = function Transit$Uint8ArrayHandler() {
360 |     };
361 |     handlers.Uint8ArrayHandler.prototype.tag = function (v) {
362 |         return "b";
363 |     };
364 |     handlers.Uint8ArrayHandler.prototype.rep = function (v) {
365 |         return util.Uint8ToBase64(v);
366 |     };
367 |     handlers.Uint8ArrayHandler.prototype.stringRep = function (v, h) {
368 |         return null;
369 |     };
370 | 
371 |     handlers.defaultHandlers = function (hs) {
372 |         hs.set(null, new handlers.NilHandler());
373 |         hs.set(String, new handlers.StringHandler());
374 |         hs.set(Number, new handlers.NumberHandler());
375 |         hs.set(Long, new handlers.IntegerHandler());
376 |         hs.set(Boolean, new handlers.BooleanHandler());
377 |         hs.set(Array, new handlers.ArrayHandler());
378 |         hs.set(Object, new handlers.MapHandler());
379 |         hs.set(Date, new handlers.DateHandler());
380 |         hs.set(types.UUID, new handlers.UUIDHandler());
381 |         hs.set(types.Keyword, new handlers.KeywordHandler());
382 |         hs.set(types.Symbol, new handlers.SymbolHandler());
383 |         hs.set(types.TaggedValue, new handlers.TaggedHandler());
384 |         hs.set(types.TransitSet, new handlers.TransitSetHandler());
385 |         hs.set(types.TransitArrayMap, new handlers.TransitArrayMapHandler());
386 |         hs.set(types.TransitMap, new handlers.TransitMapHandler());
387 | 
388 |         if (typeof goog.global.Buffer != "undefined") {
389 |             hs.set(goog.global.Buffer, new handlers.BufferHandler());
390 |         }
391 | 
392 |         if (typeof Uint8Array != "undefined") {
393 |             hs.set(Uint8Array, new handlers.Uint8ArrayHandler());
394 |         }
395 | 
396 |         return hs;
397 |     };
398 | 
399 |     /**
400 |      * @constructor
401 |      */
402 |     handlers.Handlers = function Transit$Handlers() {
403 |         this.handlers = {};
404 |         handlers.defaultHandlers(this);
405 |     };
406 | 
407 |     handlers.Handlers.prototype.get = function (ctor) {
408 |         var h = null;
409 |         if (typeof ctor === "string") {
410 |             h = this.handlers[ctor];
411 |         } else {
412 |             h = this.handlers[handlers.typeTag(ctor)];
413 |         }
414 |         if (h != null) {
415 |             return h;
416 |         } else {
417 |             return this.handlers["default"];
418 |         }
419 |     };
420 |     handlers.Handlers.prototype["get"] = handlers.Handlers.prototype.get;
421 | 
422 |     handlers.validTag = function (tag) {
423 |         switch (tag) {
424 |             case "null":
425 |             case "string":
426 |             case "boolean":
427 |             case "number":
428 |             case "array":
429 |             case "map":
430 |                 return false;
431 |                 break;
432 |         }
433 |         return true;
434 |     };
435 | 
436 |     handlers.Handlers.prototype.set = function (ctor, handler) {
437 |         if (typeof ctor === "string" && handlers.validTag(ctor)) {
438 |             this.handlers[ctor] = handler;
439 |         } else {
440 |             this.handlers[handlers.typeTag(ctor)] = handler;
441 |         }
442 |     };
443 | 
444 | });    
445 | 


--------------------------------------------------------------------------------
/doctheme/assets/vendor/prettify/prettify-min.js:
--------------------------------------------------------------------------------
1 | window.PR_SHOULD_USE_CONTINUATION=true;var prettyPrintOne;var prettyPrint;(function(){var O=window;var j=["break,continue,do,else,for,if,return,while"];var v=[j,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var q=[v,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var m=[q,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var y=[q,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var T=[y,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,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"];var s="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes";var x=[q,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var t="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";var J=[j,"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"];var g=[j,"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"];var I=[j,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var B=[m,T,x,t+J,g,I];var f=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;var D="str";var A="kwd";var k="com";var Q="typ";var H="lit";var M="pun";var G="pln";var n="tag";var F="dec";var K="src";var R="atn";var o="atv";var P="nocode";var N="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function l(ab){var af=0;var U=false;var ae=false;for(var X=0,W=ab.length;X122)){if(!(am<65||ai>90)){ah.push([Math.max(65,ai)|32,Math.min(am,90)|32])}if(!(am<97||ai>122)){ah.push([Math.max(97,ai)&~32,Math.min(am,122)&~32])}}}}ah.sort(function(aw,av){return(aw[0]-av[0])||(av[1]-aw[1])});var ak=[];var aq=[];for(var at=0;atau[0]){if(au[1]+1>au[0]){ao.push("-")}ao.push(V(au[1]))}}ao.push("]");return ao.join("")}function Y(an){var al=an.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var aj=al.length;var ap=[];for(var am=0,ao=0;am=2&&ak==="["){al[am]=Z(ai)}else{if(ak!=="\\"){al[am]=ai.replace(/[a-zA-Z]/g,function(aq){var ar=aq.charCodeAt(0);return"["+String.fromCharCode(ar&~32,ar|32)+"]"})}}}}return al.join("")}var ac=[];for(var X=0,W=ab.length;X=0;){U[ae.charAt(ag)]=aa}}var ah=aa[1];var ac=""+ah;if(!ai.hasOwnProperty(ac)){aj.push(ah);ai[ac]=null}}aj.push(/[\0-\uffff]/);X=l(aj)})();var Z=V.length;var Y=function(aj){var ab=aj.sourceCode,aa=aj.basePos;var af=[aa,G];var ah=0;var ap=ab.match(X)||[];var al={};for(var ag=0,at=ap.length;ag=5&&"lang-"===ar.substring(0,5);if(ao&&!(ak&&typeof ak[1]==="string")){ao=false;ar=K}if(!ao){al[ai]=ar}}var ad=ah;ah+=ai.length;if(!ao){af.push(aa+ad,ar)}else{var an=ak[1];var am=ai.indexOf(an);var ae=am+an.length;if(ak[2]){ae=ai.length-ak[2].length;am=ae-an.length}var au=ar.substring(5);C(aa+ad,ai.substring(0,am),Y,af);C(aa+ad+am,an,r(au,an),af);C(aa+ad+ae,ai.substring(ae),Y,af)}}aj.decorations=af};return Y}function i(V){var Y=[],U=[];if(V.tripleQuotedStrings){Y.push([D,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(V.multiLineStrings){Y.push([D,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{Y.push([D,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(V.verbatimStrings){U.push([D,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var ab=V.hashComments;if(ab){if(V.cStyleComments){if(ab>1){Y.push([k,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{Y.push([k,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}U.push([D,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])}else{Y.push([k,/^#[^\r\n]*/,null,"#"])}}if(V.cStyleComments){U.push([k,/^\/\/[^\r\n]*/,null]);U.push([k,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(V.regexLiterals){var aa=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");U.push(["lang-regex",new RegExp("^"+N+"("+aa+")")])}var X=V.types;if(X){U.push([Q,X])}var W=(""+V.keywords).replace(/^ | $/g,"");if(W.length){U.push([A,new RegExp("^(?:"+W.replace(/[\s,]+/g,"|")+")\\b"),null])}Y.push([G,/^\s+/,null," \r\n\t\xA0"]);var Z=/^.[^\s\w\.$@\'\"\`\/\\]*/;U.push([H,/^@[a-z_$][a-z_$@0-9]*/i,null],[Q,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[G,/^[a-z_$][a-z_$@0-9]*/i,null],[H,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[G,/^\\[\s\S]?/,null],[M,Z,null]);return h(Y,U)}var L=i({keywords:B,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function S(W,ah,aa){var V=/(?:^|\s)nocode(?:\s|$)/;var ac=/\r\n?|\n/;var ad=W.ownerDocument;var ag=ad.createElement("li");while(W.firstChild){ag.appendChild(W.firstChild)}var X=[ag];function af(am){switch(am.nodeType){case 1:if(V.test(am.className)){break}if("br"===am.nodeName){ae(am);if(am.parentNode){am.parentNode.removeChild(am)}}else{for(var ao=am.firstChild;ao;ao=ao.nextSibling){af(ao)}}break;case 3:case 4:if(aa){var an=am.nodeValue;var ak=an.match(ac);if(ak){var aj=an.substring(0,ak.index);am.nodeValue=aj;var ai=an.substring(ak.index+ak[0].length);if(ai){var al=am.parentNode;al.insertBefore(ad.createTextNode(ai),am.nextSibling)}ae(am);if(!aj){am.parentNode.removeChild(am)}}}break}}function ae(al){while(!al.nextSibling){al=al.parentNode;if(!al){return}}function aj(am,at){var ar=at?am.cloneNode(false):am;var ap=am.parentNode;if(ap){var aq=aj(ap,1);var ao=am.nextSibling;aq.appendChild(ar);for(var an=ao;an;an=ao){ao=an.nextSibling;aq.appendChild(an)}}return ar}var ai=aj(al.nextSibling,0);for(var ak;(ak=ai.parentNode)&&ak.nodeType===1;){ai=ak}X.push(ai)}for(var Z=0;Z=U){aj+=2}if(Y>=ar){ac+=2}}}finally{if(au){au.style.display=ak}}}var u={};function d(W,X){for(var U=X.length;--U>=0;){var V=X[U];if(!u.hasOwnProperty(V)){u[V]=W}else{if(O.console){console.warn("cannot override language handler %s",V)}}}}function r(V,U){if(!(V&&u.hasOwnProperty(V))){V=/^\s*]*(?:>|$)/],[k,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[M,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);d(h([[G,/^[\s]+/,null," \t\r\n"],[o,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[n,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[R,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[M,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);d(h([],[[o,/^[\s\S]+/]]),["uq.val"]);d(i({keywords:m,hashComments:true,cStyleComments:true,types:f}),["c","cc","cpp","cxx","cyc","m"]);d(i({keywords:"null,true,false"}),["json"]);d(i({keywords:T,hashComments:true,cStyleComments:true,verbatimStrings:true,types:f}),["cs"]);d(i({keywords:y,cStyleComments:true}),["java"]);d(i({keywords:I,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);d(i({keywords:J,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);d(i({keywords:t,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);d(i({keywords:g,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);d(i({keywords:x,cStyleComments:true,regexLiterals:true}),["js"]);d(i({keywords:s,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);d(h([],[[D,/^[\s\S]+/]]),["regex"]);function e(X){var W=X.langExtension;try{var U=b(X.sourceNode,X.pre);var V=U.sourceCode;X.sourceCode=V;X.spans=U.spans;X.basePos=0;r(W,V)(X);E(X)}catch(Y){if(O.console){console.log(Y&&Y.stack?Y.stack:Y)}}}function z(Y,X,W){var U=document.createElement("pre");U.innerHTML=Y;if(W){S(U,W,true)}var V={langExtension:X,numberLines:W,sourceNode:U,pre:1};e(V);return U.innerHTML}function c(aj){function ab(al){return document.getElementsByTagName(al)}var ah=[ab("pre"),ab("code"),ab("xmp")];var V=[];for(var ae=0;ae]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]);


--------------------------------------------------------------------------------