# add dist

This commit is contained in:
Mario Romano
2016-04-21 11:56:31 +01:00
parent 5914688467
commit 07807e7bc3
13499 changed files with 1808930 additions and 5 deletions

View File

@@ -0,0 +1,24 @@
v2.0.0 -- 2015.09.03
* Fix templates resolution. Since this update, internal string is parsed as
valid JavaScrip code, there for any '}' characters used as code continuation (or string insert)
won't break resolution of template. Issue #3
* Resolve non returning expressions to undefined (instead of '')
* Improve `resolve` logic
* Support 'partial' option
v1.0.0 -- 2015.06.23
* Fix bug related to '$${' resolution
* Improve error reporting
* Fix spelling of LICENSE
* Configure lint scripts
* Drop support for v0.8 node ('^' in package.json dependencies)
v0.1.0 -- 2014.04.28
* Assure strictly npm dependencies
* Update dependencies to latest versions
* Introduce resolution to array ('resolve-to-array', 'passthru-array' and 'to-array' modules)
* Reuse same functions among compilation tasks
* Do not stringify substitution on resolution
v0.0.0 -- 2013.10.10
Initial (dev version)

View File

@@ -0,0 +1,19 @@
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,49 @@
# es6-template-strings
## Compile and resolve template strings notation as specified in ES6
### Usage
```javascript
var template = require('es6-template-strings');
// Hello WORLD!
console.log(template('Hello ${place.toUpperCase()}!', { place: "World" }));
// You can reuse same templates:
var compile = require('es6-template-strings/compile')
, resolveToString = require('es6-template-strings/resolve-to-string')
, compiled = compile('Welcome to ${siteName}, you are visitor number ${visitorNumber}!');
// Welcome to MySite, you are visitor number 137!
console.log(resolveToString(compiled, { siteName: "MySite", visitorNumber: 137 }));
// Welcome to OtherSite, you are visitor number 777!
console.log(resolveToString(compiled, { siteName: "OtherSite", visitorNumber: 777 }));
// You may prepare custom tag functions
var resolve = require('es6-template-strings/resolve');
var customTag = function (literals/*, …substitutions*/) {
// Process input and return result string
};
// Output template processed by customTag:
customTag.apply(null, resolve(compiled, {/* context */}));
```
### Installation
#### NPM
In your project path:
$ npm install es6-template-strings
##### Browser
You can easily bundle _es6-template-strings_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake)
## Tests [![Build Status](https://travis-ci.org/medikoo/es6-template-strings.png)](https://travis-ci.org/medikoo/es6-template-strings)
$ npm test

View File

@@ -0,0 +1,79 @@
'use strict';
var esniff = require('esniff')
, i, current, literals, substitutions, sOut, sEscape, sAhead, sIn, sInEscape, template;
sOut = function (char) {
if (char === '\\') return sEscape;
if (char === '$') return sAhead;
current += char;
return sOut;
};
sEscape = function (char) {
if ((char !== '\\') && (char !== '$')) current += '\\';
current += char;
return sOut;
};
sAhead = function (char) {
if (char === '{') {
literals.push(current);
current = '';
return sIn;
}
if (char === '$') {
current += '$';
return sAhead;
}
current += '$' + char;
return sOut;
};
sIn = function (char) {
var code = template.slice(i), end;
esniff(code, '}', function (j) {
if (esniff.nest >= 0) return esniff.next();
end = j;
});
if (end != null) {
substitutions.push(template.slice(i, i + end));
i += end;
current = '';
return sOut;
}
end = code.length;
i += end;
current += code;
return sIn;
};
sInEscape = function (char) {
if ((char !== '\\') && (char !== '}')) current += '\\';
current += char;
return sIn;
};
module.exports = function (str) {
var length, state, result;
current = '';
literals = [];
substitutions = [];
template = String(str);
length = template.length;
state = sOut;
for (i = 0; i < length; ++i) state = state(template[i]);
if (state === sOut) {
literals.push(current);
} else if (state === sEscape) {
literals.push(current + '\\');
} else if (state === sAhead) {
literals.push(current + '$');
} else if (state === sIn) {
literals[literals.length - 1] += '${' + current;
} else if (state === sInEscape) {
literals[literals.length - 1] += '${' + current + '\\';
}
result = { literals: literals, substitutions: substitutions };
literals = substitutions = null;
return result;
};

View File

@@ -0,0 +1,8 @@
'use strict';
var compile = require('./compile')
, resolve = require('./resolve-to-string');
module.exports = function (template, context/*, options*/) {
return resolve(compile(template), context, arguments[2]);
};

View File

@@ -0,0 +1,31 @@
v1.0.0 -- 2015.09.03
* Support methods in function resolver
* Allow operator chars as triggers
* `resolveSeparated` utility
* `resolveArguments` utility
* `isStringLiteral` utility
* `ensureStringLiteral` utility
* `stripComments` utility
* `resolveConcat` utility
* Fix bug in multiline comments handling
* Optimise and improve internal algorithms
* Simplify internal algorithm with cost of invalid `{} /regexp/` handling
* Improve arguments validation
* Reorganise private modules into lib folder
* Improve tests
* Fix spelling of LICENSE
* Update Travis CI configuration
v0.1.1 -- 2014.08.08
* Fix support for one character named functions in `function` utility.
Thanks @kamsi for picking this up
* Add lint configuration
* Update dependencies configuration
v0.1.0 -- 2014.04.28
* Assure strictly npm hosted dependencies
* Add accessedProperties resolver
* Expose whitespace maps as individual modules
v0.0.0 -- 2013.11.06
Initial (dev version)

View File

