File tree Expand file tree Collapse file tree 4 files changed +88
-10
lines changed
Expand file tree Collapse file tree 4 files changed +88
-10
lines changed Original file line number Diff line number Diff line change 1- .nyc_output /
1+ / .nyc_output /
22node_modules /
3- build /
4- coverage /
5- lib /
6- types /
7- test /fixtures /access-denied.tpl
3+ / build /
4+ / coverage /
5+ / lib /
6+ / types /
7+ / test /fixtures /access-denied.tpl
Original file line number Diff line number Diff line change 1+ sudo : false
2+ notifications :
3+ email :
4+ on_success : never
5+ on_failure : always
6+ language : node_js
7+ branches :
8+ only :
9+ - master
10+ - /^v\d+\.\d+\.\d+$/
11+ stages :
12+ - test
13+ - deploy
14+ jobs :
15+ include :
16+ - stage : test
17+ node_js : 10
18+ script : ./scripts/test.bash :unit
19+ - stage : test
20+ node_js : 8
21+ before_script : npm install coveralls
22+ script :
23+ - ./scripts/test.bash :coverage
24+ - ./scripts/lint.bash
25+ after_script : nyc report --reporter=text-lcov | coveralls
26+ - stage : deploy
27+ node_js : 8
28+ skip_cleanup : true
29+ script : ./scripts/build.bash
30+ deploy :
31+ provider : npm
32+ email : mitmaro@gmail.com
33+ skip_cleanup : true
34+ api_key :
35+ secure : " CMpOGrptULWS3VnGi8slkp6Wf3FlSVJRfsvJmQgOExF+sq19yctF33jXg0cfRPbjDZSxVzdq0PR4py+6AspMTuo0AQVT4XhKOIYARPE8POsUPv0z88Ik8r5tKhbIDiwvdvhxPqBV1iI1jWK9rMNduOibSCJpEr3F4jd/yajsUjePvj3kO11ic6JtyjIqIQ9Et6bHtMbD0Hnhd+na8wGKdVJYWx6CSGtHB1dNK8gKwDyfZa/itlGSBFGBno1K2yI9LoOAAHilt/bMGwZ2EjjljQEhdqAUUn7xMUVPt30EPt0K8rzcLoUOZGCwmEG8sa0Rk9VDS6pmHQFu9WTxIquLfiVkLnB4KQd7OdxIh0z9BM+2Ho+wZSXulgHoRkkEa3VvwEee5le6IbayAbBLkDt0o8g+qHmvC2nMDkUxxwmjlLjJtaI3pi+UyYyI9sCRcDHfTyZlJ4N4rjnN9piWGeL/9i+Oo977hNDwTFjlVUfY5B9fQ7uJ6mhaLJKVsFVDfnq2g5Y5ENJ5WXCQKPPyATvN2EKxbHqNYdDMDancA+hVT7CmDI13fGT+YDLMvoLp4Yjh6D7ziVb2SSnKTnJhulpeNZ/B+h7VQX/STD0D5JrbAMicplNkbN6Ej5X1lZQUAZ8c8uPocAgZKx0cYVk98XBC67C7OOhnLt+LOZaBfz02yCY="
36+ on :
37+ tags : true
38+ repo : MitMaro/node-sql-template-engine
Original file line number Diff line number Diff line change 11{
2- "name" : " sql-templates " ,
3- "version" : " 0.0.1 " ,
2+ "name" : " @mitmaro/ sql-template-engine " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " A SQL template engine" ,
5- "main" : " src/index.js" ,
5+ "main" : " lib/index.js" ,
6+ "files" : [
7+ " lib" ,
8+ " types"
9+ ],
610 "directories" : {
711 "test" : " test"
812 },
13+ "types" : " types/index.d.ts" ,
14+ "publishConfig" : {
15+ "access" : " public"
16+ },
17+ "repository" : {
18+ "type" : " git" ,
19+ "url" : " git@github.com:MitMaro/node-sql-template-engine.git"
20+ },
21+ "engines" : {
22+ "node" : " >= 8"
23+ },
924 "scripts" : {
1025 "build" : " scripts/build.bash" ,
1126 "build:docs" : " scripts/docs.bash" ,
1429 "test:unit" : " scripts/test.bash :unit" ,
1530 "test:coverage" : " scripts/test.bash :coverage"
1631 },
17- "author" : " Tim Oram <mitmaro@gmail.com >" ,
32+ "author" : " Tim Oram <dev@mitmaro.ca >" ,
1833 "license" : " ISC" ,
1934 "devDependencies" : {
2035 "@mitmaro/build-scripts" : " ^0.1.5" ,
Original file line number Diff line number Diff line change 1+ import { AbstractSyntaxTree } from '../abstract-syntax-tree' ;
2+ import { AbstractSyntaxTreeCache } from '../abstract-syntax-tree-cache' ;
3+
4+ /**
5+ * Create an in-memory cache for the compiled templates
6+ * @returns A cache instance
7+ */
8+ export function createMemoryCache ( ) : AbstractSyntaxTreeCache {
9+ const cache = new Map < string , AbstractSyntaxTree > ( ) ;
10+
11+ return {
12+ /**
13+ * Get or create a value for the key
14+ * @param key The key of this entry
15+ * @param factory A function to call to create the value if it is missing
16+ * @returns Resolves with the compiled template as an abstract syntax tree
17+ */
18+ async entry ( key : string , factory : ( ) => Promise < AbstractSyntaxTree > ) : Promise < AbstractSyntaxTree > {
19+ if ( ! cache . has ( key ) ) {
20+ cache . set ( key , await factory ( ) ) ;
21+ }
22+ return cache . get ( key ) ! ;
23+ } ,
24+ } ;
25+ }
You can’t perform that action at this time.
0 commit comments