@@ -0,0 +1,19 @@
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,94 @@
# esniff
## Low footprint JavaScript source code parser
Low footprint, fast source code parser, which allows you to find all code fragment occurrences with respect to all syntax rules that cannot be handled with plain regular expression search.
It aims at use cases where we need to quickly find usage of given function, property etc. in syntactically valid code.
### Installation
#### npm
$ npm install esniff
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
### Usage
Using main module you can configure sophisticated parser on your own. However, first, __see preprared [API utilities](#API) that may already address use cases you have__.
#### esniff(code, triggerChar, callback)
* `code` Code to parse
* `triggerChar` Character which is expected to trigger custom handling via `callback`
* `callback` To detect and eventually handle case we're after
Example: Find all `require(..)` calls:
```javascript
var esniff = require('esniff');
var result = esniff('var x = require(\'foo/bar\')', 'r', function (index, previous, nest) {
if (previous === '.') return next(); // Ignore x.require calls
if (code.indexOf('require', index) !== index) return esniff.next(); // Not really `require` call
next('require'.length); // Move after `require` and skip any following whitespace
index = esniff.index; // Update index
if (code[i] !== '(') return resume(); // Not `require(`
return collectNest(); // Collect all code between parenthesis
});
console.log(result); [{ point: 17, column: 17, line: 1, raw: '\'foo/bar\'' }]
```
#### API
#### accessedProperties(objName) _(esniff/accessed-properties)_
Returns function which allows us to find all accessed property names on given object name
```javascript
var findProperties = require('esniff/accessed-properties');
var findContextProperties = findProperties('this');
var result = findContextProperties('var foo = "0"; this.bar = foo; this.someMethod(); otherFunction()');
console.log(result); // [ { name: 'bar', start: 20, end: 23 }, { name: 'someMethod', start: 36, end: 46 } ]
```
#### function(name[, options]) _(esniff/function)_
Returns function which allows us to find all occurrences of given function (or method) being invoked
Through options we can restrict cases which we're after:
* `asProperty` (default: `false`), on true will allow `x.name()` when we search for `name` calls
* `asPlain` (default: `true`), on true it allows plain calls e.g. `name()` when we search for `name`. Should be set to `false` if we're strictly about method calls.
Setting both `asProperty` and `asPlain` to false, will always produce empty result
```javascript
var findRequires = require('esniff/function')('require');
findRequires('var x = require(\'foo/bar\')');
// [{ point: 17, column: 17, line: 1, raw: '\'foo/bar\'' }]
```
#### resolveArguments(code[, limit]) _(esniff/resolve-arguments)_
Resolves expressions separated with commas, with additional `limit` you can specify after which number of arguments resolver should stop
```javascript
var resolveArgs = require('esniff/resolve-arguments');
var result = resolveArgs('"raz", "dwa", [\'raz\', \'dwa\'], "trzy"', 3));
console.log(result); // ['"raz"', ' "dwa"', ' [\'raz\', \'dwa\']']
```
### Limitations
* _esniff_ assumes code that you pass is syntactically correct, it won't inform you about any syntax errors and may produce unexpected and nonsense results when such code is used.
* There's single case of syntactically correct code, which will make _esniff_ produce incorrect results, it's division made directly on object literal (e.g. `x = { foo: 'bar' } / 14`, esniff in that case will assume that `/` starts regular expression). Still there's not known use case where such code may make any sense, and many popular JS source code parsers share very same vulnerability.
* _esniff_ may work with new syntax introduced by ECMAScript 6 but it has not been fully revised in that matter yet. Pull requests are welcome.
## Tests [![Build Status](https://travis-ci.org/medikoo/esniff.svg)](https://travis-ci.org/medikoo/esniff)
$ npm test

View File

@@ -0,0 +1,139 @@
'use strict';
var value = require('es5-ext/object/valid-value')
, esniff = require('./')
, next = esniff.next
, resume = esniff.resume
// Stolen from excellent work by Mathias Bynens, see:
// http://mathiasbynens.be/notes/javascript-properties
// https://github.com/mathiasbynens/mothereff.in/blob/master/
// js-properties/eff.js#L16
, identStart = '$A-Z_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-' +
'\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d' +
'\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-' +
'\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-' +
'\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc' +
'\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5' +
'\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac' +
'\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-' +
'\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd' +
'\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13' +
'-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c' +
'\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0' +
'\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10' +
'\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d' +
'\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99' +
'\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0' +
'\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d' +
'\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-' +
'\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e' +
'-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96' +
'\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33' +
'\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97' +
'\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2' +
'\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-' +
'\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061' +
'\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd' +
'\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d' +
'\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0' +
'\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-' +
'\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea' +
'\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-' +
'\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8' +
'\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab' +
'\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b' +
'\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-' +
'\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15' +
'\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d' +
'\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc' +
'\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071' +
'\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124' +
'\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e' +
'\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2' +
'\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-' +
'\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce' +
'\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035' +
'\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-' +
'\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc' +
'\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-' +
'\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e' +
'\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-' +
'\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-' +
'\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-' +
'\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd' +
'\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-' +
'\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3' +
'\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-' +
'\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41' +
'\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-' +
'\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe' +
'\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc'
, identNext = '0-9\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1' +
'\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc' +
'\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a' +
'\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-' +
'\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0903\u093a-\u093c' +
'\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc' +
'\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef' +
'\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-' +
'\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd' +
'\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48' +
'\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2' +
'\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c3e-\u0c44' +
'\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c82' +
'\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2' +
'\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d' +
'\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6' +
'\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59' +
'\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19' +
'\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87' +
'\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059' +
'\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-' +
'\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773' +
'\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-' +
'\u192b\u1930-\u193b\u1946-\u194f\u19b0-\u19c0\u19c8\u19c9\u19d0-\u19d9' +
'\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b00-' +
'\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad' +
'\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-' +
'\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200c' +
'\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1' +
'\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-' +
'\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4' +
'-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953' +
'\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\uaa29-\uaa36\uaa43\uaa4c\uaa4d' +
'\uaa50-\uaa59\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1' +
'\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e' +
'\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f'
, reIdentStart = new RegExp('[' + identStart + ']')
, reIdentNext = new RegExp('[' + identStart + identNext + ']');
module.exports = function (objName) {
var l;
objName = String(value(objName));
l = objName.length;
if (!l) throw new TypeError(objName + " is not valid object name");
return function (code) {
var data = [];
code = String(value(code));
esniff(code, objName[0], function (i, previous) {
var name, startIndex, char;
if (previous === '.') return next();
if (code.indexOf(objName, i) !== i) return next();
next(l);
i = esniff.index;
if (code[i] !== '.') return resume();
next();
startIndex = i = esniff.index;
name = '';
if (!reIdentStart.test(char = code[i])) return resume();
name += char;
while ((char = code[++i]) && reIdentNext.test(char)) name += char;
data.push({ name: name, start: startIndex, end: i });
return next(i - startIndex);
});
return data;
};
};

View File

@@ -0,0 +1,8 @@
'use strict';
var isStringLiteral = require('./is-string-literal');
module.exports = function (arg) {
if (isStringLiteral(arg)) return arg;
throw new TypeError(arg + " does not represent string literal");
};

View File

@@ -0,0 +1,46 @@
'use strict';
var value = require('es5-ext/object/valid-value')
, esniff = require('./')
, next = esniff.next
, resume = esniff.resume
, collectNest = esniff.collectNest;
module.exports = function (name/*, options*/) {
var l, names, options = Object(arguments[1]), asProperty = false, asPlain = true;
name = String(value(name));
names = name.split('.').map(function (prop) {
prop = prop.trim();
if (!prop) throw new TypeError(name + " is not valid function name");
return prop;
});
l = names.length;
if (options.asProperty != null) asProperty = options.asProperty;
if (options.asPlain != null) asPlain = options.asPlain;
return function (code) {
code = String(value(code));
return esniff(code, names[0][0], function (i, previous) {
var j = 0, prop;
if (previous === '.') {
if (!asProperty) return next();
} else if (!asPlain) {
return next();
}
while (j < l) {
prop = names[j];
if (code.indexOf(prop, i) !== i) return next();
next(prop.length);
i = esniff.index;
++j;
if (j < l) {
if (code[i] !== '.') return resume();
next();
i = esniff.index;
}
}
if (code[i] !== '(') return resume();
return collectNest();
});
};
};

View File

@@ -0,0 +1,230 @@
'use strict';
var from = require('es5-ext/array/from')
, primitiveSet = require('es5-ext/object/primitive-set')
, value = require('es5-ext/object/valid-value')
, callable = require('es5-ext/object/valid-callable')
, d = require('d')
, eolSet = require('./lib/ws-eol')
, wsSet = require('./lib/ws')
, hasOwnProperty = Object.prototype.hasOwnProperty
, preRegExpSet = primitiveSet.apply(null, from(';{=([,<>+-*/%&|^!~?:}'))
, nonNameSet = primitiveSet.apply(null, from(';{=([,<>+-*/%&|^!~?:})].'))
, move, startCollect, endCollect, collectNest
, $ws, $common, $string, $comment, $multiComment, $regExp
, i, char, line, columnIndex, afterWs, previousChar
, nest, nestedTokens, results
, userCode, userTriggerChar, isUserTriggerOperatorChar, userCallback
, quote
, collectIndex, data, nestRelease;
move = function (j) {
if (!char) return;
if (i >= j) return;
while (i !== j) {
if (!char) return;
if (hasOwnProperty.call(wsSet, char)) {
if (hasOwnProperty.call(eolSet, char)) {
columnIndex = i;
++line;
}
} else {
previousChar = char;
}
char = userCode[++i];
}
};
startCollect = function (oldNestRelease) {
if (collectIndex != null) nestedTokens.push([data, collectIndex, oldNestRelease]);
data = { point: i + 1, line: line, column: i + 1 - columnIndex };
collectIndex = i;
};
endCollect = function () {
var previous;
data.raw = userCode.slice(collectIndex, i);
results.push(data);
if (nestedTokens.length) {
previous = nestedTokens.pop();
data = previous[0];
collectIndex = previous[1];
nestRelease = previous[2];
return;
}
data = null;
collectIndex = null;
nestRelease = null;
};
collectNest = function () {
var old = nestRelease;
nestRelease = nest;
++nest;
move(i + 1);
startCollect(old);
return $ws;
};
$common = function () {
if ((char === '\'') || (char === '"')) {
quote = char;
char = userCode[++i];
return $string;
}
if ((char === '(') || (char === '{') || (char === '[')) {
++nest;
} else if ((char === ')') || (char === '}') || (char === ']')) {
if (nestRelease === --nest) endCollect();
} else if (char === '/') {
if (hasOwnProperty.call(preRegExpSet, previousChar)) {
char = userCode[++i];
return $regExp;
}
}
if ((char !== userTriggerChar) || (!isUserTriggerOperatorChar && previousChar && !afterWs &&
!hasOwnProperty.call(nonNameSet, previousChar))) {
previousChar = char;
char = userCode[++i];
return $ws;
}
return userCallback(i, previousChar, nest);
};
$comment = function () {
while (true) {
if (!char) return;
if (hasOwnProperty.call(eolSet, char)) {
columnIndex = i + 1;
++line;
return;
}
char = userCode[++i];
}
};
$multiComment = function () {
while (true) {
if (!char) return;
if (char === '*') {
char = userCode[++i];
if (char === '/') return;
continue;
}
if (hasOwnProperty.call(eolSet, char)) {
columnIndex = i + 1;
++line;
}
char = userCode[++i];
}
};
$ws = function () {
var next;
afterWs = false;
while (true) {
if (!char) return;
if (hasOwnProperty.call(wsSet, char)) {
afterWs = true;
if (hasOwnProperty.call(eolSet, char)) {
columnIndex = i + 1;
++line;
}
} else if (char === '/') {
next = userCode[i + 1];
if (next === '/') {
char = userCode[i += 2];
afterWs = true;
$comment();
} else if (next === '*') {
char = userCode[i += 2];
afterWs = true;
$multiComment();
} else {
break;
}
} else {
break;
}
char = userCode[++i];
}
return $common;
};
$string = function () {
while (true) {
if (!char) return;
if (char === quote) {
char = userCode[++i];
previousChar = quote;
return $ws;
}
if (char === '\\') {
if (hasOwnProperty.call(eolSet, userCode[++i])) {
columnIndex = i + 1;
++line;
}
}
char = userCode[++i];
}
};
$regExp = function () {
while (true) {
if (!char) return;
if (char === '/') {
previousChar = '/';
char = userCode[++i];
return $ws;
}
if (char === '\\') ++i;
char = userCode[++i];
}
};
module.exports = exports = function (code, triggerChar, callback) {
var state;
userCode = String(value(code));
userTriggerChar = String(value(triggerChar));
if (userTriggerChar.length !== 1) {
throw new TypeError(userTriggerChar + " should be one character long string");
}
userCallback = callable(callback);
isUserTriggerOperatorChar = hasOwnProperty.call(nonNameSet, userTriggerChar);
i = 0;
char = userCode[i];
line = 1;
columnIndex = 0;
afterWs = false;
previousChar = null;
nest = 0;
nestedTokens = [];
results = [];
exports.forceStop = false;
state = $ws;
while (state) state = state();
return results;
};
Object.defineProperties(exports, {
$ws: d($ws),
$common: d($common),
collectNest: d(collectNest),
move: d(move),
index: d.gs(function () { return i; }),
line: d.gs(function () { return line; }),
nest: d.gs(function () { return nest; }),
columnIndex: d.gs(function () { return columnIndex; }),
next: d(function (step) {
if (!char) return;
move(i + (step || 1));
return $ws();
}),
resume: d(function () { return $common; })
});

View File

@@ -0,0 +1,18 @@
'use strict';
var value = require('es5-ext/object/valid-value');
module.exports = function (str) {
var quote, i, char;
str = String(value(str));
quote = str[0];
if ((quote !== '\'') && (quote !== '"')) return false;
i = 0;
char = str[++i];
while (char) {
if (char === quote) break;
if (char === '\\') ++i;
char = str[++i];
}
return Boolean(char && !str[i + 1]);
};

View File

@@ -0,0 +1,96 @@
{
"_args": [
[
"esniff@1",
"/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/es6-template-strings"
]
],
"_from": "esniff@>=1.0.0 <2.0.0",
"_id": "esniff@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/es6-template-strings/esniff",
"_nodeVersion": "0.12.7",
"_npmUser": {
"email": "medikoo+npm@medikoo.com",
"name": "medikoo"
},
"_npmVersion": "2.11.3",
"_phantomChildren": {},
"_requested": {
"name": "esniff",
"raw": "esniff@1",
"rawSpec": "1",
"scope": null,
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/es6-template-strings"
],
"_resolved": "https://registry.npmjs.org/esniff/-/esniff-1.0.0.tgz",
"_shasum": "a8d5b7d8fbe836b41b064e435b09c19988db142e",
"_shrinkwrap": null,
"_spec": "esniff@1",
"_where": "/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/es6-template-strings",
"author": {
"email": "medyk@medikoo.com",
"name": "Mariusz Nowak",
"url": "http://www.medikoo.com/"
},
"bugs": {
"url": "https://github.com/medikoo/esniff/issues"
},
"dependencies": {
"d": "^0.1.1",
"es5-ext": "^0.10.7"
},
"description": "Low footprint ECMAScript source code parser",
"devDependencies": {
"esprima": "^2.6",
"tad": "^0.2.3",
"xlint": "^0.2.2",
"xlint-jslint-medikoo": "^0.1.4"
},
"directories": {},
"dist": {
"shasum": "a8d5b7d8fbe836b41b064e435b09c19988db142e",
"tarball": "https://registry.npmjs.org/esniff/-/esniff-1.0.0.tgz"
},
"gitHead": "14b7361b0d7b07f71a496f4f11eeb74191a37b57",
"homepage": "https://github.com/medikoo/esniff#readme",
"keywords": [
"sniff",
"analyze",
"ast",
"parse",
"syntax",
"sniffer",
"detective",
"detect",
"find",
"search",
"source",
"code"
],
"license": "MIT",
"maintainers": [
{
"email": "medikoo+npm@medikoo.com",
"name": "medikoo"
}
],
"name": "esniff",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/medikoo/esniff.git"
},
"scripts": {
"lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream",
"lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch",
"test": "node ./node_modules/tad/bin/tad"
},
"version": "1.0.0"
}

View File

@@ -0,0 +1,7 @@
'use strict';
var resolveSeparated = require('./resolve-separated');
module.exports = function (code/*, limit*/) {
return resolveSeparated(code, ',', arguments[1]);
};

View File

@@ -0,0 +1,7 @@
'use strict';
var resolveSeparated = require('./resolve-separated');
module.exports = function (code/*, limit*/) {
return resolveSeparated(code, '+', arguments[1]);
};

View File

@@ -0,0 +1,26 @@
'use strict';
var from = require('es5-ext/array/from')
, value = require('es5-ext/object/valid-value')
, primitiveSet = require('es5-ext/object/primitive-set')
, esniff = require('./')
, allowedSeparators = primitiveSet.apply(null, from('.+-*/,&|;'))
, next = esniff.next;
module.exports = function (code, sep/*, limit*/) {
var expressions, fromIndex, limit = arguments[2] || Infinity;
code = String(value(code));
sep = String(value(sep));
if (!allowedSeparators[sep]) throw new Error(sep + ' is not supported separator');
expressions = [];
fromIndex = 0;
esniff(code, sep, function (i, previous, nest) {
if (nest) return next();
if (expressions.push(code.slice(fromIndex, i)) === limit) return;
fromIndex = i + 1;
return next();
});
if (expressions.length < limit) expressions.push(code.slice(fromIndex));
return expressions;
};

View File

@@ -0,0 +1,23 @@
'use strict';
var value = require('es5-ext/object/valid-value')
, repeat = require('es5-ext/string/#/repeat')
, parse = require('./lib/parse-comments');
module.exports = exports = function (code/*, options*/) {
var options = Object(arguments[1]), result, comments, i;
code = String(value(code));
comments = parse(code);
if (!comments.length) return code;
i = 0;
result = '';
comments.forEach(function (range) {
result += code.slice(i, range[0]);
if (options.preserveLocation) result += repeat.call(' ', range[1] - range[0]);
i = range[1];
});
result += code.slice(i);
return result;
};

View File

@@ -0,0 +1,127 @@
foo.bar1('on\u0065')
foo.bar2(12)
var foo = foo.bar3('thr/ee').b.c.d().e.f().g
if (foobar) {
var bla = function() {
switch (baz) {
default:
foo.bar4("fo\\ur")()()()()
}
}
qux(1, 3, quux(foo.bar5('five').bar.foo, 4), 2)
}
function func() {
return
}
foo.barąć6(baz);
var str = "raz; foo.bar('string'); ";
var str2 = 'raz; foo.bar("string2");';
var a = b
/foo.bar7("six")/g;
a['raz']
/foo.bar8("seven")/g
var c = d;
/foo.bar9('regexp');/g
foo.bar10()
if (a) {
}
/foo.bar11("reqexp2")/
var x = {
raz: 'dwa'
}
/** comment **/
obj.foo.bar13('object');
obj.
foo.bar14("object2");
// foo.bar15('comment');
var raz = 4; // foo.bar16('comment2')
/* foo.bar17('mlcomment'); */
function test() {
return foo.bar18('nine');
}
/* comment
foo.bar19('mlcomment2');
*/
if (foo) { } foo.bar20('ten');
foo.bar21('eleven' + 'split' +
'path');
foo.bar22(true ? "twelve" : "bar");
foo.bar23("object3" + { foo: bar25() });
foo.bar24.foo;
function test() {
a();return foo.bar26;
}
function test() {
return foo.bar27('fifteen');
}
(foo.bar28)('donottake')
function test() {
a(); return (foo.bar29);
}
switch (foo.bar30('seventeen')) {
case 1:
foo.bar31("'eighteen'");
break;
case 2:
foo.bar32;
break;
default:
foo.bar33('twenty');
}
if (foo.bar34('twenty/one')) {
} else if (foo.bar35('twenty/two')) {
i = (foo.bar36('twenty/three'));
}
for (var i, j = foo.bar37('/twenty/two/2/'); foo.bar38('twenty/three/2/');
foo.bar39('twenty/four/2/\'')) {
foo.bar40("twenty/five/2/\"");
}
for (i in foo.bar41('\'twenty/seven\'')) {
foo.bar42("\"twenty/eight");
}
with (a, foo.bar43("\"twenty/nine\"")) {
foo.bar44('"thirty"');
}
isNaN();foo.bar45('mid-thirty')
foo.bar46('inner' + foo.bar47(foo.bar48('marko')) + 'elo')
foo.bar49('thirty\
break-line \
one');
module.exports = foo.bar50

View File

@@ -0,0 +1,129 @@
_('on\u0065')
_(12)
var foo = _('thr/ee').b.c.d().e.f().g
if (foobar) {
var bla = function() {
switch (baz) {
default:
_("fo\\ur")()()()()
}
}
qux(1, 3, quux(_('five').bar.foo, 4), 2)
}
function func() {
return
}
_(baz);
/** comment **/
var str = "raz; _('string'); ";
var str2 = 'raz; _("string2");';
var a = b
/_("six")/g;
a['raz']
/_("seven")/g
var c = d;
/_('regexp');/g
_()
if (a) {
}
/_("reqexp2")/
var x = {
raz: 'dwa',
marko: { tile: _("nested-one") },
biurko: { elos: _("nested-one2") }
}
obj._('object');
obj.
_("object2");
// _('comment');
var raz = 4; // _('comment2')
/* _('mlcomment'); */
function test() {
return _('nine');
}
/* comment
_('mlcomment2');
*/
if (foo) { } _('ten');
_('eleven' + 'split' +
'path');
_(true ? "twelve" : "bar");
_("object3" + { foo: bar() });
_.foo;
function test() {
a();return _(('four') + 'teen');
}
function test() {
return _('fifteen');
}
(_)('donottake')
function test() {
a(); return (_('sixteen'));
}
switch (_('seventeen')) {
case 1:
_("'eighteen'");
break;
case 2:
_('nineteen');
break;
default:
_('twenty');
}
if (_('twenty/one')) {
} else if (_('twenty/two')) {
i = (_('twenty/three'));
}
for (var i, j = _('/twenty/two/2/'); _('twenty/three/2/');
_('twenty/four/2/\'')) {
_("twenty/five/2/\"");
}
for (i in _('\'twenty/seven\'')) {
_("\"twenty/eight");
}
with (a, _("\"twenty/nine\"")) {
_('"thirty"');
}
isNaN();_('mid-thirty')
_('inner' + _(_('marko')) + 'elo')
_('thirty\
break-line \
one');
module.exports = /"/, _('thirty\two')

View File

@@ -0,0 +1,130 @@
require('on\u0065')
require(12)
var foo = require('thr/ee').b.c.d().e.f().g
if (foobar) {
var bla = function() {
switch (baz) {
default:
require("fo\\ur")()()()()
}
}
qux(1, 3, quux(require('five').bar.foo, 4), 2)
}
function func() {
return
}
require(baz);
var str = "raz; require('string'); ";
var str2 = 'raz; require("string2");';
var a = b
/require("six")/g;
a['raz']
/require("seven")/g
var c = d;
/require('regexp');/g
require()
if (a) {
}
/require("reqexp2")/
var x = {
raz: 'dwa',
marko: { tile: require('nested-one') },
biurko: { elos: require('nested-one2') }
}
/** comment **/
obj.require('object');
obj.
require("object2");
// require('comment');
var raz = 4; // require('comment2')
/* require('mlcomment'); */
function test() {
return require('nine');
}
/* comment
require('mlcomment2');
*/
if (foo) { } require('ten');
otheRrequire('marko');
require('eleven' + 'split' +
'path');
require(true ? "twelve" : "bar");
require("object3" + { foo: bar() });
require.foo;
function test() {
a();return require(('four') + 'teen');
}
function test() {
return require/* raz */('fifteen');
}
(require)('donottake')
function test() {
a(); return (require('sixteen'));
}
switch (require('seventeen')) {
case 1:
require("'eighteen'");
break;
case 2:
require('nineteen');
break;
default:
require('twenty');
}
if (require('twenty/one')) {
} else if (require('twenty/two')) {
i = (require('twenty/three'));
}
for (var i, j = require('/twenty/two/2/'); require('twenty/three/2/');
require('twenty/four/2/\'')) {
require("twenty/five/2/\"");
}
for (i in require('\'twenty/seven\'')) {
require("\"twenty/eight");
}
with (a, require("\"twenty/nine\"")) {
require('"thirty"');
}
isNaN();require('mid-thirty')
require('inner' + require(require('marko')) + 'elo')
require('thirty\
break-line \
one');
module.exports = /"/, require('thirty\two')

View File

@@ -0,0 +1,124 @@
foo.bar('on\u0065')
foo.bar(12)
var foo = foo.bar('thr/ee').b.c.d().e.f().g
if (foobar) {
var bla = function() {
switch (baz) {
default:
foo.bar("fo\\ur")()()()()
}
}
qux(1, 3, quux(foo.bar('five').bar.foo, 4), 2)
}
function func() {
return
}
foo.bar(baz);
var str = "raz; foo.bar('string'); ";
var str2 = 'raz; foo.bar("string2");';
var a = b
/foo.bar("six")/g;
a['raz']
/foo.bar("seven")/g
var c = d;
/foo.bar('regexp');/g
foo.bar()
if (a) {
}
/foo.bar("reqexp2")/
var x = {
raz: 'dwa'
}
obj.foo.bar('object');
obj.
foo.bar("object2");
// foo.bar('comment');
var raz = 4; // foo.bar('comment2')
/* foo.bar('mlcomment'); */
function test() {
return foo.bar('nine');
}
/* comment
foo.bar('mlcomment2');
*/
if (foo) { } foo.bar('ten');
foo.bar('eleven' + 'split' +
'path');
foo.bar(true ? "twelve" : "bar");
foo.bar("object3" + { foo: bar() });
foo.bar.foo;
function test() {
a();return foo.bar(('four') + 'teen');
}
function test() {
return foo.bar('fifteen');
}
foo.bar('donottake')
function test() {
a(); return (foo.bar('sixteen'));
}
switch (foo.bar('seventeen')) {
case 1:
foo.bar("'eighteen'");
break;
case 2:
foo.bar('nineteen');
break;
default:
foo.bar('twenty');
}
if (foo.bar('twenty/one')) {
} else if (foo.bar('twenty/two')) {
i = (foo.bar('twenty/three'));
}
for (var i, j = foo.bar('/twenty/two/2/'); foo.bar('twenty/three/2/');
foo.bar('twenty/four/2/\'')) {
foo.bar("twenty/five/2/\"");
}
for (i in foo.bar('\'twenty/seven\'')) {
foo.bar("\"twenty/eight");
}
with (a, foo.bar("\"twenty/nine\"")) {
foo.bar('"thirty"');
}
isNaN();foo.bar('mid-thirty')
foo.bar('thirty\
break-line \
one');
module.exports = foo.bar('thirty\two')

View File

@@ -0,0 +1,127 @@
i18n.bind('on\u0065')
i18n.bind(12)
var foo = i18n.bind('thr/ee').b.c.d().e.f().g
if (foobar) {
var bla = function() {
switch (baz) {
default:
i18n.bind("fo\\ur")()()()()
}
}
qux(1, 3, quux(i18n.bind('five').bar.foo, 4), 2)
}
function func() {
return
}
/** comment **/
i18n.bind(baz);
var str = "raz; i18n.bind('string'); ";
var str2 = 'raz; i18n.bind("string2");';
var a = b
/i18n.bind("six")/g;
a['raz']
/i18n.bind("seven")/g
var c = d;
/i18n.bind('regexp');/g
i18n.bind()
if (a) {
}
/i18n.bind("reqexp2")/
var x = {
raz: 'dwa'
}
obj.i18n.bind('object');
obj.
i18n.bind("object2");
// i18n.bind('comment');
var raz = 4; // i18n.bind('comment2')
/* i18n.bind('mlcomment'); */
function test() {
return i18n.bind('nine');
}
/* comment
i18n.bind('mlcomment2');
*/
if (foo) { } i18n.bind('ten');
i18n.bind('eleven' + 'split' +
'path');
i18n.bind(true ? "twelve" : "bar");
i18n.bind("object3" + { foo: bar() });
i18n.bind.foo;
function test() {
a();return i18n.bind(('four') + 'teen');
}
function test() {
return i18n.bind/* raz */('fifteen');
}
(i18n.bind)('donottake')
function test() {
a(); return (i18n.bind('sixteen'));
}
switch (i18n.bind('seventeen')) {
case 1:
i18n.bind("'eighteen'");
break;
case 2:
i18n.bind('nineteen');
break;
default:
i18n.bind('twenty');
}
if (i18n.bind('twenty/one')) {
} else if (i18n.bind('twenty/two')) {
i = (i18n.bind('twenty/three'));
}
for (var i, j = i18n.bind('/twenty/two/2/'); i18n.bind('twenty/three/2/');
i18n.bind('twenty/four/2/\'')) {
i18n.bind("twenty/five/2/\"");
}
for (i in i18n.bind('\'twenty/seven\'')) {
i18n.bind("\"twenty/eight");
}
with (a, i18n.bind("\"twenty/nine\"")) {
i18n.bind('"thirty"');
}
isNaN();i18n.bind('mid-thirty')
i18n.bind('inner' + i18n.bind(i18n.bind('marko')) + 'elo')
i18n.bind('thirty\
break-line \
one');
module.exports = /"/, i18n.bind('thirty\two')

View File

@@ -0,0 +1,29 @@
'use strict';
var esprima = require('esprima')
, isArray = Array.isArray, keys = Object.keys
, walker;
walker = function (ast) {
if (!ast || (typeof ast !== 'object')) return;
if (isArray(ast)) {
ast.forEach(walker, this);
return;
}
keys(ast).forEach(function (key) {
if (key !== 'range') walker.call(this, ast[key]);
}, this);
if (!ast.type) return;
if ((ast.type === 'MemberExpression') &&
(ast.object.name === 'foo')) {
this.deps.push({ name: ast.property.name, start: ast.property.range[0],
end: ast.property.range[1] });
}
};
module.exports = function (code) {
var ctx = { code: code, deps: [] };
walker.call(ctx, esprima.parse(code, { range: true, loc: true }));
return ctx.deps;
};

View File

@@ -0,0 +1,68 @@
'use strict';
var last = require('es5-ext/array/#/last')
, esprima = require('esprima')
, isArray = Array.isArray, keys = Object.keys
, walker, eolRe
, fnName, objName
, asProperty;
eolRe = /(?:\r\n|[\n\r\u2028\u2029])/;
walker = function (ast) {
var dep, lines, object;
if (!ast || (typeof ast !== 'object')) return;
if (isArray(ast)) {
ast.forEach(walker, this);
return;
}
keys(ast).forEach(function (key) {
if (key !== 'range') walker.call(this, ast[key]);
}, this);
if (ast.type !== 'CallExpression') return;
if (objName) {
if (ast.callee.type !== 'MemberExpression') return false;
object = ast.callee.object;
if (object.type === 'MemberExpression') {
if (!asProperty) return;
if (object.property.name !== objName) return;
} else if (object.name !== objName) {
return;
}
if (ast.callee.property.name !== fnName) return;
if (this.code[ast.range[0]] === '(') return;
dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
dep.line = ast.loc.start.line + lines.length - 1;
dep.column = (lines.length > 1)
? last.call(lines).length : ast.loc.start.column + lines[0].length;
this.deps.push(dep);
} else {
if ((ast.type === 'CallExpression') && (ast.callee.type === 'Identifier') &&
(ast.callee.name === fnName) && (this.code[ast.range[0]] !== '(')) {
dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
dep.raw = this.code.slice(dep.point - 1, ast.range[1] - 1);
lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
dep.line = ast.loc.start.line + lines.length - 1;
dep.column = (lines.length > 1)
? last.call(lines).length : ast.loc.start.column + lines[0].length;
this.deps.push(dep);
}
}
};
module.exports = function (code, name, method, options) {
var ctx = { code: code, deps: [] };
options = Object(options);
if (method) {
fnName = method;
objName = name;
} else {
fnName = name;
}
asProperty = options.asProperty;
walker.call(ctx, esprima.parse(code, { range: true, loc: true }));
return ctx.deps;
};

View File

@@ -0,0 +1,39 @@
'use strict';
var last = require('es5-ext/array/#/last')
, esprima = require('esprima')
, isArray = Array.isArray, keys = Object.keys
, walker, eolRe;
eolRe = /(?:\r\n|[\n\r\u2028\u2029])/;
walker = function (ast) {
var dep, lines;
if (!ast || (typeof ast !== 'object')) return;
if (isArray(ast)) {
ast.forEach(walker, this);
return;
}
keys(ast).forEach(function (key) {
if (key !== 'range') walker.call(this, ast[key]);
}, this);
if (!ast.type) return;
if ((ast.type === 'CallExpression') &&
(ast.callee.type === 'MemberExpression') &&
(ast.callee.object.name === 'foo') &&
(ast.callee.property.name === 'bar')) {
dep = { point: this.code.indexOf('(', ast.range[0]) + 2 };
lines = this.code.slice(ast.range[0], dep.point).split(eolRe);
dep.line = ast.loc.start.line + lines.length - 1;
dep.column = (lines.length > 1) ? last.call(lines).length :
ast.loc.start.column + lines[0].length;
this.deps.push(dep);
}
};
module.exports = function (code) {
var ctx = { code: code, deps: [] };
walker.call(ctx, esprima.parse(code, { range: true, loc: true }));
return ctx.deps;
};

View File

@@ -0,0 +1,21 @@
'use strict';
var readFile = require('fs').readFile
, ast = require('./_ast-accessed-properties')
, pg = __dirname + '/__playground';
module.exports = function (t, a, d) {
readFile(pg + '/accessed-properties.js', 'utf-8', function (err, str) {
var plainR, astR;
if (err) {
d(err);
return;
}
plainR = t('foo')(str);
astR = ast(str);
a(plainR.length, astR.length, "Length");
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); });
d();
});
};

View File

@@ -0,0 +1,22 @@
'use strict';
module.exports = function (t, a) {
var str;
a.throws(function () { t(); }, TypeError, "Undefined");
a.throws(function () { t(null); }, TypeError, "Null");
a.throws(function () { t({}); }, TypeError, "Object");
a.throws(function () { t(''); }, TypeError, "Empty code");
a(t('""'), '""', "Empty \" string");
a(t('\'\''), '\'\'', "Empty ' string");
a.throws(function () { t('"sdfsdf'); }, TypeError, "Not finished \" string");
a.throws(function () { t('\'sdfsdf'); }, TypeError, "Not finished ' string");
str = '\'sdf\\\'fefeefe\\\\efefe\\n\\\\\\\'\\\'efef"" "sdfdfsdf\'';
a(t(str), str, "' string");
str = '"sdf\\"fefeefe\\\\efefe\\n\\\\\\"\\"efef\'\' \'sdfdfsdf"';
a(t(str), str, "Messy \" string");
a.throws(function () { t(' "sdf\\"fefeefe\\\\efefe\\n\\\\\\"\\"efef\'\' \'sdfdfsdf"'); },
TypeError, "Starts with ws");
a.throws(function () { t('"sdf\\"fefeefe\\\\efefe\\n\\\\\\"\\"efef\'\' \'sdfdfsdf" '); },
TypeError, "Ends with ws");
a.throws(function () { t('34'); }, TypeError, "Number");
};

View File

@@ -0,0 +1,67 @@
'use strict';
var readFile = require('fs').readFile
, ast = require('./_ast-function')
, pg = __dirname + '/__playground';
module.exports = function (t) {
return {
Normal: function (a, d) {
readFile(pg + '/function.js', 'utf-8', function (err, str) {
var plainR, astR;
if (err) {
d(err);
return;
}
plainR = t('require')(str);
astR = ast(str, 'require');
a(plainR.length, astR.length, "Length");
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); });
d();
});
},
"One character name": function (a, d) {
readFile(pg + '/function-one-char.js', 'utf-8', function (err, str) {
var plainR, astR;
if (err) {
d(err);
return;
}
plainR = t('_')(str);
astR = ast(str, '_');
a(plainR.length, astR.length, "Length");
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); });
d();
});
},
Method: function (a, d) {
readFile(pg + '/method.js', 'utf-8', function (err, str) {
var plainR, astR;
if (err) {
d(err);
return;
}
plainR = t('i18n.bind')(str);
astR = ast(str, 'i18n', 'bind');
a(plainR.length, astR.length, "Length");
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); });
d();
});
},
"Method as property": function (a, d) {
readFile(pg + '/method.js', 'utf-8', function (err, str) {
var plainR, astR;
if (err) {
d(err);
return;
}
plainR = t('i18n.bind', { asProperty: true })(str);
astR = ast(str, 'i18n', 'bind', { asProperty: true });
a(plainR.length, astR.length, "Length");
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); });
d();
});
}
};
};

View File

@@ -0,0 +1,35 @@
'use strict';
var readFile = require('fs').readFile
, ast = require('./_ast-index')
, pg = __dirname + '/__playground';
module.exports = function (t, a, d) {
readFile(pg + '/index.js', 'utf-8', function (err, str) {
var plainR = [], astR;
if (err) {
d(err);
return;
}
t(str, 'f', function (i, previous) {
if (previous === '.') return t.next();
if (str.indexOf('foo', i) !== i) return t.next();
t.next(3);
i = t.index;
if (str[i] !== '.') return t.resume();
t.next();
i = t.index;
if (str.indexOf('bar', i) !== i) return t.resume();
t.next(3);
i = t.index;
if (str[i] !== '(') return t.resume();
plainR.push({ point: i + 2, line: t.line, column: i + 2 - t.columnIndex });
return t.resume();
});
astR = ast(str);
a(plainR.length, astR.length, "Length");
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); });
d();
});
};

View File

@@ -0,0 +1,14 @@
'use strict';
module.exports = function (t, a) {
a(t(''), false, "Empty code");
a(t('""'), true, "Empty \" string");
a(t('\'\''), true, "Empty ' string");
a(t('"sdfsdf'), false, "Not finished \" string");
a(t('\'sdfsdf'), false, "Not finished ' string");
a(t('\'sdf\\\'fefeefe\\\\efefe\\n\\\\\\\'\\\'efef"" "sdfdfsdf\''), true, "' string");
a(t('"sdf\\"fefeefe\\\\efefe\\n\\\\\\"\\"efef\'\' \'sdfdfsdf"'), true, "\" string");
a(t(' "sdf\\"fefeefe\\\\efefe\\n\\\\\\"\\"efef\'\' \'sdfdfsdf"'), false, "Starts with ws");
a(t('"sdf\\"fefeefe\\\\efefe\\n\\\\\\"\\"efef\'\' \'sdfdfsdf" '), false, "Ends with ws");
a(t('34'), false, "Number");
};

View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function (t, a) {
a.deep(t('"raz", "dwa", [\'raz\', \'dwa\'], "trzy"'),
['"raz"', ' "dwa"', ' [\'raz\', \'dwa\']', ' "trzy"']);
a.deep(t('"raz", "dwa", [\'raz\', \'dwa\'], "trzy"', 3),
['"raz"', ' "dwa"', ' [\'raz\', \'dwa\']'], "Limit");
a.deep(t('"trzy"'), ['"trzy"'], "One argument");
};

View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function (t, a) {
a.deep(t('"raz" + "dwa" + [\'raz\', \'dwa\'] + "trzy"'),
['"raz" ', ' "dwa" ', ' [\'raz\', \'dwa\'] ', ' "trzy"']);
a.deep(t('"raz" + "dwa" + [\'raz\', \'dwa\'] + "trzy"', 3),
['"raz" ', ' "dwa" ', ' [\'raz\', \'dwa\'] '], "Limit");
a.deep(t('"trzy"'), ['"trzy"'], "One argument");
};

View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function (t, a) {
a.deep(t('"raz", "dwa", [\'raz\', \'dwa\'], "trzy"', ','),
['"raz"', ' "dwa"', ' [\'raz\', \'dwa\']', ' "trzy"']);
a.deep(t('"raz", "dwa", [\'raz\', \'dwa\'], "trzy"', ',', 3),
['"raz"', ' "dwa"', ' [\'raz\', \'dwa\']'], "Limit");
a.deep(t('"trzy"', ','), ['"trzy"'], "One argument");
};

View File

@@ -0,0 +1,8 @@
'use strict';
module.exports = function (t, a) {
var code = '/* raz */ var foo = 4; // fefe\nmasfdf()/* fefe */ fefe()/* bak */';
a.deep(t(code), ' var foo = 4; \nmasfdf() fefe()');
a.deep(t(code, { preserveLocation: true }),
' var foo = 4; \nmasfdf() fefe() ', "Preserve location");
};

View File

@@ -0,0 +1,97 @@
{
"_args": [
[
"es6-template-strings@^2.0.0",
"/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/systemjs-builder"
]
],
"_from": "es6-template-strings@>=2.0.0 <3.0.0",
"_id": "es6-template-strings@2.0.0",
"_inCache": true,
"_installable": true,
"_location": "/es6-template-strings",
"_nodeVersion": "0.12.7",
"_npmUser": {
"email": "medikoo+npm@medikoo.com",
"name": "medikoo"
},
"_npmVersion": "2.11.3",
"_phantomChildren": {
"d": "0.1.1",
"es5-ext": "0.10.11"
},
"_requested": {
"name": "es6-template-strings",
"raw": "es6-template-strings@^2.0.0",
"rawSpec": "^2.0.0",
"scope": null,
"spec": ">=2.0.0 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/systemjs-builder"
],
"_resolved": "https://registry.npmjs.org/es6-template-strings/-/es6-template-strings-2.0.0.tgz",
"_shasum": "35c80365efbbc1510fe7ca9f475967d546c169fc",
"_shrinkwrap": null,
"_spec": "es6-template-strings@^2.0.0",
"_where": "/Users/mromano/dev/dev-platform-webcomponents/ng2-components/ng2-alfresco-documentslist/node_modules/systemjs-builder",
"author": {
"email": "medyk@medikoo.com",
"name": "Mariusz Nowak",
"url": "http://www.medikoo.com/"
},
"bugs": {
"url": "https://github.com/medikoo/es6-template-strings/issues"
},
"dependencies": {
"es5-ext": "^0.10.7",
"esniff": "1"
},
"description": "Compile and resolve template strings notation as specified in ES6",
"devDependencies": {
"tad": "^0.2.3",
"xlint": "^0.2.2",
"xlint-jslint-medikoo": "^0.1.4"
},
"directories": {},
"dist": {
"shasum": "35c80365efbbc1510fe7ca9f475967d546c169fc",
"tarball": "https://registry.npmjs.org/es6-template-strings/-/es6-template-strings-2.0.0.tgz"
},
"gitHead": "8f2eaec9993a9af2b0fe9022f0c71c4a48321330",
"homepage": "https://github.com/medikoo/es6-template-strings#readme",
"keywords": [
"es6",
"template",
"string",
"literal",
"literals",
"format",
"i18n",
"quasiliterals",
"multiline",
"localization",
"escape"
],
"license": "MIT",
"maintainers": [
{
"email": "medikoo+npm@medikoo.com",
"name": "medikoo"
}
],
"name": "es6-template-strings",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/medikoo/es6-template-strings.git"
},
"scripts": {
"lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream",
"lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch",
"test": "node ./node_modules/tad/bin/tad"
},
"version": "2.0.0"
}

View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function (literals/*, …substitutions*/) {
var result = [], i, l = literals.length;
if (!l) return result;
result.push(literals[0]);
for (i = 1; i < l; ++i) result.push(arguments[i], literals[i]);
return result;
};

View File

@@ -0,0 +1,10 @@
'use strict';
var reduce = Array.prototype.reduce;
module.exports = function (literals/*, …substitutions*/) {
var args = arguments;
return reduce.call(literals, function (a, b, i) {
return a + ((args[i] === undefined) ? '' : String(args[i])) + b;
});
};

View File

@@ -0,0 +1,8 @@
'use strict';
var resolve = require('./resolve')
, passthru = require('./passthru-array');
module.exports = function (data, context/*, options*/) {
return passthru.apply(null, resolve(data, context, arguments[2]));
};

View File

@@ -0,0 +1,8 @@
'use strict';
var resolve = require('./resolve')
, passthru = require('./passthru');
module.exports = function (data, context/*, options*/) {
return passthru.apply(null, resolve(data, context, arguments[2]));
};

View File

@@ -0,0 +1,34 @@
'use strict';
var value = require('es5-ext/object/valid-value')
, normalize = require('es5-ext/object/normalize-options')
, map = Array.prototype.map, keys = Object.keys
, stringify = JSON.stringify;
module.exports = function (data, context/*, options*/) {
var names, argNames, argValues, options = Object(arguments[2]);
(value(data) && value(data.literals) && value(data.substitutions));
context = normalize(context);
names = keys(context);
argNames = names.join(', ');
argValues = names.map(function (name) { return context[name]; });
return [data.literals].concat(map.call(data.substitutions, function (expr) {
var resolver;
if (!expr) return undefined;
try {
resolver = new Function(argNames, 'return (' + expr + ')');
} catch (e) {
throw new TypeError("Unable to compile expression:\n\targs: " + stringify(argNames) +
"\n\tbody: " + stringify(expr) + "\n\terror: " + e.stack);
}
try {
return resolver.apply(null, argValues);
} catch (e) {
if (options.partial) return '${' + expr + '}';
throw new TypeError("Unable to resolve expression:\n\targs: " + stringify(argNames) +
"\n\tbody: " + stringify(expr) + "\n\terror: " + e.stack);
}
}));
};

View File

@@ -0,0 +1,23 @@
'use strict';
module.exports = function (t, a) {
a.deep(t('ech${}'),
{ literals: ['ech', '' ], substitutions: [''] });
a.deep(t('ech${"${foo}"}marko${(function () { if (elo) { return ' +
'\'${foo}\'; } else { return "${mar}"; } })}boo'),
{ literals: ['ech', 'marko', 'boo'], substitutions: ['"${foo}"',
'(function () { if (elo) { return \'${foo}\'; } else { return "${mar}"; } })'] });
a.deep(t('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k\\2o' +
'${markas()}${x.moled}ech${}eloo$${x.su}elo${marko'),
{ literals: ['', ' ${$\\{ f', 'oo ', '\n$mis\\1k\\2o', '', 'ech', 'eloo$',
'elo${marko'], substitutions: ['x.raz', 'prik()', 'maroko', 'markas()',
'x.moled', '', 'x.su'] });
a.deep(t('ula${melo}far${ulo}'), { literals: ['ula', 'far', ''],
substitutions: ['melo', 'ulo'] });
a.deep(t('${melo}far${ulo}ula'), { literals: ['', 'far', 'ula'],
substitutions: ['melo', 'ulo'] });
};

View File

@@ -0,0 +1,19 @@
'use strict';
module.exports = function (t, a) {
var obj, context;
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: 'vivi' };
context.x = obj;
a(t('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko', context),
'raz1 ${$\\{ f23oo morek\n$mis\\1k\\2omordaehoecheloovivielo${marko');
a(t('${ raz }marko ${ elo }', obj, { partial: true }), 'raz1marko ${ elo }');
};

View File

@@ -0,0 +1,22 @@
'use strict';
var compile = require('../compile')
, resolve = require('../resolve');
module.exports = function (t, a) {
var compiled, obj, context, x = {};
compiled = compile('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko');
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: x };
context.x = obj;
a.deep(t.apply(null, resolve(compiled, context)),
['', 'raz1', ' ${$\\{ f', 23, 'oo ', 'morek', '\n$mis\\1k\\2o', 'morda', '',
'eho', 'ech', undefined, 'eloo', x, 'elo${marko']);
};

View File

@@ -0,0 +1,21 @@
'use strict';
var compile = require('../compile')
, resolve = require('../resolve');
module.exports = function (t, a) {
var compiled, obj, context;
compiled = compile('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko');
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: 'vivi' };
context.x = obj;
a(t.apply(null, resolve(compiled, context)),
'raz1 ${$\\{ f23oo morek\n$mis\\1k\\2omordaehoecheloovivielo${marko');
};

View File

@@ -0,0 +1,20 @@
'use strict';
var compile = require('../compile');
module.exports = function (t, a) {
var compiled, obj, context, x = {};
compiled = compile('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko');
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: x };
context.x = obj;
a.deep(t(compiled, context), ['', 'raz1', ' ${$\\{ f', 23, 'oo ', 'morek',
'\n$mis\\1k\\2o', 'morda', '', 'eho', 'ech', undefined, 'eloo', x, 'elo${marko']);
};

View File

@@ -0,0 +1,20 @@
'use strict';
var compile = require('../compile');
module.exports = function (t, a) {
var compiled, obj, context;
compiled = compile('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko');
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: 'vivi' };
context.x = obj;
a(t(compiled, context), 'raz1 ${$\\{ f23oo morek\n$mis\\1k\\2omordaehoechel' +
'oovivielo${marko');
};

View File

@@ -0,0 +1,21 @@
'use strict';
var compile = require('../compile');
module.exports = function (t, a) {
var compiled, obj, context;
compiled = compile('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko');
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: 'vivi' };
context.x = obj;
a.deep(t(compiled, context), [['', ' ${$\\{ f', 'oo ', '\n$mis\\1k\\2o', '',
'ech', 'eloo', 'elo${marko'], 'raz1', 23, 'morek', 'morda', 'eho', undefined,
'vivi']);
};

View File

@@ -0,0 +1,18 @@
'use strict';
module.exports = function (t, a) {
var obj, context, x = {};
context = {
maroko: 'morek',
prik: function () { return obj.prik2; },
markas: function () { return obj.foo; }
};
obj = { raz: 'raz1', prik2: 23, foo: 'morda', moled: 'eho', su: x };
context.x = obj;
a.deep(t('${x.raz} \\${$\\{ f${prik()}oo ${maroko}\n\\$mis\\1k' +
'\\2o${markas()}${x.moled}ech${}eloo${x.su}elo${marko', context),
['', 'raz1', ' ${$\\{ f', 23, 'oo ', 'morek', '\n$mis\\1k\\2o', 'morda', '',
'eho', 'ech', undefined, 'eloo', x, 'elo${marko']);
};

View File

@@ -0,0 +1,8 @@
'use strict';
var compile = require('./compile')
, resolve = require('./resolve-to-array');
module.exports = function (template, context/*, options*/) {
return resolve(compile(template), context, arguments[2]);
};