Reorganize module loading.

We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point.  This results
in a much smaller extension size (almost half).  Furthermore we use
yarn/npm even for extension run-time dependencies.  This relieves us
from manually vendoring and building dependencies.  It's also easier to
understand for new developers familiar with node.
This commit is contained in:
Florian Dold 2017-04-20 03:09:25 +02:00
parent e6e0cbc387
commit 82f2b76e25
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2785 changed files with 210963 additions and 320486 deletions

2
.gitignore vendored
View File

@ -22,3 +22,5 @@ node_modules
coverage/
coverage-*.json
dist/

18
decl/jed.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
interface JedInstance {
translate: any;
ngettext: any;
}
interface JedConstructor {
new(s: any): JedInstance;
}
declare namespace JedLib {
const Jed: JedConstructor;
}
declare module "jed" {
export = JedLib;
}

3190
decl/jquery/jquery.d.ts vendored

File diff suppressed because it is too large Load Diff

20674
decl/lib.es6.d.ts vendored

File diff suppressed because it is too large Load Diff

2178
decl/node.d.ts vendored

File diff suppressed because it is too large Load Diff

75
decl/react-dom.d.ts vendored
View File

@ -1,75 +0,0 @@
// Type definitions for React v0.14 (react-dom)
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="react.d.ts" />
declare namespace __React {
namespace __DOM {
function findDOMNode<E extends Element>(instance: ReactInstance): E;
function findDOMNode(instance: ReactInstance): Element;
function render<P extends DOMAttributes, T extends Element>(
element: DOMElement<P, T>,
container: Element,
callback?: (element: T) => any): T;
function render<P>(
element: SFCElement<P>,
container: Element,
callback?: () => any): void;
function render<P, T extends Component<P, ComponentState>>(
element: CElement<P, T>,
container: Element,
callback?: (component: T) => any): T;
function render<P>(
element: ReactElement<P>,
container: Element,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
function unmountComponentAtNode(container: Element): boolean;
var version: string;
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
function unstable_batchedUpdates(callback: () => any): void;
function unstable_renderSubtreeIntoContainer<P extends DOMAttributes, T extends Element>(
parentComponent: Component<any, any>,
element: DOMElement<P, T>,
container: Element,
callback?: (element: T) => any): T;
function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
parentComponent: Component<any, any>,
element: CElement<P, T>,
container: Element,
callback?: (component: T) => any): T;
function render<P>(
parentComponent: Component<any, any>,
element: SFCElement<P>,
container: Element,
callback?: () => any): void;
function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any, any>,
element: ReactElement<P>,
container: Element,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
}
namespace __DOMServer {
function renderToString(element: ReactElement<any>): string;
function renderToStaticMarkup(element: ReactElement<any>): string;
var version: string;
}
}
declare module "react-dom" {
import DOM = __React.__DOM;
export = DOM;
}
declare module "react-dom/server" {
import DOMServer = __React.__DOMServer;
export = DOMServer;
}

View File

@ -1,11 +0,0 @@
// Type definitions for React v0.14 (namespace)
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="react.d.ts" />
/// <reference path="react-dom.d.ts" />
import React = __React;
import ReactDOM = __React.__DOM;

2547
decl/react.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
interface System {
import(name: string): Promise<any>;
defined: any;
amdDefine: () => void;
amdRequire: () => void;
baseURL: string;
paths: { [key: string]: string };
meta: { [key: string]: Object };
config: any;
newModule(obj: Object): any;
normalizeSync(name: string): string;
set(moduleName: string, module: any): void;
}
declare var System: System;
declare module "systemjs" {
export = System;
}

227
decl/urijs.d.ts vendored Normal file
View File

@ -0,0 +1,227 @@
// Type definitions for URI.js 1.15.1
// Project: https://github.com/medialize/URI.js
// Definitions by: RodneyJT <https://github.com/RodneyJT>, Brian Surowiec <https://github.com/xt0rted>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Modified by Florian Dold <dold@taler.net>
declare module "urijs" {
interface URIOptions {
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
path?: string;
query?: string;
fragment?: string;
}
class URI {
public constructor();
public constructor (value: string | URIOptions | HTMLElement);
static addQuery(data: Object, prop: string, value: string): Object;
static addQuery(data: Object, qryObj: Object): Object;
static build(parts: {
protocol: string;
username: string;
password: string;
hostname: string;
port: string;
path: string;
query: string;
fragment: string;
}): string;
static buildAuthority(parts: {
username?: string;
password?: string;
hostname?: string;
port?: string;
}): string;
static buildHost(parts: {
hostname?: string;
port?: string;
}): string;
static buildQuery(qry: Object): string;
static buildQuery(qry: Object, duplicates: boolean): string;
static buildUserinfo(parts: {
username?: string;
password?: string;
}): string;
static commonPath(path1: string, path2: string): string;
static decode(str: string): string;
static decodeQuery(qry: string): string;
static encode(str: string): string;
static encodeQuery(qry: string): string;
static encodeReserved(str: string): string;
static expand(template: string, vals: Object): URI;
static iso8859(): void;
static joinPaths(...paths: (string | URI)[]): URI;
static parse(url: string): {
protocol: string;
username: string;
password: string;
hostname: string;
port: string;
path: string;
query: string;
fragment: string;
};
static parseAuthority(url: string, parts: {
username?: string;
password?: string;
hostname?: string;
port?: string;
}): string;
static parseHost(url: string, parts: {
hostname?: string;
port?: string;
}): string;
static parseQuery(url: string): Object;
static parseUserinfo(url: string, parts: {
username?: string;
password?: string;
}): string;
static removeQuery(data: Object, prop: string, value: string): Object;
static removeQuery(data: Object, props: string[]): Object;
static removeQuery(data: Object, props: Object): Object;
static unicode(): void;
static withinString(source: string, func: (url: string) => string): string;
absoluteTo(path: string): URI;
absoluteTo(path: URI): URI;
addFragment(fragment: string): URI;
addQuery(qry: string): URI;
addQuery(qry: Object): URI;
addSearch(qry: string): URI;
addSearch(key: string, value:any): URI;
addSearch(qry: Object): URI;
authority(): string;
authority(authority: string): URI;
clone(): URI;
directory(): string;
directory(dir: boolean): string;
directory(dir: string): URI;
domain(): string;
domain(domain: boolean): string;
domain(domain: string): URI;
duplicateQueryParameters(val: boolean): URI;
equals(): boolean;
equals(url: string | URI): boolean;
filename(): string;
filename(file: boolean): string;
filename(file: string): URI;
fragment(): string;
fragment(fragment: string): URI;
fragmentPrefix(prefix: string): URI;
hash(): string;
hash(hash: string): URI;
host(): string;
host(host: string): URI;
hostname(): string;
hostname(hostname: string): URI;
href(): string;
href(url: string): void;
is(qry: string): boolean;
iso8859(): URI;
normalize(): URI;
normalizeFragment(): URI;
normalizeHash(): URI;
normalizeHostname(): URI;
normalizePath(): URI;
normalizePathname(): URI;
normalizePort(): URI;
normalizeProtocol(): URI;
normalizeQuery(): URI;
normalizeSearch(): URI;
origin(): string;
origin(uri: string | URI): URI;
password(): string;
password(pw: string): URI;
path(): string;
path(path: boolean): string;
path(path: string): URI;
pathname(): string;
pathname(path: boolean): string;
pathname(path: string): URI;
port(): string;
port(port: string): URI;
protocol(): string;
protocol(protocol: string): URI;
query(): string;
query(qry: string): URI;
query(qry: boolean): Object;
query(qry: Object): URI;
readable(): string;
relativeTo(path: string): URI;
removeQuery(qry: string): URI;
removeQuery(qry: Object): URI;
removeSearch(qry: string): URI;
removeSearch(qry: Object): URI;
resource(): string;
resource(resource: string): URI;
scheme(): string;
scheme(protocol: string): URI;
search(): string;
search(qry: string): URI;
search(qry: boolean): any;
search(qry: Object): URI;
segment(): string[];
segment(segments: string[]): URI;
segment(position: number): string;
segment(position: number, level: string): URI;
segment(segment: string): URI;
segmentCoded(): string[];
segmentCoded(segments: string[]): URI;
segmentCoded(position: number): string;
segmentCoded(position: number, level: string): URI;
segmentCoded(segment: string): URI;
setQuery(key: string, value: string): URI;
setQuery(qry: Object): URI;
setSearch(key: string, value: string): URI;
setSearch(qry: Object): URI;
hasQuery(name: string | any, value?: string | number | boolean | Function | Array<string> | Array<number> | Array<boolean> | RegExp, withinArray?: boolean): boolean;
hasSearch(name: string | any, value?: string | number | boolean | Function | Array<string> | Array<number> | Array<boolean> | RegExp, withinArray?: boolean): boolean;
subdomain(): string;
subdomain(subdomain: string): URI;
suffix(): string;
suffix(suffix: boolean): string;
suffix(suffix: string): URI;
tld(): string;
tld(tld: boolean): string;
tld(tld: string): URI;
unicode(): URI;
userinfo(): string;
userinfo(userinfo: string): URI;
username(): string;
username(uname: string): URI;
valueOf(): string;
}
export = URI;
}

236
decl/urijs/URIjs.d.ts vendored
View File

@ -1,236 +0,0 @@
// Type definitions for URI.js 1.15.1
// Project: https://github.com/medialize/URI.js
// Definitions by: RodneyJT <https://github.com/RodneyJT>, Brian Surowiec <https://github.com/xt0rted>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
declare module uri {
interface URI {
absoluteTo(path: string): URI;
absoluteTo(path: URI): URI;
addFragment(fragment: string): URI;
addQuery(qry: string): URI;
addQuery(qry: Object): URI;
addSearch(qry: string): URI;
addSearch(key: string, value:any): URI;
addSearch(qry: Object): URI;
authority(): string;
authority(authority: string): URI;
clone(): URI;
directory(): string;
directory(dir: boolean): string;
directory(dir: string): URI;
domain(): string;
domain(domain: boolean): string;
domain(domain: string): URI;
duplicateQueryParameters(val: boolean): URI;
equals(): boolean;
equals(url: string): boolean;
filename(): string;
filename(file: boolean): string;
filename(file: string): URI;
fragment(): string;
fragment(fragment: string): URI;
fragmentPrefix(prefix: string): URI;
hash(): string;
hash(hash: string): URI;
host(): string;
host(host: string): URI;
hostname(): string;
hostname(hostname: string): URI;
href(): string;
href(url: string): void;
is(qry: string): boolean;
iso8859(): URI;
normalize(): URI;
normalizeFragment(): URI;
normalizeHash(): URI;
normalizeHostname(): URI;
normalizePath(): URI;
normalizePathname(): URI;
normalizePort(): URI;
normalizeProtocol(): URI;
normalizeQuery(): URI;
normalizeSearch(): URI;
password(): string;
password(pw: string): URI;
path(): string;
path(path: boolean): string;
path(path: string): URI;
pathname(): string;
pathname(path: boolean): string;
pathname(path: string): URI;
port(): string;
port(port: string): URI;
protocol(): string;
protocol(protocol: string): URI;
query(): string;
query(qry: string): URI;
query(qry: boolean): Object;
query(qry: Object): URI;
readable(): string;
relativeTo(path: string): URI;
removeQuery(qry: string): URI;
removeQuery(qry: Object): URI;
removeSearch(qry: string): URI;
removeSearch(qry: Object): URI;
resource(): string;
resource(resource: string): URI;
scheme(): string;
scheme(protocol: string): URI;
search(): string;
search(qry: string): URI;
search(qry: boolean): any;
search(qry: Object): URI;
segment(): string[];
segment(segments: string[]): URI;
segment(position: number): string;
segment(position: number, level: string): URI;
segment(segment: string): URI;
setQuery(key: string, value: string): URI;
setQuery(qry: Object): URI;
setSearch(key: string, value: string): URI;
setSearch(qry: Object): URI;
subdomain(): string;
subdomain(subdomain: string): URI;
suffix(): string;
suffix(suffix: boolean): string;
suffix(suffix: string): URI;
tld(): string;
tld(tld: boolean): string;
tld(tld: string): URI;
unicode(): URI;
userinfo(): string;
userinfo(userinfo: string): URI;
username(): string;
username(uname: string): URI;
valueOf(): string;
}
interface URIOptions {
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
path?: string;
query?: string;
fragment?: string;
}
interface URIStatic {
(): URI;
(value: string | URIOptions | HTMLElement): URI;
new (): URI;
new (value: string | URIOptions | HTMLElement): URI;
addQuery(data: Object, prop: string, value: string): Object;
addQuery(data: Object, qryObj: Object): Object;
build(parts: {
protocol: string;
username: string;
password: string;
hostname: string;
port: string;
path: string;
query: string;
fragment: string;
}): string;
buildAuthority(parts: {
username?: string;
password?: string;
hostname?: string;
port?: string;
}): string;
buildHost(parts: {
hostname?: string;
port?: string;
}): string;
buildQuery(qry: Object): string;
buildQuery(qry: Object, duplicates: boolean): string;
buildUserinfo(parts: {
username?: string;
password?: string;
}): string;
commonPath(path1: string, path2: string): string;
decode(str: string): string;
decodeQuery(qry: string): string;
encode(str: string): string;
encodeQuery(qry: string): string;
encodeReserved(str: string): string;
expand(template: string, vals: Object): URI;
iso8859(): void;
parse(url: string): {
protocol: string;
username: string;
password: string;
hostname: string;
port: string;
path: string;
query: string;
fragment: string;
};
parseAuthority(url: string, parts: {
username?: string;
password?: string;
hostname?: string;
port?: string;
}): string;
parseHost(url: string, parts: {
hostname?: string;
port?: string;
}): string;
parseQuery(url: string): Object;
parseUserinfo(url: string, parts: {
username?: string;
password?: string;
}): string;
removeQuery(data: Object, prop: string, value: string): Object;
removeQuery(data: Object, props: string[]): Object;
removeQuery(data: Object, props: Object): Object;
unicode(): void;
withinString(source: string, func: (url: string) => string): string;
}
}
interface JQuery {
uri(): uri.URI;
}
declare var URI: uri.URIStatic;
declare module 'URI' {
export = URI;
}
declare module 'urijs' {
export = URI;
}

View File

@ -30,6 +30,7 @@
*/
const gulp = require("gulp");
const gutil = require("gulp-util");
const map = require("map-stream");
const zip = require("gulp-zip");
const gzip = require("gulp-gzip");
@ -47,6 +48,7 @@ const through = require('through2');
const File = require('vinyl');
const Stream = require('stream').Stream;
const vfs = require('vinyl-fs');
const webpack = require('webpack');
const paths = {
ts: {
@ -55,11 +57,9 @@ const paths = {
"!src/**/*-test*.ts",
],
decl: [
"decl/lib.es6.d.ts",
"decl/urijs/URIjs.d.ts",
"decl/systemjs/systemjs.d.ts",
"decl/react-global.d.ts",
"decl/jed.d.ts",
"decl/chrome/chrome.d.ts",
"decl/urijs.d.ts",
],
test: [
"testlib/**/.ts",
@ -70,8 +70,10 @@ const paths = {
dist: [
"img/icon.png",
"img/logo.png",
"src/**/*.{js,css,html}",
"testlib/**/*.{js,ts,tsx,html}",
"src/**/*.{css,html}",
"src/taler-wallet-lib.js",
"src/emscripten/taler-emscripten-lib.js",
"dist/*-bundle.js",
],
// for the source distribution
extra: [
@ -103,9 +105,9 @@ const tsBaseArgs = {
jsx: "react",
reactNamespace: "React",
experimentalDecorators: true,
module: "system",
module: "commonjs",
sourceMap: true,
noLib: true,
lib: ["ES6", "DOM"],
noImplicitReturns: true,
noFallthroughCasesInSwitch: true,
strictNullChecks: true,
@ -157,27 +159,19 @@ gulp.task("clean", function () {
});
gulp.task("dist-prod", ["clean"], function () {
gulp.task("dist-prod", ["clean", "compile-prod"], function () {
return vfs.src(paths.dist, {base: ".", stripBOM: false})
.pipe(gulp.dest("build/ext/"));
});
gulp.task("compile-prod", ["clean"], function () {
const tsArgs = {};
Object.assign(tsArgs, tsBaseArgs);
tsArgs.typescript = require("typescript");
// relative to the gulp.dest
tsArgs.outDir = ".";
// We don't want source maps for production
tsArgs.sourceMap = undefined;
let opts = {base: "."};
const files = concatStreams(
gulp.src(paths.ts.src, opts),
gulp.src(paths.ts.decl, opts));
return files
.pipe(ts(tsArgs))
.pipe(gulp.dest("build/ext/"));
gulp.task("compile-prod", function (callback) {
let config = require("./webpack.config.js");
webpack(config, function(err, stats) {
if(err) {
throw new gutil.PluginError("webpack", err);
}
callback();
});
});
gulp.task("manifest-stable", ["clean"], function () {
@ -199,7 +193,7 @@ gulp.task("manifest-unstable", ["clean"], function () {
});
gulp.task("package-stable", ["compile-prod", "dist-prod", "manifest-stable"], function () {
gulp.task("package-stable", ["dist-prod", "manifest-stable"], function () {
let basename = String.prototype.concat("taler-wallet-stable-", manifest.version_name, "-", manifest.version);
let zipname = basename + ".zip";
let xpiname = basename + ".xpi";
@ -209,7 +203,7 @@ gulp.task("package-stable", ["compile-prod", "dist-prod", "manifest-stable"], fu
.pipe(symlink("build/" + xpiname, {relative: true, force: true}));
});
gulp.task("package-unstable", ["compile-prod", "dist-prod", "manifest-unstable"], function () {
gulp.task("package-unstable", ["dist-prod", "manifest-unstable"], function () {
let basename = String.prototype.concat("taler-wallet-unstable-", manifest.version_name, "-", manifest.version);
let zipname = basename + ".zip";
let xpiname = basename + ".xpi";

View File

@ -36,16 +36,15 @@
"32": "img/icon.png"
},
"default_title": "Taler",
"default_popup": "src/popup/popup.html"
"default_popup": "src/pages/popup.html"
},
"content_scripts": [
{
"matches": ["*://*/*"],
"js": [
"src/vendor/URI.js",
"src/taler-wallet-lib.js",
"src/content_scripts/notify.js"
"dist/contentScript-bundle.js"
],
"run_at": "document_start"
}

2
node_modules/.yarn-integrity generated vendored
View File

@ -1 +1 @@
7ed29847ffe108e16d5c053f27c2c2be64cd4091dc26a19a2d6cfb0f78807183
0dc42bcf25ec3d59c7bd394b1d9f751da1a3446ef6012260b277831cef6de2bf

2
node_modules/ansi-regex/index.js generated vendored
View File

@ -1,4 +1,4 @@
'use strict';
module.exports = function () {
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g;
};

21
node_modules/ansi-regex/license generated vendored
View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.

11
node_modules/ansi-regex/package.json generated vendored
View File

@ -1,24 +1,19 @@
{
"name": "ansi-regex",
"version": "2.0.0",
"version": "0.2.1",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": "sindresorhus/ansi-regex",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "http://sindresorhus.com"
},
"maintainers": [
"Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
"Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)"
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha test/test.js",
"view-supported": "node test/viewCodes.js"
"test": "mocha"
},
"files": [
"index.js"

4
node_modules/ansi-regex/readme.md generated vendored
View File

@ -5,7 +5,7 @@
## Install
```
```sh
$ npm install --save ansi-regex
```
@ -25,6 +25,8 @@ ansiRegex().test('cake');
//=> ['\u001b[4m', '\u001b[0m']
```
*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
## License

6
node_modules/archiver/CHANGELOG.md generated vendored
View File

@ -1,5 +1,11 @@
## Changelog
**1.3.0** — <small> December 13, 2016_</small> — [Diff](https://github.com/archiverjs/node-archiver/compare/1.2.0...1.3.0)
- improve `directory` and `glob` methods to use events rather than callbacks. (#203)
- fix bulk warning spam (#208)
- updated mocha (#205)
**1.2.0** — <small> November 2, 2016_</small> — [Diff](https://github.com/archiverjs/node-archiver/compare/1.1.0...1.2.0)
- Add a `process.emitWarning` for `deprecated` (#202)

50
node_modules/archiver/README.md generated vendored
View File

@ -1,4 +1,4 @@
# Archiver v1.2.0
# Archiver v1.3.0
[![Build Status](https://travis-ci.org/archiverjs/node-archiver.svg?branch=master)](https://travis-ci.org/archiverjs/node-archiver) [![Build status](https://ci.appveyor.com/api/projects/status/38kqu3yp159nodxe/branch/master?svg=true)](https://ci.appveyor.com/project/ctalkington/node-archiver/branch/master)
@ -12,11 +12,55 @@ Visit the [API documentation](http://archiverjs.com/docs) for a list of all meth
npm install archiver --save
```
## Usage
## Quick Start
```js
// require modules
var fs = require('fs');
var archiver = require('archiver');
var archive = archiver.create('zip', {}); // or archiver('zip', {});
// create a file to stream archive data to.
var output = fs.createWriteStream(__dirname + '/example.zip');
var archive = archiver('zip', {
store: true // Sets the compression method to STORE.
});
// listen for all archive data to be written
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
// good practice to catch this error explicitly
archive.on('error', function(err) {
throw err;
});
// pipe archive data to the file
archive.pipe(output);
// append a file from stream
var file1 = __dirname + '/file1.txt';
archive.append(fs.createReadStream(file1), { name: 'file1.txt' });
// append a file from string
archive.append('string cheese!', { name: 'file2.txt' });
// append a file from buffer
var buffer3 = new Buffer('buff it!');
archive.append(buffer3, { name: 'file3.txt' });
// append a file
archive.file('file1.txt', { name: 'file4.txt' });
// append files from a directory
archive.directory('subdir/');
// append files from a glob pattern
archive.glob('subdir/*.txt');
// finalize the archive (ie we are done appending files but streams have to finish yet)
archive.finalize();
```
## Formats

113
node_modules/archiver/lib/core.js generated vendored
View File

@ -9,6 +9,8 @@ var fs = require('fs');
var glob = require('glob');
var async = require('async');
var _ = require('lodash');
var path = require('path');
var walkdir = require('walkdir');
var util = require('archiver-utils');
var inherits = require('util').inherits;
@ -16,6 +18,10 @@ var Transform = require('readable-stream').Transform;
var win32 = process.platform === 'win32';
if (process._loggedBulkDeprecation === undefined) {
process._loggedBulkDeprecation = false;
}
/**
* @constructor
* @param {String} format The archive format to use.
@ -58,8 +64,6 @@ var Archiver = function(format, options) {
};
this._streams = [];
this._loggedBulkDeprecation = false;
};
inherits(Archiver, Transform);
@ -557,8 +561,8 @@ Archiver.prototype.append = function(source, data) {
* @return {this}
*/
Archiver.prototype.bulk = function(mappings) {
if (!this._loggedBulkDeprecation) {
this._loggedBulkDeprecation = true;
if (process._loggedBulkDeprecation === false) {
process._loggedBulkDeprecation = true;
var warning = 'Archiver.bulk() deprecated since 0.21.0';
if (typeof process !== 'undefined' && typeof process.emitWarning !== 'undefined') {
process.emitWarning(warning, 'DeprecationWarning');
@ -655,38 +659,43 @@ Archiver.prototype.directory = function(dirpath, destpath, data) {
data = {};
}
var self = this;
function onWalkPath(filepath, stats){
var entryData = _.extend({}, data);
entryData.name = path.relative(dirpath, filepath).replace(/\\/g, '/');
entryData.prefix = destpath;
entryData.stats = stats;
util.walkdir(dirpath, function(err, results) {
if (err) {
self.emit('error', err);
} else {
results.forEach(function(file) {
var entryData = _.extend({}, data);
entryData.name = file.relative;
entryData.prefix = destpath;
entryData.stats = file.stats;
try {
if (dataFunction) {
entryData = dataFunction(entryData);
try {
if (dataFunction) {
entryData = dataFunction(entryData);
if (typeof entryData !== 'object') {
throw new Error('directory: invalid data returned from custom function');
}
}
} catch(e) {
self.emit('error', e);
return;
if (typeof entryData !== 'object') {
throw new Error('directory: invalid data returned from custom function');
}
self._append(file.path, entryData);
});
}
} catch(e) {
this.emit('error', e);
return;
}
self._pending--;
self._maybeFinalize();
});
this._append(filepath, entryData);
}
function onWalkEnd() {
this._pending--;
this._maybeFinalize();
}
function onWalkError(err) {
this.emit('error', 'directory: ' + err);
}
var walker = walkdir(dirpath);
walker.on('error', onWalkError.bind(this));
walker.on('directory', onWalkPath.bind(this));
walker.on('file', onWalkPath.bind(this));
walker.on('end', onWalkEnd.bind(this));
return this;
};
@ -736,26 +745,30 @@ Archiver.prototype.glob = function(pattern, options, data) {
stat: false
});
var globber = glob(pattern, options, function(err, files) {
if (err) {
this.emit('error', err);
return this;
}
files.forEach(function(file) {
entryData = _.extend({}, data);
if (options.cwd) {
entryData.name = file;
file = globber._makeAbs(file);
}
this._append(file, entryData);
}, this);
function onGlobEnd() {
this._pending--;
this._maybeFinalize();
}.bind(this));
}
function onGlobError(err) {
this.emit('error', 'glob: ' + err);
}
function onGlobMatch(match){
entryData = _.extend({}, data);
if (options.cwd) {
entryData.name = match;
match = globber._makeAbs(match);
}
this._append(match, entryData);
}
var globber = glob(pattern, options);
globber.on('error', onGlobError.bind(this));
globber.on('match', onGlobMatch.bind(this));
globber.on('end', onGlobEnd.bind(this));
return this;
};
@ -890,4 +903,4 @@ module.exports = Archiver;
* when working with methods like `directory` or `glob`.
* @property {fs.Stats} [stats] Sets the fs stat data for this entry allowing
* for reduction of fs stat calls when stat data is already known.
*/
*/

7
node_modules/archiver/package.json generated vendored
View File

@ -1,6 +1,6 @@
{
"name": "archiver",
"version": "1.2.0",
"version": "1.3.0",
"description": "a streaming interface for archive generation",
"homepage": "https://github.com/archiverjs/node-archiver",
"author": {
@ -36,13 +36,14 @@
"lodash": "^4.8.0",
"readable-stream": "^2.0.0",
"tar-stream": "^1.5.0",
"zip-stream": "^1.1.0"
"zip-stream": "^1.1.0",
"walkdir": "^0.0.11"
},
"devDependencies": {
"archiver-jsdoc-theme": "^1.0.0",
"jsdoc": "~3.4.0",
"chai": "^3.4.0",
"mocha": "^2.3.3",
"mocha": "^3.1.1",
"rimraf": "^2.4.2",
"mkdirp": "^0.5.0",
"stream-bench": "^0.1.2",

2
node_modules/arr-flatten/LICENSE generated vendored
View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014-2015, Jon Schlinkert.
Copyright (c) 2014-2015, 2017, Jon Schlinkert
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

102
node_modules/arr-flatten/README.md generated vendored
View File

@ -1,51 +1,29 @@
# arr-flatten [![NPM version](https://badge.fury.io/js/arr-flatten.svg)](http://badge.fury.io/js/arr-flatten) [![Build Status](https://travis-ci.org/jonschlinkert/arr-flatten.svg)](https://travis-ci.org/jonschlinkert/arr-flatten)
# arr-flatten [![NPM version](https://img.shields.io/npm/v/arr-flatten.svg?style=flat)](https://www.npmjs.com/package/arr-flatten) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-flatten.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/arr-flatten) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/arr-flatten.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/arr-flatten)
> Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
> Recursively flatten an array or arrays.
Why another flatten utility? I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%.
## Install
## Run benchmarks
Install with [npm](https://www.npmjs.com/):
```bash
npm run benchmarks
```sh
$ npm install --save arr-flatten
```
Benchmark results comparing this library to [array-flatten]:
Install with [yarn](https://yarnpkg.com):
```bash
#1: large.js
arr-flatten.js x 487,030 ops/sec ±0.67% (92 runs sampled)
array-flatten.js x 347,020 ops/sec ±0.57% (98 runs sampled)
#2: medium.js
arr-flatten.js x 1,914,516 ops/sec ±0.76% (94 runs sampled)
array-flatten.js x 1,391,661 ops/sec ±0.63% (96 runs sampled)
#3: small.js
arr-flatten.js x 5,158,980 ops/sec ±0.85% (94 runs sampled)
array-flatten.js x 3,683,173 ops/sec ±0.79% (97 runs sampled)
```sh
$ yarn add arr-flatten
```
## Run tests
## Install
Install dev dependencies:
Install with [bower](https://bower.io/)
```bash
npm i -d && npm test
```sh
$ bower install arr-flatten --save
```
## Install with [npm](npmjs.org)
```bash
npm i arr-flatten --save
```
### Install with [bower](https://github.com/bower/bower)
```bash
bower install arr-flatten --save
```
## Usage
```js
@ -55,19 +33,53 @@ flatten(['a', ['b', ['c']], 'd', ['e']]);
//=> ['a', 'b', 'c', 'd', 'e']
```
## Author
## Why another flatten utility?
I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%.
## About
### Related projects
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.")
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.")
* [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.")
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 11, 2015._
[array-flatten]: https://github.com/blakeembrey/array-flatten
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 16, 2017._

20
node_modules/arr-flatten/index.js generated vendored Executable file → Normal file
View File

@ -1,8 +1,8 @@
/*!
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
* Copyright (c) 2014-2015, 2017, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
@ -11,17 +11,17 @@ module.exports = function flatten(arr) {
return flat(arr, []);
};
function flat(arr, res) {
function flat(arr, acc) {
var len = arr.length;
var i = -1;
var idx = -1;
while (len--) {
var cur = arr[++i];
while (++idx < len) {
var cur = arr[idx];
if (Array.isArray(cur)) {
flat(cur, res);
flat(cur, acc);
} else {
res.push(cur);
acc.push(cur);
}
}
return res;
}
return acc;
}

67
node_modules/arr-flatten/package.json generated vendored Executable file → Normal file
View File

@ -1,23 +1,14 @@
{
"name": "arr-flatten",
"description": "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.",
"version": "1.0.1",
"description": "Recursively flatten an array or arrays.",
"version": "1.0.3",
"homepage": "https://github.com/jonschlinkert/arr-flatten",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/arr-flatten.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/arr-flatten",
"bugs": {
"url": "https://github.com/jonschlinkert/arr-flatten/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/arr-flatten/blob/master/LICENSE"
},
"license": "MIT",
"files": [
"index.js"
],
@ -26,16 +17,25 @@
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha",
"benchmarks": "node benchmark"
"test": "mocha"
},
"devDependencies": {
"array-flatten": "^1.0.2",
"array-slice": "^0.2.2",
"benchmarked": "^0.1.3",
"chalk": "^0.5.1",
"glob": "^4.3.5",
"kind-of": "^1.0.0"
"ansi-bold": "^0.1.1",
"array-flatten": "^2.1.1",
"array-slice": "^1.0.0",
"benchmarked": "^1.0.0",
"compute-flatten": "^1.0.0",
"flatit": "^1.1.1",
"flatten": "^1.0.2",
"flatten-array": "^1.0.0",
"glob": "^7.1.1",
"gulp-format-md": "^0.1.12",
"just-flatten-it": "^1.1.23",
"lodash.flattendeep": "^4.4.0",
"m_flattened": "^1.0.1",
"mocha": "^3.2.0",
"utils-flatten": "^1.0.0",
"write": "^0.3.3"
},
"keywords": [
"arr",
@ -47,5 +47,26 @@
"recurse",
"recursive",
"recursively"
]
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"arr-union",
"array-unique",
"array-each",
"arr-filter"
]
},
"lint": {
"reflinks": true
}
}
}

20
node_modules/async/CHANGELOG.md generated vendored
View File

@ -1,3 +1,23 @@
# v2.3.0
- Added support for ES2017 `async` functions. Wherever you can pass a Node-style/CPS function that uses a callback, you can also pass an `async` function. Previously, you had to wrap `async` functions with `asyncify`. The caveat is that it will onyl work if `async` functions are supported nateively in your environment, transpilied implementations can't be detected. (#1386, #1390)
- Small doc fix (#1392)
# v2.2.0
- Added `groupBy`, and the `Series`/`Limit` equivalents, analogous to [`_.groupBy`](http://lodash.com/docs#groupBy) (#1364)
- Fixed `transform` bug when `callback` was not passed (#1381)
- Added note about `reflect` to `parallel` docs (#1385)
# v2.1.5
- Fix `auto` bug when function names collided with Array.prototype (#1358)
- Improve some error messages (#1349)
- Avoid stack overflow case in queue
- Fixed an issue in `some`, `every` and `find` where processing would continue after the result was determined.
- Cleanup implementations of `some`, `every` and `find`
# v2.1.3
- Make bundle size smaller
- Create optimized hotpath for `filter` in array case.
# v2.1.2
- Fixed a stackoverflow bug with `detect`, `some`, `every` on large inputs (#1293).

2
node_modules/async/LICENSE generated vendored
View File

@ -1,4 +1,4 @@
Copyright (c) 2010-2016 Caolan McMahon
Copyright (c) 2010-2017 Caolan McMahon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

2
node_modules/async/README.md generated vendored
View File

@ -4,6 +4,8 @@
[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
[![Join the chat at https://gitter.im/caolan/async](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![libhive - Open source examples](https://www.libhive.com/providers/npm/packages/async/examples/badge.svg)](https://www.libhive.com/providers/npm/packages/async)
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.

1633
node_modules/async/dist/async.js generated vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

7
node_modules/async/package.json generated vendored
View File

@ -1,7 +1,7 @@
{
"name": "async",
"description": "Higher-order functions and common patterns for asynchronous code",
"version": "2.1.2",
"version": "2.3.0",
"main": "dist/async.js",
"author": "Caolan McMahon",
"repository": {
@ -21,12 +21,13 @@
"lodash": "^4.14.0"
},
"devDependencies": {
"babel-cli": "^6.16.0",
"babel-core": "^6.3.26",
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-istanbul": "^2.0.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.16",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2017": "^6.22.0",
"babelify": "^7.2.0",
"benchmark": "^2.1.1",
"bluebird": "^3.4.6",

View File

@ -5,7 +5,7 @@
## Install
```sh
$ npm install babel-code-frame
npm install --save-dev babel-code-frame
```
## Usage
@ -40,3 +40,4 @@ name | type | default | description
highlightCode | boolean | `false` | Syntax highlight the code as JavaScript for terminals
linesAbove | number | 2 | The number of lines to show above the error
linesBelow | number | 3 | The number of lines to show below the error
forceColor | boolean | `false` | Forcibly syntax highlight the code as JavaScript (for non-terminals); overrides highlightCode

View File

@ -3,15 +3,20 @@
exports.__esModule = true;
exports.default = function (rawLines, lineNumber, colNumber) {
var opts = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
colNumber = Math.max(colNumber, 0);
var highlighted = opts.highlightCode && _chalk2.default.supportsColor;
var highlighted = opts.highlightCode && _chalk2.default.supportsColor || opts.forceColor;
var chalk = _chalk2.default;
if (opts.forceColor) {
chalk = new _chalk2.default.constructor({ enabled: true });
}
var maybeHighlight = function maybeHighlight(chalkFn, string) {
return highlighted ? chalkFn(string) : string;
};
if (highlighted) rawLines = highlight(rawLines);
var defs = getDefs(chalk);
if (highlighted) rawLines = highlight(defs, rawLines);
var linesAbove = opts.linesAbove || 2;
var linesBelow = opts.linesBelow || 3;
@ -44,7 +49,7 @@ exports.default = function (rawLines, lineNumber, colNumber) {
}).join("\n");
if (highlighted) {
return _chalk2.default.reset(frame);
return chalk.reset(frame);
} else {
return frame;
}
@ -64,20 +69,22 @@ var _chalk2 = _interopRequireDefault(_chalk);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var defs = {
keyword: _chalk2.default.cyan,
capitalized: _chalk2.default.yellow,
jsx_tag: _chalk2.default.yellow,
punctuator: _chalk2.default.yellow,
function getDefs(chalk) {
return {
keyword: chalk.cyan,
capitalized: chalk.yellow,
jsx_tag: chalk.yellow,
punctuator: chalk.yellow,
number: _chalk2.default.magenta,
string: _chalk2.default.green,
regex: _chalk2.default.magenta,
comment: _chalk2.default.grey,
invalid: _chalk2.default.white.bgRed.bold,
gutter: _chalk2.default.grey,
marker: _chalk2.default.red.bold
};
number: chalk.magenta,
string: chalk.green,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold,
gutter: chalk.grey,
marker: chalk.red.bold
};
}
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
@ -86,12 +93,11 @@ var JSX_TAG = /^[a-z][\w-]*$/i;
var BRACKET = /^[()\[\]{}]$/;
function getTokenType(match) {
var _match$slice = match.slice(-2);
var _match$slice = match.slice(-2),
offset = _match$slice[0],
text = _match$slice[1];
var offset = _match$slice[0];
var text = _match$slice[1];
var token = _jsTokens2.default.matchToToken(match);
var token = (0, _jsTokens.matchToToken)(match);
if (token.type === "name") {
if (_esutils2.default.keyword.isReservedWordES6(token.value)) {
@ -114,7 +120,7 @@ function getTokenType(match) {
return token.type;
}
function highlight(text) {
function highlight(defs, text) {
return text.replace(_jsTokens2.default, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

View File

@ -1,6 +1,6 @@
{
"name": "babel-code-frame",
"version": "6.16.0",
"version": "6.22.0",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -10,6 +10,6 @@
"dependencies": {
"chalk": "^1.1.0",
"esutils": "^2.0.2",
"js-tokens": "^2.0.0"
"js-tokens": "^3.0.0"
}
}

View File

@ -5,7 +5,7 @@
## Install
```sh
$ npm install babel-generator
npm install --save-dev babel-generator
```
## Usage
@ -37,6 +37,8 @@ minified | boolean | `false` | Should the output be minif
concise | boolean | `false` | Set to `true` to reduce whitespace (but not as much as `opts.compact`)
quotes | `'single'` or `'double'` | autodetect based on `ast.tokens` | The type of quote to use in the output
filename | string | | Used in warning messages
flowCommaSeparator | boolean | `false` | Set to `true` to use commas instead of semicolons as Flow property separators
jsonCompatibleStrings | boolean | `false` | Set to true to run `jsesc` with "json": true to print "\u00A9" vs. "©";
Options for source maps:

View File

@ -6,9 +6,9 @@ var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _trimEnd = require("lodash/trimEnd");
var _trimRight = require("trim-right");
var _trimEnd2 = _interopRequireDefault(_trimEnd);
var _trimRight2 = _interopRequireDefault(_trimRight);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@ -38,19 +38,36 @@ var Buffer = function () {
Buffer.prototype.get = function get() {
this._flush();
return {
code: (0, _trimEnd2.default)(this._buf.join("")),
map: this._map ? this._map.get() : null
var map = this._map;
var result = {
code: (0, _trimRight2.default)(this._buf.join("")),
map: null,
rawMappings: map && map.getRawMappings()
};
if (map) {
Object.defineProperty(result, "map", {
configurable: true,
enumerable: true,
get: function get() {
return this.map = map.get();
},
set: function set(value) {
Object.defineProperty(this, "map", { value: value, writable: true });
}
});
}
return result;
};
Buffer.prototype.append = function append(str) {
this._flush();
var _sourcePosition = this._sourcePosition;
var line = _sourcePosition.line;
var column = _sourcePosition.column;
var filename = _sourcePosition.filename;
var identifierName = _sourcePosition.identifierName;
var _sourcePosition = this._sourcePosition,
line = _sourcePosition.line,
column = _sourcePosition.column,
filename = _sourcePosition.filename,
identifierName = _sourcePosition.identifierName;
this._append(str, line, column, identifierName, filename);
};
@ -58,11 +75,11 @@ var Buffer = function () {
Buffer.prototype.queue = function queue(str) {
if (str === "\n") while (this._queue.length > 0 && SPACES_RE.test(this._queue[0][0])) {
this._queue.shift();
}var _sourcePosition2 = this._sourcePosition;
var line = _sourcePosition2.line;
var column = _sourcePosition2.column;
var filename = _sourcePosition2.filename;
var identifierName = _sourcePosition2.identifierName;
}var _sourcePosition2 = this._sourcePosition,
line = _sourcePosition2.line,
column = _sourcePosition2.column,
filename = _sourcePosition2.filename,
identifierName = _sourcePosition2.identifierName;
this._queue.unshift([str, line, column, identifierName, filename]);
};

View File

@ -31,11 +31,14 @@ function Program(node) {
function BlockStatement(node) {
this.token("{");
this.printInnerComments(node);
if (node.body.length) {
var hasDirectives = node.directives && node.directives.length;
if (node.body.length || hasDirectives) {
this.newline();
this.printSequence(node.directives, node, { indent: true });
if (node.directives && node.directives.length) this.newline();
if (hasDirectives) this.newline();
this.printSequence(node.body, node, { indent: true });
this.removeTrailingNewline();

View File

@ -13,6 +13,7 @@ exports.ThisExpression = ThisExpression;
exports.Super = Super;
exports.Decorator = Decorator;
exports.CallExpression = CallExpression;
exports.Import = Import;
exports.EmptyStatement = EmptyStatement;
exports.ExpressionStatement = ExpressionStatement;
exports.AssignmentPattern = AssignmentPattern;
@ -21,10 +22,6 @@ exports.BindExpression = BindExpression;
exports.MemberExpression = MemberExpression;
exports.MetaProperty = MetaProperty;
var _isNumber = require("lodash/isNumber");
var _isNumber2 = _interopRequireDefault(_isNumber);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
@ -35,8 +32,6 @@ var n = _interopRequireWildcard(_node);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function UnaryExpression(node) {
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof") {
this.word(node.operator);
@ -142,6 +137,10 @@ function CallExpression(node) {
this.token(")");
}
function Import() {
this.word("import");
}
function buildYieldAwait(keyword) {
return function (node) {
this.word(keyword);
@ -173,6 +172,8 @@ function ExpressionStatement(node) {
function AssignmentPattern(node) {
this.print(node.left, node);
if (node.left.optional) this.token("?");
this.print(node.left.typeAnnotation, node);
this.space();
this.token("=");
this.space();
@ -219,7 +220,7 @@ function MemberExpression(node) {
}
var computed = node.computed;
if (t.isLiteral(node.property) && (0, _isNumber2.default)(node.property.value)) {
if (t.isLiteral(node.property) && typeof node.property.value === "number") {
computed = true;
}

View File

@ -321,11 +321,19 @@ function ObjectTypeAnnotation(node) {
this.space();
this.printJoin(props, node, {
addNewlines: function addNewlines(leading) {
if (leading && !props[0]) return 1;
},
indent: true,
statement: true,
iterator: function iterator() {
if (props.length !== 1) {
_this.semicolon();
if (_this.format.flowCommaSeparator) {
_this.token(",");
} else {
_this.semicolon();
}
_this.space();
}
}

View File

@ -12,6 +12,7 @@ exports.JSXNamespacedName = JSXNamespacedName;
exports.JSXMemberExpression = JSXMemberExpression;
exports.JSXSpreadAttribute = JSXSpreadAttribute;
exports.JSXExpressionContainer = JSXExpressionContainer;
exports.JSXSpreadChild = JSXSpreadChild;
exports.JSXText = JSXText;
exports.JSXElement = JSXElement;
exports.JSXOpeningElement = JSXOpeningElement;
@ -57,6 +58,13 @@ function JSXExpressionContainer(node) {
this.token("}");
}
function JSXSpreadChild(node) {
this.token("{");
this.token("...");
this.print(node.expression, node);
this.token("}");
}
function JSXText(node) {
this.token(node.value);
}

View File

@ -19,6 +19,11 @@ var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function ImportSpecifier(node) {
if (node.importKind === "type" || node.importKind === "typeof") {
this.word(node.importKind);
this.space();
}
this.print(node.imported, node);
if (node.local && node.local.name !== node.imported.name) {
this.space();
@ -58,12 +63,6 @@ function ExportAllDeclaration(node) {
this.word("export");
this.space();
this.token("*");
if (node.exported) {
this.space();
this.word("as");
this.space();
this.print(node.exported, node);
}
this.space();
this.word("from");
this.space();

View File

@ -115,13 +115,12 @@ var buildForXStatement = function buildForXStatement(op) {
if (op === "await") {
this.word("await");
this.space();
op = "of";
}
this.token("(");
this.print(node.left, node);
this.space();
this.word(op);
this.word(op === "await" ? "of" : op);
this.space();
this.print(node.right, node);
this.token(")");

View File

@ -15,9 +15,7 @@ function TemplateElement(node, parent) {
var value = (isFirst ? "`" : "}") + node.value.raw + (isLast ? "`" : "${");
if (!isFirst) this.space();
this.token(value);
if (!isLast) this.space();
}
function TemplateLiteral(node) {

View File

@ -128,21 +128,31 @@ function NullLiteral() {
function NumericLiteral(node) {
var raw = this.getPossibleRaw(node);
this.number(raw == null ? node.value + "" : raw);
var value = node.value + "";
if (raw == null) {
this.number(value);
} else if (this.format.minified) {
this.number(raw.length < value.length ? raw : value);
} else {
this.number(raw);
}
}
function StringLiteral(node, parent) {
var raw = this.getPossibleRaw(node);
if (raw != null) {
if (!this.format.minified && raw != null) {
this.token(raw);
return;
}
var val = (0, _jsesc2.default)(node.value, {
var opts = {
quotes: t.isJSX(parent) ? "double" : this.format.quotes,
wrap: true
});
};
if (this.format.jsonCompatibleStrings) {
opts.json = true;
}
var val = (0, _jsesc2.default)(node.value, opts);
return this.token(val);
}

View File

@ -43,11 +43,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var Generator = function (_Printer) {
(0, _inherits3.default)(Generator, _Printer);
function Generator(ast, opts, code) {
function Generator(ast) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var code = arguments[2];
(0, _classCallCheck3.default)(this, Generator);
opts = opts || {};
var tokens = ast.tokens || [];
var format = normalizeOptions(code, opts, tokens);
var map = opts.sourceMaps ? new _sourceMap2.default(opts, code) : null;
@ -83,11 +83,13 @@ function normalizeOptions(code, opts, tokens) {
minified: opts.minified,
concise: opts.concise,
quotes: opts.quotes || findCommonStringDelimiter(code, tokens),
jsonCompatibleStrings: opts.jsonCompatibleStrings,
indent: {
adjustMultilineComment: true,
style: style,
base: 0
}
},
flowCommaSeparator: opts.flowCommaSeparator
};
if (format.minified) {
@ -103,10 +105,10 @@ function normalizeOptions(code, opts, tokens) {
}
if (format.compact === "auto") {
format.compact = code.length > 100000;
format.compact = code.length > 500000;
if (format.compact) {
console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "100KB"));
console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "500KB"));
}
}
@ -123,7 +125,7 @@ function findCommonStringDelimiter(code, tokens) {
return DEFAULT_STRING_DELIMITER;
}
var occurences = {
var occurrences = {
single: 0,
double: 0
};
@ -136,15 +138,15 @@ function findCommonStringDelimiter(code, tokens) {
var raw = code.slice(token.start, token.end);
if (raw[0] === "'") {
occurences.single++;
occurrences.single++;
} else {
occurences.double++;
occurrences.double++;
}
checked++;
if (checked >= 3) break;
}
if (occurences.single > occurences.double) {
if (occurrences.single > occurrences.double) {
return "single";
} else {
return "double";

View File

@ -5,6 +5,7 @@ exports.AwaitExpression = exports.FunctionTypeAnnotation = undefined;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.UpdateExpression = UpdateExpression;
exports.ObjectExpression = ObjectExpression;
exports.DoExpression = DoExpression;
exports.Binary = Binary;
exports.BinaryExpression = BinaryExpression;
exports.SequenceExpression = SequenceExpression;
@ -55,27 +56,19 @@ function NullableTypeAnnotation(node, parent) {
exports.FunctionTypeAnnotation = NullableTypeAnnotation;
function UpdateExpression(node, parent) {
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
return false;
return t.isMemberExpression(parent) && parent.object === node;
}
function ObjectExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { considerArrow: true });
}
function DoExpression(node, parent, printStack) {
return isFirstInStatement(printStack);
}
function Binary(node, parent) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
return true;
}
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) {
return true;
}
@ -86,11 +79,7 @@ function Binary(node, parent) {
var nodeOp = node.operator;
var nodePos = PRECEDENCE[nodeOp];
if (parentPos > nodePos) {
return true;
}
if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent)) {
if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent) || parentPos > nodePos) {
return true;
}
}
@ -99,49 +88,12 @@ function Binary(node, parent) {
}
function BinaryExpression(node, parent) {
if (node.operator === "in") {
if (t.isVariableDeclarator(parent)) {
return true;
}
if (t.isFor(parent)) {
return true;
}
}
return false;
return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
}
function SequenceExpression(node, parent) {
if (t.isForStatement(parent)) {
return false;
}
if (t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
if (t.isReturnStatement(parent)) {
return false;
}
if (t.isThrowStatement(parent)) {
return false;
}
if (t.isSwitchStatement(parent) && parent.discriminant === node) {
return false;
}
if (t.isWhileStatement(parent) && parent.test === node) {
return false;
}
if (t.isIfStatement(parent) && parent.test === node) {
return false;
}
if (t.isForInStatement(parent) && parent.right === node) {
if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
@ -158,15 +110,7 @@ function ClassExpression(node, parent, printStack) {
}
function UnaryLike(node, parent) {
if (t.isMemberExpression(parent, { object: node })) {
return true;
}
if (t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node })) {
return true;
}
return false;
return t.isMemberExpression(parent, { object: node }) || t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node });
}
function FunctionExpression(node, parent, printStack) {
@ -174,15 +118,7 @@ function FunctionExpression(node, parent, printStack) {
}
function ArrowFunctionExpression(node, parent) {
if (t.isExportDeclaration(parent)) {
return true;
}
if (t.isBinaryExpression(parent) || t.isLogicalExpression(parent)) {
return true;
}
if (t.isUnaryExpression(parent)) {
if (t.isExportDeclaration(parent) || t.isBinaryExpression(parent) || t.isLogicalExpression(parent) || t.isUnaryExpression(parent) || t.isTaggedTemplateExpression(parent)) {
return true;
}
@ -190,15 +126,7 @@ function ArrowFunctionExpression(node, parent) {
}
function ConditionalExpression(node, parent) {
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isBinary(parent)) {
return true;
}
if (t.isConditionalExpression(parent, { test: node })) {
if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, { test: node }) || t.isAwaitExpression(parent)) {
return true;
}
@ -214,27 +142,18 @@ function AssignmentExpression(node) {
}
function isFirstInStatement(printStack) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _ref$considerArrow = _ref.considerArrow;
var considerArrow = _ref$considerArrow === undefined ? false : _ref$considerArrow;
var _ref$considerDefaultE = _ref.considerDefaultExports;
var considerDefaultExports = _ref$considerDefaultE === undefined ? false : _ref$considerDefaultE;
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$considerArrow = _ref.considerArrow,
considerArrow = _ref$considerArrow === undefined ? false : _ref$considerArrow,
_ref$considerDefaultE = _ref.considerDefaultExports,
considerDefaultExports = _ref$considerDefaultE === undefined ? false : _ref$considerDefaultE;
var i = printStack.length - 1;
var node = printStack[i];
i--;
var parent = printStack[i];
while (i > 0) {
if (t.isExpressionStatement(parent, { expression: node })) {
return true;
}
if (considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node })) {
return true;
}
if (considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
if (t.isExpressionStatement(parent, { expression: node }) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node }) || considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
return true;
}

View File

@ -1,13 +1,5 @@
"use strict";
var _isBoolean = require("lodash/isBoolean");
var _isBoolean2 = _interopRequireDefault(_isBoolean);
var _each = require("lodash/each");
var _each2 = _interopRequireDefault(_each);
var _map = require("lodash/map");
var _map2 = _interopRequireDefault(_map);
@ -144,19 +136,14 @@ exports.list = {
}
};
(0, _each2.default)({
Function: true,
Class: true,
Loop: true,
LabeledStatement: true,
SwitchStatement: true,
TryStatement: true
}, function (amounts, type) {
if ((0, _isBoolean2.default)(amounts)) {
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function (_ref) {
var type = _ref[0],
amounts = _ref[1];
if (typeof amounts === "boolean") {
amounts = { after: amounts, before: amounts };
}
(0, _each2.default)([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
[type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
exports.nodes[type] = function () {
return amounts;
};

View File

@ -340,8 +340,6 @@ var Printer = function () {
};
Printer.prototype.getPossibleRaw = function getPossibleRaw(node) {
if (this.format.minified) return;
var extra = node.extra;
if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {
return extra.raw;

View File

@ -22,27 +22,38 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var SourceMap = function () {
function SourceMap(opts, code) {
var _this = this;
(0, _classCallCheck3.default)(this, SourceMap);
this._cachedMap = null;
this._code = code;
this._opts = opts;
this._map = new _sourceMap2.default.SourceMapGenerator({
file: opts.sourceMapTarget,
sourceRoot: opts.sourceRoot
});
if (typeof code === "string") {
this._map.setSourceContent(opts.sourceFileName, code);
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") {
(0, _keys2.default)(code).forEach(function (sourceFileName) {
_this._map.setSourceContent(sourceFileName, code[sourceFileName]);
});
}
this._rawMappings = [];
}
SourceMap.prototype.get = function get() {
return this._map.toJSON();
if (!this._cachedMap) {
var map = this._cachedMap = new _sourceMap2.default.SourceMapGenerator({
file: this._opts.sourceMapTarget,
sourceRoot: this._opts.sourceRoot
});
var code = this._code;
if (typeof code === "string") {
map.setSourceContent(this._opts.sourceFileName, code);
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") {
(0, _keys2.default)(code).forEach(function (sourceFileName) {
map.setSourceContent(sourceFileName, code[sourceFileName]);
});
}
this._rawMappings.forEach(map.addMapping, map);
}
return this._cachedMap.toJSON();
};
SourceMap.prototype.getRawMappings = function getRawMappings() {
return this._rawMappings.slice();
};
SourceMap.prototype.mark = function mark(generatedLine, generatedColumn, line, column, identifierName, filename) {
@ -52,18 +63,19 @@ var SourceMap = function () {
return;
}
this._cachedMap = null;
this._lastGenLine = generatedLine;
this._lastSourceLine = line;
this._lastSourceColumn = column;
this._map.addMapping({
name: identifierName,
this._rawMappings.push({
name: identifierName || undefined,
generated: {
line: generatedLine,
column: generatedColumn
},
source: line == null ? null : filename || this._opts.sourceFileName,
original: line == null ? null : {
source: line == null ? undefined : filename || this._opts.sourceFileName,
original: line == null ? undefined : {
line: line,
column: column
}

View File

@ -1,6 +1,6 @@
{
"name": "babel-generator",
"version": "6.18.0",
"version": "6.24.1",
"description": "Turns an AST into code.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -11,16 +11,17 @@
"lib"
],
"dependencies": {
"babel-messages": "^6.8.0",
"babel-runtime": "^6.9.0",
"babel-types": "^6.18.0",
"babel-messages": "^6.23.0",
"babel-runtime": "^6.22.0",
"babel-types": "^6.24.1",
"detect-indent": "^4.0.0",
"jsesc": "^1.3.0",
"lodash": "^4.2.0",
"source-map": "^0.5.0"
"source-map": "^0.5.0",
"trim-right": "^1.0.1"
},
"devDependencies": {
"babel-helper-fixtures": "^6.18.0",
"babel-helper-fixtures": "^6.22.0",
"babylon": "^6.11.0"
}
}

View File

@ -5,7 +5,7 @@
## Install
```sh
$ npm install babel-messages
npm install --save-dev babel-messages
```
## Usage

View File

@ -1,4 +1,4 @@
/*istanbul ignore next*/"use strict";
"use strict";
exports.__esModule = true;
exports.MESSAGES = undefined;
@ -8,24 +8,17 @@ var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
exports.get = get;
/*istanbul ignore next*/exports.parseArgs = parseArgs;
exports.parseArgs = parseArgs;
var /*istanbul ignore next*/_util = require("util");
var _util = require("util");
/*istanbul ignore next*/
var util = _interopRequireWildcard(_util);
/*istanbul ignore next*/
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Mapping of messages to be used in Babel.
* Messages can include $0-style placeholders.
*/
var MESSAGES = /*istanbul ignore next*/exports.MESSAGES = {
var MESSAGES = exports.MESSAGES = {
tailCallReassignmentDeopt: "Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",
classesIllegalBareSuper: "Illegal use of bare super",
classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
@ -61,42 +54,28 @@ var MESSAGES = /*istanbul ignore next*/exports.MESSAGES = {
pluginInvalidProperty: "Plugin $2 specified in $1 provided an invalid property of $3"
};
/**
* Get a message with $0 placeholders replaced by arguments.
*/
/* eslint max-len: 0 */
function get(key) {
/*istanbul ignore next*/
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var msg = MESSAGES[key];
if (!msg) throw new ReferenceError( /*istanbul ignore next*/"Unknown message " + /*istanbul ignore next*/(0, _stringify2.default)(key));
if (!msg) throw new ReferenceError("Unknown message " + (0, _stringify2.default)(key));
// stringify args
args = parseArgs(args);
// replace $0 placeholders with args
return msg.replace(/\$(\d+)/g, function (str, i) {
return args[i - 1];
});
}
/**
* Stingify arguments to be used inside messages.
*/
function parseArgs(args) {
return args.map(function (val) {
if (val != null && val.inspect) {
return val.inspect();
} else {
try {
return (/*istanbul ignore next*/(0, _stringify2.default)(val) || val + ""
);
return (0, _stringify2.default)(val) || val + "";
} catch (e) {
return util.inspect(val);
}

View File

@ -1,6 +1,6 @@
{
"name": "babel-messages",
"version": "6.8.0",
"version": "6.23.0",
"description": "Collection of debug messages used by Babel.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -8,6 +8,6 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-messages",
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.0.0"
"babel-runtime": "^6.22.0"
}
}

View File

@ -2,10 +2,6 @@
exports.__esModule = true;
var _asyncIterator = require("../core-js/symbol/async-iterator");
var _asyncIterator2 = _interopRequireDefault(_asyncIterator);
var _symbol = require("../core-js/symbol");
var _symbol2 = _interopRequireDefault(_symbol);
@ -99,8 +95,8 @@ exports.default = function () {
}
}
if (typeof _symbol2.default === "function" && _asyncIterator2.default) {
AsyncGenerator.prototype[_asyncIterator2.default] = function () {
if (typeof _symbol2.default === "function" && _symbol2.default.asyncIterator) {
AsyncGenerator.prototype[_symbol2.default.asyncIterator] = function () {
return this;
};
}

View File

@ -10,10 +10,6 @@ var _iterator = require("../core-js/symbol/iterator");
var _iterator2 = _interopRequireDefault(_iterator);
var _asyncIterator = require("../core-js/symbol/async-iterator");
var _asyncIterator2 = _interopRequireDefault(_asyncIterator);
var _symbol = require("../core-js/symbol");
var _symbol2 = _interopRequireDefault(_symbol);
@ -22,8 +18,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
exports.default = function (iterable) {
if (typeof _symbol2.default === "function") {
if (_asyncIterator2.default) {
var method = iterable[_asyncIterator2.default];
if (_symbol2.default.asyncIterator) {
var method = iterable[_symbol2.default.asyncIterator];
if (method != null) return method.call(iterable);
}

View File

@ -1,16 +1,16 @@
{
"name": "babel-runtime",
"version": "6.18.0",
"version": "6.23.0",
"description": "babel selfContained runtime",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-runtime",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"dependencies": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.9.5"
"regenerator-runtime": "^0.10.0"
},
"devDependencies": {
"babel-helpers": "^6.6.0",
"babel-plugin-transform-runtime": "^6.9.0"
"babel-helpers": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0"
}
}

View File

@ -7,30 +7,30 @@ In computer science, this is known as an implementation of quasiquotes.
## Install
```sh
$ npm install babel-template
npm install --save-dev babel-template
```
## Usage
```js
import template from 'babel-template';
import generate from 'babel-generator';
import * as t from 'babel-types';
import template from "babel-template";
import generate from "babel-generator";
import * as t from "babel-types";
const buildRequire = template(`
var IMPORT_NAME = require(SOURCE);
`);
const ast = buildRequire({
IMPORT_NAME: t.identifier('myModule'),
SOURCE: t.stringLiteral('my-module')
IMPORT_NAME: t.identifier("myModule"),
SOURCE: t.stringLiteral("my-module")
});
console.log(generate(ast).code);
```
```js
var myModule = require('my-module');
const myModule = require("my-module");
```
## API

View File

@ -87,8 +87,8 @@ var TEMPLATE_SKIP = (0, _symbol2.default)();
function useTemplate(ast, nodes) {
ast = (0, _cloneDeep2.default)(ast);
var _ast = ast;
var program = _ast.program;
var _ast = ast,
program = _ast.program;
if (nodes.length) {

View File

@ -1,6 +1,6 @@
{
"name": "babel-template",
"version": "6.16.0",
"version": "6.24.1",
"description": "Generate an AST from a string template.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -9,9 +9,9 @@
"main": "lib/index.js",
"dependencies": {
"babylon": "^6.11.0",
"babel-traverse": "^6.16.0",
"babel-types": "^6.16.0",
"babel-runtime": "^6.9.0",
"babel-traverse": "^6.24.1",
"babel-types": "^6.24.1",
"babel-runtime": "^6.22.0",
"lodash": "^4.2.0"
}
}

View File

@ -8,6 +8,8 @@ var _weakMap = require("babel-runtime/core-js/weak-map");
var _weakMap2 = _interopRequireDefault(_weakMap);
exports.clear = clear;
exports.clearPath = clearPath;
exports.clearScope = clearScope;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@ -15,6 +17,14 @@ var path = exports.path = new _weakMap2.default();
var scope = exports.scope = new _weakMap2.default();
function clear() {
clearPath();
clearScope();
}
function clearPath() {
exports.path = path = new _weakMap2.default();
}
function clearScope() {
exports.scope = scope = new _weakMap2.default();
}

View File

@ -155,6 +155,9 @@ traverse.clearCache = function () {
cache.clear();
};
traverse.clearCache.clearPath = cache.clearPath;
traverse.clearCache.clearScope = cache.clearScope;
traverse.copyCache = function (source, destination) {
if (cache.path.has(source)) {
cache.path.set(destination, cache.path.get(source));

View File

@ -13,6 +13,8 @@ exports.getStatementParent = getStatementParent;
exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
exports.getAncestry = getAncestry;
exports.isAncestor = isAncestor;
exports.isDescendant = isDescendant;
exports.inType = inType;
exports.inShadow = inShadow;
@ -181,6 +183,16 @@ function getAncestry() {
return paths;
}
function isAncestor(maybeDescendant) {
return maybeDescendant.isDescendant(this);
}
function isDescendant(maybeAncestor) {
return !!this.findParent(function (parent) {
return parent === maybeAncestor;
});
}
function inType() {
var path = this;
while (path) {

View File

@ -5,6 +5,8 @@ exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
exports.addComment = addComment;
exports.addComments = addComments;
function shareCommentsWithSiblings() {
if (typeof this.key === "string") return;
var node = this.node;
if (!node) return;

View File

@ -156,15 +156,19 @@ function evaluate() {
return deopt(binding.path);
}
if (binding && path.node.start < binding.path.node.end) {
return deopt(binding.path);
}
if (binding && binding.hasValue) {
return binding.value;
} else {
if (node.name === "undefined") {
return undefined;
return binding ? deopt(binding.path) : undefined;
} else if (node.name === "Infinity") {
return Infinity;
return binding ? deopt(binding.path) : Infinity;
} else if (node.name === "NaN") {
return NaN;
return binding ? deopt(binding.path) : NaN;
}
var resolved = path.resolve();

View File

@ -2,6 +2,10 @@
exports.__esModule = true;
var _create = require("babel-runtime/core-js/object/create");
var _create2 = _interopRequireDefault(_create);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
@ -10,11 +14,17 @@ exports.getStatementParent = getStatementParent;
exports.getOpposite = getOpposite;
exports.getCompletionRecords = getCompletionRecords;
exports.getSibling = getSibling;
exports.getPrevSibling = getPrevSibling;
exports.getNextSibling = getNextSibling;
exports.getAllNextSiblings = getAllNextSiblings;
exports.getAllPrevSiblings = getAllPrevSiblings;
exports.get = get;
exports._getKey = _getKey;
exports._getPattern = _getPattern;
exports.getBindingIdentifiers = getBindingIdentifiers;
exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers;
exports.getBindingIdentifierPaths = getBindingIdentifierPaths;
exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
var _index = require("./index");
@ -91,6 +101,36 @@ function getSibling(key) {
});
}
function getPrevSibling() {
return this.getSibling(this.key - 1);
}
function getNextSibling() {
return this.getSibling(this.key + 1);
}
function getAllNextSiblings() {
var _key = this.key;
var sibling = this.getSibling(++_key);
var siblings = [];
while (sibling.node) {
siblings.push(sibling);
sibling = this.getSibling(++_key);
}
return siblings;
}
function getAllPrevSiblings() {
var _key = this.key;
var sibling = this.getSibling(--_key);
var siblings = [];
while (sibling.node) {
siblings.push(sibling);
sibling = this.getSibling(--_key);
}
return siblings;
}
function get(key, context) {
if (context === true) context = this.context;
var parts = key.split(".");
@ -162,4 +202,65 @@ function getBindingIdentifiers(duplicates) {
function getOuterBindingIdentifiers(duplicates) {
return t.getOuterBindingIdentifiers(this.node, duplicates);
}
function getBindingIdentifierPaths() {
var duplicates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var outerOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var path = this;
var search = [].concat(path);
var ids = (0, _create2.default)(null);
while (search.length) {
var id = search.shift();
if (!id) continue;
if (!id.node) continue;
var keys = t.getBindingIdentifiers.keys[id.node.type];
if (id.isIdentifier()) {
if (duplicates) {
var _ids = ids[id.node.name] = ids[id.node.name] || [];
_ids.push(id);
} else {
ids[id.node.name] = id;
}
continue;
}
if (id.isExportDeclaration()) {
var declaration = id.get("declaration");
if (declaration.isDeclaration()) {
search.push(declaration);
}
continue;
}
if (outerOnly) {
if (id.isFunctionDeclaration()) {
search.push(id.get("id"));
continue;
}
if (id.isFunctionExpression()) {
continue;
}
}
if (keys) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var child = id.get(key);
if (Array.isArray(child) || child.node) {
search = search.concat(child);
}
}
}
}
return ids;
}
function getOuterBindingIdentifierPaths(duplicates) {
return this.getBindingIdentifierPaths(duplicates, true);
}

View File

@ -74,12 +74,12 @@ var NodePath = function () {
}
NodePath.get = function get(_ref) {
var hub = _ref.hub;
var parentPath = _ref.parentPath;
var parent = _ref.parent;
var container = _ref.container;
var listKey = _ref.listKey;
var key = _ref.key;
var hub = _ref.hub,
parentPath = _ref.parentPath,
parent = _ref.parent,
container = _ref.container,
listKey = _ref.listKey,
key = _ref.key;
if (!hub && parentPath) {
hub = parentPath.hub;

View File

@ -44,15 +44,13 @@ function getTypeAnnotationBindingConstantViolations(path, name) {
var testType = getConditionalAnnotation(path, name);
if (testType) {
(function () {
var testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement);
var testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement);
constantViolations = constantViolations.filter(function (path) {
return testConstantViolations.indexOf(path) < 0;
});
constantViolations = constantViolations.filter(function (path) {
return testConstantViolations.indexOf(path) < 0;
});
types.push(testType.typeAnnotation);
})();
types.push(testType.typeAnnotation);
}
if (constantViolations.length) {

View File

@ -3,10 +3,6 @@
exports.__esModule = true;
exports.is = undefined;
var _typeof2 = require("babel-runtime/helpers/typeof");
var _typeof3 = _interopRequireDefault(_typeof2);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
@ -319,8 +315,6 @@ function resolve(dangerous, resolved) {
}
function _resolve(dangerous, resolved) {
var _this = this;
if (resolved && resolved.indexOf(this) >= 0) return;
resolved = resolved || [];
@ -339,20 +333,12 @@ function _resolve(dangerous, resolved) {
if (binding.kind === "module") return;
if (binding.path !== this) {
var _ret = function () {
var ret = binding.path.resolve(dangerous, resolved);
var ret = binding.path.resolve(dangerous, resolved);
if (_this.find(function (parent) {
return parent.node === ret.node;
})) return {
v: void 0
};
return {
v: ret
};
}();
if ((typeof _ret === "undefined" ? "undefined" : (0, _typeof3.default)(_ret)) === "object") return _ret.v;
if (this.find(function (parent) {
return parent.node === ret.node;
})) return;
return ret;
}
} else if (this.isTypeCastExpression()) {
return this.get("expression").resolve(dangerous, resolved);

View File

@ -2,14 +2,14 @@
exports.__esModule = true;
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
@ -20,35 +20,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var referenceVisitor = {
ReferencedIdentifier: function ReferencedIdentifier(path, state) {
if (path.isJSXIdentifier() && _babelTypes.react.isCompatTag(path.node.name)) {
if (path.isJSXIdentifier() && _babelTypes.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
return;
}
if (path.node.name === "this") {
var scope = path.scope;
do {
if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) break;
} while (scope = scope.parent);
if (scope) state.breakOnScopePaths.push(scope.path);
}
var binding = path.scope.getBinding(path.node.name);
if (!binding) return;
if (binding !== state.scope.getBinding(path.node.name)) return;
if (binding.constant) {
state.bindings[path.node.name] = binding;
} else {
for (var _iterator = binding.constantViolations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var violationPath = _ref;
state.breakOnScopePaths = state.breakOnScopePaths.concat(violationPath.getAncestry());
}
}
state.bindings[path.node.name] = binding;
}
};
@ -57,10 +46,15 @@ var PathHoister = function () {
(0, _classCallCheck3.default)(this, PathHoister);
this.breakOnScopePaths = [];
this.bindings = {};
this.scopes = [];
this.scope = scope;
this.path = path;
this.attachAfter = false;
}
PathHoister.prototype.isCompatibleScope = function isCompatibleScope(scope) {
@ -107,7 +101,29 @@ var PathHoister = function () {
if (binding.kind === "param") continue;
if (binding.path.getStatementParent().key > path.key) return;
if (this.getAttachmentParentForPath(binding.path).key > path.key) {
this.attachAfter = true;
path = binding.path;
for (var _iterator = binding.constantViolations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var violationPath = _ref;
if (this.getAttachmentParentForPath(violationPath).key > path.key) {
path = violationPath;
}
}
}
}
}
@ -118,6 +134,7 @@ var PathHoister = function () {
var scopes = this.scopes;
var scope = scopes.pop();
if (!scope) return;
if (scope.path.isFunction()) {
@ -126,16 +143,22 @@ var PathHoister = function () {
return scope.path.get("body").get("body")[0];
} else {
return this.getNextScopeStatementParent();
return this.getNextScopeAttachmentParent();
}
} else if (scope.path.isProgram()) {
return this.getNextScopeStatementParent();
return this.getNextScopeAttachmentParent();
}
};
PathHoister.prototype.getNextScopeStatementParent = function getNextScopeStatementParent() {
PathHoister.prototype.getNextScopeAttachmentParent = function getNextScopeAttachmentParent() {
var scope = this.scopes.pop();
if (scope) return scope.path.getStatementParent();
if (scope) return this.getAttachmentParentForPath(scope.path);
};
PathHoister.prototype.getAttachmentParentForPath = function getAttachmentParentForPath(path) {
do {
if (!path.parentPath || Array.isArray(path.container) && path.isStatement() || path.isVariableDeclarator() && path.parentPath.node !== null && path.parentPath.node.declarations.length > 1) return path;
} while (path = path.parentPath);
};
PathHoister.prototype.hasOwnParamBindings = function hasOwnParamBindings(scope) {
@ -143,7 +166,8 @@ var PathHoister = function () {
if (!scope.hasOwnBinding(name)) continue;
var binding = this.bindings[name];
if (binding.kind === "param") return true;
if (binding.kind === "param" && binding.constant) return true;
}
return false;
};
@ -163,7 +187,10 @@ var PathHoister = function () {
if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
var uid = attachTo.scope.generateUidIdentifier("ref");
attachTo.insertBefore([t.variableDeclaration("var", [t.variableDeclarator(uid, this.path.node)])]);
var declarator = t.variableDeclarator(uid, this.path.node);
var insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])]);
var parent = this.path.parentPath;
if (parent.isJSXElement() && this.path.container === parent.node.children) {

View File

@ -2,22 +2,7 @@
exports.__esModule = true;
var hooks = exports.hooks = [function (self, parent) {
if (self.key === "body" && parent.isArrowFunctionExpression()) {
self.replaceWith(self.scope.buildUndefinedNode());
return true;
}
}, function (self, parent) {
var removeParent = false;
removeParent = removeParent || self.key === "test" && (parent.isWhile() || parent.isSwitchCase());
removeParent = removeParent || self.key === "declaration" && parent.isExportDeclaration();
removeParent = removeParent || self.key === "body" && parent.isLabeledStatement();
removeParent = removeParent || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1;
removeParent = removeParent || self.key === "expression" && parent.isExpressionStatement();
var removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
if (removeParent) {
parent.remove();
@ -38,9 +23,9 @@ var hooks = exports.hooks = [function (self, parent) {
return true;
}
}, function (self, parent) {
if (parent.isIfStatement() && (self.key === 'consequent' || self.key === 'alternate') || parent.isLoop() && self.key === 'body') {
if (parent.isIfStatement() && (self.key === "consequent" || self.key === "alternate") || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) {
self.replaceWith({
type: 'BlockStatement',
type: "BlockStatement",
body: []
});
return true;

View File

@ -12,8 +12,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
var ReferencedIdentifier = exports.ReferencedIdentifier = {
types: ["Identifier", "JSXIdentifier"],
checkPath: function checkPath(_ref, opts) {
var node = _ref.node;
var parent = _ref.parent;
var node = _ref.node,
parent = _ref.parent;
if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) {
if (t.isJSXIdentifier(node, opts)) {
@ -30,8 +30,8 @@ var ReferencedIdentifier = exports.ReferencedIdentifier = {
var ReferencedMemberExpression = exports.ReferencedMemberExpression = {
types: ["MemberExpression"],
checkPath: function checkPath(_ref2) {
var node = _ref2.node;
var parent = _ref2.parent;
var node = _ref2.node,
parent = _ref2.parent;
return t.isMemberExpression(node) && t.isReferenced(node, parent);
}
@ -40,8 +40,8 @@ var ReferencedMemberExpression = exports.ReferencedMemberExpression = {
var BindingIdentifier = exports.BindingIdentifier = {
types: ["Identifier"],
checkPath: function checkPath(_ref3) {
var node = _ref3.node;
var parent = _ref3.parent;
var node = _ref3.node,
parent = _ref3.parent;
return t.isIdentifier(node) && t.isBinding(node, parent);
}
@ -50,8 +50,8 @@ var BindingIdentifier = exports.BindingIdentifier = {
var Statement = exports.Statement = {
types: ["Statement"],
checkPath: function checkPath(_ref4) {
var node = _ref4.node;
var parent = _ref4.parent;
var node = _ref4.node,
parent = _ref4.parent;
if (t.isStatement(node)) {
if (t.isVariableDeclaration(node)) {
@ -122,7 +122,7 @@ var Pure = exports.Pure = {
};
var Flow = exports.Flow = {
types: ["Flow", "ImportDeclaration", "ExportDeclaration"],
types: ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"],
checkPath: function checkPath(_ref5) {
var node = _ref5.node;
@ -132,6 +132,8 @@ var Flow = exports.Flow = {
return node.importKind === "type" || node.importKind === "typeof";
} else if (t.isExportDeclaration(node)) {
return node.exportKind === "type";
} else if (t.isImportSpecifier(node)) {
return node.importKind === "type" || node.importKind === "typeof";
} else {
return false;
}

View File

@ -58,7 +58,7 @@ function insertBefore(nodes) {
if (this.node) nodes.push(this.node);
this._replaceWith(t.blockStatement(nodes));
} else {
throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
}
}
@ -172,7 +172,7 @@ function insertAfter(nodes) {
if (this.node) nodes.unshift(this.node);
this._replaceWith(t.blockStatement(nodes));
} else {
throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
}
}

View File

@ -230,10 +230,16 @@ function replaceExpressionWithStatements(nodes) {
return path.isLoop();
});
if (loop) {
var callee = this.get("callee");
var uid = loop.getData("expressionReplacementReturnUid");
var uid = callee.scope.generateDeclaredUidIdentifier("ret");
callee.get("body").pushContainer("body", t.returnStatement(uid));
if (!uid) {
var callee = this.get("callee");
uid = callee.scope.generateDeclaredUidIdentifier("ret");
callee.get("body").pushContainer("body", t.returnStatement(uid));
loop.setData("expressionReplacementReturnUid", uid);
} else {
uid = t.identifier(uid.name);
}
path.get("expression").replaceWith(t.assignmentExpression("=", uid, path.node.expression));
} else {

View File

@ -10,11 +10,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var Binding = function () {
function Binding(_ref) {
var existing = _ref.existing;
var identifier = _ref.identifier;
var scope = _ref.scope;
var path = _ref.path;
var kind = _ref.kind;
var existing = _ref.existing,
identifier = _ref.identifier,
scope = _ref.scope,
path = _ref.path,
kind = _ref.kind;
(0, _classCallCheck3.default)(this, Binding);
this.identifier = identifier;

View File

@ -93,21 +93,76 @@ function getCache(path, parentScope, self) {
}
}
var collectorVisitor = {
For: function For(path) {
for (var _iterator2 = t.FOR_INIT_KEYS, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
function gatherNodeParts(node, parts) {
if (t.isModuleDeclaration(node)) {
if (node.source) {
gatherNodeParts(node.source, parts);
} else if (node.specifiers && node.specifiers.length) {
for (var _iterator2 = node.specifiers, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var specifier = _ref2;
gatherNodeParts(specifier, parts);
}
} else if (node.declaration) {
gatherNodeParts(node.declaration, parts);
}
} else if (t.isModuleSpecifier(node)) {
gatherNodeParts(node.local, parts);
} else if (t.isMemberExpression(node)) {
gatherNodeParts(node.object, parts);
gatherNodeParts(node.property, parts);
} else if (t.isIdentifier(node)) {
parts.push(node.name);
} else if (t.isLiteral(node)) {
parts.push(node.value);
} else if (t.isCallExpression(node)) {
gatherNodeParts(node.callee, parts);
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
for (var _iterator3 = node.properties, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) {
var _ref3;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
}
var key = _ref2;
var prop = _ref3;
gatherNodeParts(prop.key || prop.argument, parts);
}
}
}
var collectorVisitor = {
For: function For(path) {
for (var _iterator4 = t.FOR_INIT_KEYS, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) {
var _ref4;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
}
var key = _ref4;
var declar = path.get(key);
if (declar.isVar()) path.scope.getFunctionParent().registerBinding("var", declar);
@ -133,8 +188,8 @@ var collectorVisitor = {
ExportDeclaration: {
exit: function exit(path) {
var node = path.node;
var scope = path.scope;
var node = path.node,
scope = path.scope;
var declar = node.declaration;
if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
@ -144,19 +199,19 @@ var collectorVisitor = {
var binding = scope.getBinding(_id.name);
if (binding) binding.reference(path);
} else if (t.isVariableDeclaration(declar)) {
for (var _iterator3 = declar.declarations, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) {
var _ref3;
for (var _iterator5 = declar.declarations, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) {
var _ref5;
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref5 = _iterator5[_i5++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
_i5 = _iterator5.next();
if (_i5.done) break;
_ref5 = _i5.value;
}
var decl = _ref3;
var decl = _ref5;
var ids = t.getBindingIdentifiers(decl);
for (var name in ids) {
@ -197,19 +252,19 @@ var collectorVisitor = {
},
Block: function Block(path) {
var paths = path.get("body");
for (var _iterator4 = paths, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) {
var _ref4;
for (var _iterator6 = paths, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : (0, _getIterator3.default)(_iterator6);;) {
var _ref6;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
if (_isArray6) {
if (_i6 >= _iterator6.length) break;
_ref6 = _iterator6[_i6++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
_i6 = _iterator6.next();
if (_i6.done) break;
_ref6 = _i6.value;
}
var bodyPath = _ref4;
var bodyPath = _ref6;
if (bodyPath.isFunctionDeclaration()) {
path.scope.getBlockParent().registerDeclaration(bodyPath);
@ -297,63 +352,7 @@ var Scope = function () {
}
var parts = [];
var add = function add(node) {
if (t.isModuleDeclaration(node)) {
if (node.source) {
add(node.source);
} else if (node.specifiers && node.specifiers.length) {
for (var _iterator5 = node.specifiers, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) {
var _ref5;
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref5 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref5 = _i5.value;
}
var specifier = _ref5;
add(specifier);
}
} else if (node.declaration) {
add(node.declaration);
}
} else if (t.isModuleSpecifier(node)) {
add(node.local);
} else if (t.isMemberExpression(node)) {
add(node.object);
add(node.property);
} else if (t.isIdentifier(node)) {
parts.push(node.name);
} else if (t.isLiteral(node)) {
parts.push(node.value);
} else if (t.isCallExpression(node)) {
add(node.callee);
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
for (var _iterator6 = node.properties, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : (0, _getIterator3.default)(_iterator6);;) {
var _ref6;
if (_isArray6) {
if (_i6 >= _iterator6.length) break;
_ref6 = _iterator6[_i6++];
} else {
_i6 = _iterator6.next();
if (_i6.done) break;
_ref6 = _i6.value;
}
var prop = _ref6;
add(prop.key || prop.argument);
}
}
};
add(node);
gatherNodeParts(node, parts);
var id = parts.join("$");
id = id.replace(/^_/, "") || defaultName || "ref";
@ -393,11 +392,7 @@ var Scope = function () {
if (kind === "hoisted" && local.kind === "let") return;
var duplicate = false;
if (!duplicate) duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module";
if (!duplicate) duplicate = local.kind === "param" && (kind === "let" || kind === "const");
var duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && (kind === "let" || kind === "const");
if (duplicate) {
throw this.hub.file.buildCodeFrameError(id, messages.get("scopeDuplicateDeclaration", name), TypeError);

View File

@ -108,11 +108,11 @@ var Renamer = function () {
};
Renamer.prototype.rename = function rename(block) {
var binding = this.binding;
var oldName = this.oldName;
var newName = this.newName;
var scope = binding.scope;
var path = binding.path;
var binding = this.binding,
oldName = this.oldName,
newName = this.newName;
var scope = binding.scope,
path = binding.path;
var parentDeclar = path.find(function (path) {

View File

@ -1,6 +1,6 @@
{
"name": "babel-traverse",
"version": "6.18.0",
"version": "6.24.1",
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -8,14 +8,17 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
"main": "lib/index.js",
"dependencies": {
"babel-code-frame": "^6.16.0",
"babel-messages": "^6.8.0",
"babel-runtime": "^6.9.0",
"babel-types": "^6.18.0",
"babylon": "^6.11.0",
"babel-code-frame": "^6.22.0",
"babel-messages": "^6.23.0",
"babel-runtime": "^6.22.0",
"babel-types": "^6.24.1",
"babylon": "^6.15.0",
"debug": "^2.2.0",
"globals": "^9.0.0",
"invariant": "^2.2.0",
"lodash": "^4.2.0"
},
"devDependencies": {
"babel-generator": "^6.24.1"
}
}

1009
node_modules/babel-types/README.md generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -28,18 +28,10 @@ var _isPlainObject = require("lodash/isPlainObject");
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
var _isNumber = require("lodash/isNumber");
var _isNumber2 = _interopRequireDefault(_isNumber);
var _isRegExp = require("lodash/isRegExp");
var _isRegExp2 = _interopRequireDefault(_isRegExp);
var _isString = require("lodash/isString");
var _isString2 = _interopRequireDefault(_isString);
var _index = require("./index");
var t = _interopRequireWildcard(_index);
@ -310,11 +302,11 @@ function valueToNode(value) {
return t.nullLiteral();
}
if ((0, _isString2.default)(value)) {
if (typeof value === "string") {
return t.stringLiteral(value);
}
if ((0, _isNumber2.default)(value)) {
if (typeof value === "number") {
return t.numericLiteral(value);
}

View File

@ -213,6 +213,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
},
imported: {
validate: (0, _index.assertNodeType)("Identifier")
},
importKind: {
validate: (0, _index.assertOneOf)(null, "type", "typeof")
}
}
});

View File

@ -39,6 +39,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
fields: {}
});
(0, _index2.default)("Import", {
aliases: ["Expression"]
});
(0, _index2.default)("Decorator", {
visitor: ["expression"],
fields: {

View File

@ -43,7 +43,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
validate: (0, _index.assertNodeType)("JSXClosingElement")
},
children: {
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXElement")))
validate: (0, _index.chain)((0, _index.assertValueType)("array"), (0, _index.assertEach)((0, _index.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement")))
}
}
});
@ -62,6 +62,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
}
});
(0, _index2.default)("JSXSpreadChild", {
visitor: ["expression"],
aliases: ["JSX", "Immutable"],
fields: {
expression: {
validate: (0, _index.assertNodeType)("Expression")
}
}
});
(0, _index2.default)("JSXIdentifier", {
builder: ["name"],
aliases: ["JSX", "Expression"],

View File

@ -1,7 +1,7 @@
"use strict";
exports.__esModule = true;
exports.createTypeAnnotationBasedOnTypeof = exports.removeTypeDuplicates = exports.createUnionTypeAnnotation = exports.valueToNode = exports.toBlock = exports.toExpression = exports.toStatement = exports.toBindingIdentifierName = exports.toIdentifier = exports.toKeyAlias = exports.toSequenceExpression = exports.toComputedKey = exports.isImmutable = exports.isScope = exports.isSpecifierDefault = exports.isVar = exports.isBlockScoped = exports.isLet = exports.isValidIdentifier = exports.isReferenced = exports.isBinding = exports.getOuterBindingIdentifiers = exports.getBindingIdentifiers = exports.TYPES = exports.react = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = undefined;
exports.createTypeAnnotationBasedOnTypeof = exports.removeTypeDuplicates = exports.createUnionTypeAnnotation = exports.valueToNode = exports.toBlock = exports.toExpression = exports.toStatement = exports.toBindingIdentifierName = exports.toIdentifier = exports.toKeyAlias = exports.toSequenceExpression = exports.toComputedKey = exports.isNodesEquivalent = exports.isImmutable = exports.isScope = exports.isSpecifierDefault = exports.isVar = exports.isBlockScoped = exports.isLet = exports.isValidIdentifier = exports.isReferenced = exports.isBinding = exports.getOuterBindingIdentifiers = exports.getBindingIdentifiers = exports.TYPES = exports.react = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = undefined;
var _getOwnPropertySymbols = require("babel-runtime/core-js/object/get-own-property-symbols");
@ -229,6 +229,12 @@ Object.defineProperty(exports, "isImmutable", {
return _validators.isImmutable;
}
});
Object.defineProperty(exports, "isNodesEquivalent", {
enumerable: true,
get: function get() {
return _validators.isNodesEquivalent;
}
});
var _converters = require("./converters");
@ -312,18 +318,10 @@ var _toFastProperties = require("to-fast-properties");
var _toFastProperties2 = _interopRequireDefault(_toFastProperties);
var _compact = require("lodash/compact");
var _compact2 = _interopRequireDefault(_compact);
var _clone = require("lodash/clone");
var _clone2 = _interopRequireDefault(_clone);
var _each = require("lodash/each");
var _each2 = _interopRequireDefault(_each);
var _uniq = require("lodash/uniq");
var _uniq2 = _interopRequireDefault(_uniq);
@ -372,15 +370,15 @@ for (var type in t.VISITOR_KEYS) {
t.FLIPPED_ALIAS_KEYS = {};
(0, _each2.default)(t.ALIAS_KEYS, function (aliases, type) {
(0, _each2.default)(aliases, function (alias) {
(0, _keys2.default)(t.ALIAS_KEYS).forEach(function (type) {
t.ALIAS_KEYS[type].forEach(function (alias) {
var types = t.FLIPPED_ALIAS_KEYS[alias] = t.FLIPPED_ALIAS_KEYS[alias] || [];
types.push(type);
});
});
(0, _each2.default)(t.FLIPPED_ALIAS_KEYS, function (types, type) {
t[type.toUpperCase() + "_TYPES"] = types;
(0, _keys2.default)(t.FLIPPED_ALIAS_KEYS).forEach(function (type) {
t[type.toUpperCase() + "_TYPES"] = t.FLIPPED_ALIAS_KEYS[type];
registerType(type);
});
@ -429,7 +427,9 @@ function isType(nodeType, targetType) {
return false;
}
(0, _each2.default)(t.BUILDER_KEYS, function (keys, type) {
(0, _keys2.default)(t.BUILDER_KEYS).forEach(function (type) {
var keys = t.BUILDER_KEYS[type];
function builder() {
if (arguments.length > keys.length) {
throw new Error("t." + type + ": Too many arguments passed. Received " + arguments.length + " but can receive " + ("no more than " + keys.length));
@ -549,6 +549,7 @@ function ensureBlock(node) {
}
function clone(node) {
if (!node) return node;
var newNode = {};
for (var key in node) {
if (key[0] === "_") continue;
@ -564,6 +565,7 @@ function cloneWithoutLoc(node) {
}
function cloneDeep(node) {
if (!node) return node;
var newNode = {};
for (var key in node) {
@ -667,7 +669,7 @@ function inheritInnerComments(child, parent) {
function _inheritComments(key, child, parent) {
if (child && parent) {
child[key] = (0, _uniq2.default)((0, _compact2.default)([].concat(child[key], parent[key])));
child[key] = (0, _uniq2.default)([].concat(child[key], parent[key]).filter(Boolean));
}
}

View File

@ -38,8 +38,8 @@ function getBindingIdentifiers(node, duplicates, outerOnly) {
}
if (t.isExportDeclaration(id)) {
if (t.isDeclaration(node.declaration)) {
search.push(node.declaration);
if (t.isDeclaration(id.declaration)) {
search.push(id.declaration);
}
continue;
}

View File

@ -2,6 +2,14 @@
exports.__esModule = true;
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _typeof2 = require("babel-runtime/helpers/typeof");
var _typeof3 = _interopRequireDefault(_typeof2);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
@ -15,6 +23,7 @@ exports.isVar = isVar;
exports.isSpecifierDefault = isSpecifierDefault;
exports.isScope = isScope;
exports.isImmutable = isImmutable;
exports.isNodesEquivalent = isNodesEquivalent;
var _retrievers = require("./retrievers");
@ -157,6 +166,8 @@ function isReferenced(node, parent) {
function isValidIdentifier(name) {
if (typeof name !== "string" || _esutils2.default.keyword.isReservedWordES6(name, true)) {
return false;
} else if (name === "await") {
return false;
} else {
return _esutils2.default.keyword.isIdentifierNameES6(name);
}
@ -198,4 +209,57 @@ function isImmutable(node) {
}
return false;
}
function isNodesEquivalent(a, b) {
if ((typeof a === "undefined" ? "undefined" : (0, _typeof3.default)(a)) !== "object" || (typeof a === "undefined" ? "undefined" : (0, _typeof3.default)(a)) !== "object" || a == null || b == null) {
return a === b;
}
if (a.type !== b.type) {
return false;
}
var fields = (0, _keys2.default)(t.NODE_FIELDS[a.type] || a.type);
for (var _iterator2 = fields, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}
var field = _ref2;
if ((0, _typeof3.default)(a[field]) !== (0, _typeof3.default)(b[field])) {
return false;
}
if (Array.isArray(a[field])) {
if (!Array.isArray(b[field])) {
return false;
}
if (a[field].length !== b[field].length) {
return false;
}
for (var i = 0; i < a[field].length; i++) {
if (!isNodesEquivalent(a[field][i], b[field][i])) {
return false;
}
}
continue;
}
if (!isNodesEquivalent(a[field], b[field])) {
return false;
}
}
return true;
}

View File

@ -1,6 +1,6 @@
{
"name": "babel-types",
"version": "6.18.0",
"version": "6.24.1",
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -8,9 +8,12 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-types",
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.9.1",
"babel-runtime": "^6.22.0",
"esutils": "^2.0.2",
"lodash": "^4.2.0",
"to-fast-properties": "^1.0.1"
},
"devDependencies": {
"babylon": "^6.8.2"
}
}

327
node_modules/babylon/CHANGELOG.md generated vendored
View File

@ -15,10 +15,331 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) for the pre-6.8.0 version Changelog.
## 6.16.0 (2017-02-23)
### :rocket: New Feature
***ESTree*** compatibility as plugin ([#277](https://github.com/babel/babylon/pull/277)) (Daniel Tschinder)
We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/)
We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc.
To enable `estree` mode simply add the plugin in the config:
```json
{
"plugins": [ "estree" ]
}
```
If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned.
Add a parseExpression public method ([#213](https://github.com/babel/babylon/pull/213)) (jeromew)
Babylon exports a new function to parse a single expression
```js
import { parseExpression } from 'babylon';
const ast = parseExpression('x || y && z', options);
```
The returned AST will only consist of the expression. The options are the same as for `parse()`
Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu)
A new option was added to babylon allowing to change the intial linenumber for the first line which is usually `1`.
Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ...
Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris)
Added support for function predicates which flow introduced in version 0.33.0
```js
declare function is_number(x: mixed): boolean %checks(typeof x === "number");
```
Allow imports in declare module ([#315](https://github.com/babel/babylon/pull/315)) (Daniel Tschinder)
Added support for imports within module declarations which flow introduced in version 0.37.0
```js
declare module "C" {
import type { DT } from "D";
declare export type CT = { D: DT };
}
```
### :eyeglasses: Spec Compliancy
Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
This example now correctly throws an error when there is a semicolon after the decorator:
```js
class A {
@a;
foo(){}
}
```
Keywords are not allowed as local specifier ([#307](https://github.com/babel/babylon/pull/307)) (Daniel Tschinder)
Using keywords in imports is not allowed anymore:
```js
import { default } from "foo";
import { a as debugger } from "foo";
```
Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder)
In flow it is now forbidden to overwrite the primitve types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder)
The following code now correctly throws an error
```js
import type { type a } from "foo";
```
Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([#300](https://github.com/babel/babylon/pull/300)) (Andrew Levine)
Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour.
If you enable the flow plugin you can only define the type of the class properties, but not initialize them.
Fix export default async function to be FunctionDeclaration ([#324](https://github.com/babel/babylon/pull/324)) (Daniel Tschinder)
Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`.
```js
export default async function bar() {};
```
### :nail_care: Polish
Improve error message on attempt to destructure named import ([#288](https://github.com/babel/babylon/pull/288)) (Brian Ng)
### :bug: Bug Fix
Fix negative number literal typeannotations ([#366](https://github.com/babel/babylon/pull/366)) (Daniel Tschinder)
Ensure takeDecorators is called on exported class ([#358](https://github.com/babel/babylon/pull/358)) (Brian Ng)
ESTree: correctly change literals in all cases ([#368](https://github.com/babel/babylon/pull/368)) (Daniel Tschinder)
Correctly convert RestProperty to Assignable ([#339](https://github.com/babel/babylon/pull/339)) (Daniel Tschinder)
Fix #321 by allowing question marks in type params ([#338](https://github.com/babel/babylon/pull/338)) (Daniel Tschinder)
Fix #336 by correctly setting arrow-param ([#337](https://github.com/babel/babylon/pull/337)) (Daniel Tschinder)
Fix parse error when destructuring `set` with default value ([#317](https://github.com/babel/babylon/pull/317)) (Brian Ng)
Fix ObjectTypeCallProperty static ([#298](https://github.com/babel/babylon/pull/298)) (Dan Harper)
### :house: Internal
Fix generator-method-with-computed-name spec ([#360](https://github.com/babel/babylon/pull/360)) (Alex Rattray)
Fix flow type-parameter-declaration test with unintended semantic ([#361](https://github.com/babel/babylon/pull/361)) (Alex Rattray)
Cleanup and splitup parser functions ([#295](https://github.com/babel/babylon/pull/295)) (Daniel Tschinder)
chore(package): update flow-bin to version 0.38.0 ([#313](https://github.com/babel/babylon/pull/313)) (greenkeeper[bot])
Call inner function instead of 1:1 copy to plugin ([#294](https://github.com/babel/babylon/pull/294)) (Daniel Tschinder)
Update eslint-config-babel to the latest version 🚀 ([#299](https://github.com/babel/babylon/pull/299)) (greenkeeper[bot])
Update eslint-config-babel to the latest version 🚀 ([#293](https://github.com/babel/babylon/pull/293)) (greenkeeper[bot])
devDeps: remove eslint-plugin-babel ([#292](https://github.com/babel/babylon/pull/292)) (Kai Cataldo)
Correct indent eslint rule config ([#276](https://github.com/babel/babylon/pull/276)) (Daniel Tschinder)
Fail tests that have expected.json and throws-option ([#285](https://github.com/babel/babylon/pull/285)) (Daniel Tschinder)
### :memo: Documentation
Update contributing with more test info [skip ci] ([#355](https://github.com/babel/babylon/pull/355)) (Brian Ng)
Update API documentation ([#330](https://github.com/babel/babylon/pull/330)) (Timothy Gu)
Added keywords to package.json ([#323](https://github.com/babel/babylon/pull/323)) (Dmytro)
AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon/pull/318)) (Mathias Bynens)
## 6.15.0 (2017-01-10)
### :eyeglasses: Spec Compliancy
Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison)
This change implements flows new shorthand import syntax
and where previously you had to write this code:
```js
import {someValue} from "blah";
import type {someType} from "blah";
import typeof {someOtherValue} from "blah";
```
you can now write it like this:
```js
import {
someValue,
type someType,
typeof someOtherValue,
} from "blah";
```
For more information look at [this](https://github.com/facebook/flow/pull/2890) pull request.
flow: allow leading pipes in all positions ([#256](https://github.com/babel/babylon/pull/256)) (Vladimir Kurchatkin)
This change now allows a leading pipe everywhere types can be used:
```js
var f = (x): | 1 | 2 => 1;
```
Throw error when exporting non-declaration ([#241](https://github.com/babel/babylon/pull/241)) (Kai Cataldo)
Previously babylon parsed the following exports, although they are not valid:
```js
export typeof foo;
export new Foo();
export function() {};
export for (;;);
export while(foo);
```
### :bug: Bug Fix
Don't set inType flag when parsing property names ([#266](https://github.com/babel/babylon/pull/266)) (Vladimir Kurchatkin)
This fixes parsing of this case:
```js
const map = {
[age <= 17] : 'Too young'
};
```
Fix source location for JSXEmptyExpression nodes (fixes #248) ([#249](https://github.com/babel/babylon/pull/249)) (James Long)
The following case produced an invalid AST
```js
<div>{/* foo */}</div>
```
Use fromCodePoint to convert high value unicode entities ([#243](https://github.com/babel/babylon/pull/243)) (Ryan Duffy)
When high value unicode entities (e.g. 💩) were used in the input source code they are now correctly encoded in the resulting AST.
Rename folder to avoid Windows-illegal characters ([#281](https://github.com/babel/babylon/pull/281)) (Ryan Plant)
Allow this.state.clone() when parsing decorators ([#262](https://github.com/babel/babylon/pull/262)) (Alex Rattray)
### :house: Internal
User external-helpers ([#254](https://github.com/babel/babylon/pull/254)) (Daniel Tschinder)
Add watch script for dev ([#234](https://github.com/babel/babylon/pull/234)) (Kai Cataldo)
Freeze current plugins list for "*" option, and remove from README.md ([#245](https://github.com/babel/babylon/pull/245)) (Andrew Levine)
Prepare tests for multiple fixture runners. ([#240](https://github.com/babel/babylon/pull/240)) (Daniel Tschinder)
Add some test coverage for decorators stage-0 plugin ([#250](https://github.com/babel/babylon/pull/250)) (Andrew Levine)
Refactor tokenizer types file ([#263](https://github.com/babel/babylon/pull/263)) (Sven SAULEAU)
Update eslint-config-babel to the latest version 🚀 ([#273](https://github.com/babel/babylon/pull/273)) (greenkeeper[bot])
chore(package): update rollup to version 0.41.0 ([#272](https://github.com/babel/babylon/pull/272)) (greenkeeper[bot])
chore(package): update flow-bin to version 0.37.0 ([#255](https://github.com/babel/babylon/pull/255)) (greenkeeper[bot])
## 6.14.1 (2016-11-17)
### :bug: Bug Fix
Allow `"plugins": ["*"]` ([#229](https://github.com/babel/babylon/pull/229)) (Daniel Tschinder)
```js
{
"plugins": ["*"]
}
```
Will include all parser plugins instead of specifying each one individually. Useful for tools like babel-eslint, jscodeshift, and ast-explorer.
## 6.14.0 (2016-11-16)
### :eyeglasses: Spec Compliancy
Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo)
[11.6.2.2 Future Reserved Words](http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words)
Babylon will throw for more reserved words such as `enum` or `await` (in strict mode).
```
class enum {} // throws
class await {} // throws in strict mode (module)
```
Optional names for function types and object type indexers ([#197](https://github.com/babel/babylon/pull/197)) (Gabe Levi)
So where you used to have to write
```js
type A = (x: string, y: boolean) => number;
type B = (z: string) => number;
type C = { [key: string]: number };
```
you can now write (with flow 0.34.0)
```js
type A = (string, boolean) => number;
type B = string => number;
type C = { [string]: number };
```
Parse flow nested array type annotations like `number[][]` ([#219](https://github.com/babel/babylon/pull/219)) (Bernhard Häussner)
Supports these form now of specifying array types:
```js
var a: number[][][][];
var b: string[][];
```
### :bug: Bug Fix
Correctly eat semicolon at the end of `DelcareModuleExports` ([#223](https://github.com/babel/babylon/pull/223)) (Daniel Tschinder)
```
declare module "foo" { declare module.exports: number }
declare module "foo" { declare module.exports: number; } // also allowed now
```
### :house: Internal
* Count Babel tests towards Babylon code coverage ([#182](https://github.com/babel/babylon/pull/182)) (Moti Zilberman)
* Fix strange line endings ([#214](https://github.com/babel/babylon/pull/214)) (Thomas Grainger)
* Add node 7 (Daniel Tschinder)
* chore(package): update flow-bin to version 0.34.0 ([#204](https://github.com/babel/babylon/pull/204)) (Greenkeeper)
## v6.13.1 (2016-10-26)
### 💅 Polish
### :nail_care: Polish
- Use rollup for bundling to speed up startup time ([#190](https://github.com/babel/babylon/pull/190)) ([@drewml](https://github.com/DrewML))
@ -40,7 +361,7 @@ With that test case, there was a ~95ms savings by removing the need for node to
## v6.13.0 (2016-10-21)
### 👓 Spec Compliancy
### :eyeglasses: Spec Compliancy
Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman)
@ -98,7 +419,7 @@ Fixes two tests that are failing after the merge of #172 ([#177](https://github.
## v6.12.0 (2016-10-14)
### 👓 Spec Compliancy
### :eyeglasses: Spec Compliancy
Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler)

16
node_modules/babylon/README.md generated vendored
View File

@ -14,7 +14,7 @@
- The latest ECMAScript version enabled by default (ES2017).
- Comment attachment.
- Support for JSX and Flow.
- Support for experimental language proposals (accepting PRs for anything at least [stage-0](https://github.com/tc39/proposals/blob/master/stage-0-proposals.md).
- Support for experimental language proposals (accepting PRs for anything at least [stage-0](https://github.com/tc39/proposals/blob/master/stage-0-proposals.md)).
## Credits
@ -27,6 +27,12 @@ Significant diversions are expected to occur in the future such as streaming, EB
### `babylon.parse(code, [options])`
### `babylon.parseExpression(code, [options])`
`parse()` parses the provided `code` as an entire ECMAScript program, while
`parseExpression()` tries to parse a single Expression with performance in
mind. When in doubt, use `.parse()`.
### Options
- **allowImportExportEverywhere**: By default, `import` and `export`
@ -37,15 +43,19 @@ Significant diversions are expected to occur in the future such as streaming, EB
the top level raises an error. Set this to `true` to accept such
code.
- **allowSuperOutsideMethod** TODO
- **allowSuperOutsideMethod**: TODO
- **sourceType**: Indicate the mode the code should be parsed in. Can be
either `"script"` or `"module"`.
- **sourceFilename**: Correlate output AST nodes with their source filename. Useful when generating code and source maps from the ASTs of multiple input files.
- **startLine**: By default, the first line of code parsed is treated as line 1. You can provide a line number to alternatively start with. Useful for integration with other source tools.
- **plugins**: Array containing the plugins that you want to enable.
- **strictMode**: TODO
### Output
Babylon generates AST according to [Babel AST format][].
@ -111,7 +121,7 @@ require("babylon").parse("code", {
- `flow`
- `doExpressions`
- `objectRestSpread`
- `decorators`
- `decorators` (Based on an outdated version of the Decorators proposal. Will be removed in a future version of `Babylon`)
- `classProperties`
- `exportExtensions`
- `asyncGenerators`

View File

@ -50,7 +50,7 @@ function generate(chars) {
at = to;
}
}
return {nonASCII: re, astral: astral};
return { nonASCII: re, astral: astral };
}
const startData = generate(start);

1633
node_modules/babylon/lib/index.js generated vendored

File diff suppressed because it is too large Load Diff

51
node_modules/babylon/package.json generated vendored
View File

@ -1,10 +1,16 @@
{
"name": "babylon",
"version": "6.13.1",
"version": "6.16.1",
"description": "A JavaScript parser",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
"keywords": [
"babel",
"javascript",
"parser",
"babylon"
],
"repository": "https://github.com/babel/babylon",
"main": "lib/index.js",
"files": [
@ -12,25 +18,25 @@
"lib"
],
"devDependencies": {
"ava": "^0.16.0",
"ava": "^0.17.0",
"babel-cli": "^6.14.0",
"babel-eslint": "^7.0.0",
"babel-helper-fixtures": "^6.9.0",
"babel-plugin-istanbul": "^2.0.1",
"babel-plugin-external-helpers": "^6.18.0",
"babel-plugin-istanbul": "^3.0.0",
"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-0": "^6.5.0",
"chalk": "^1.1.3",
"codecov": "^1.0.1",
"cross-env": "^2.0.1",
"cross-env": "^2.0.0",
"eslint": "^3.7.1",
"eslint-config-babel": "^2.0.1",
"eslint-plugin-babel": "^3.3.0",
"eslint-config-babel": "^6.0.0",
"eslint-plugin-flowtype": "^2.20.0",
"flow-bin": "^0.33.0",
"lodash": "^4.15.0",
"nyc": "^8.1.0",
"flow-bin": "^0.38.0",
"nyc": "^10.0.0",
"rimraf": "^2.5.4",
"rollup": "^0.36.3",
"rollup": "^0.41.0",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-node-resolve": "^2.0.0",
"unicode-9.0.0": "~0.7.0"
@ -39,17 +45,18 @@
"babylon": "./bin/babylon.js"
},
"scripts": {
"build": "rollup -c",
"build": "npm run clean && rollup -c",
"coverage": "nyc report --reporter=json && codecov -f coverage/coverage-final.json",
"lint": "eslint src bin",
"clean": "rimraf lib",
"flow": "flow",
"prepublish": "npm run clean && cross-env BABEL_ENV=production npm run build",
"prepublish": "cross-env BABEL_ENV=production npm run build",
"preversion": "npm run test && npm run changelog",
"test": "npm run lint && npm run flow && npm run build && npm run test-only",
"test-only": "ava test",
"test": "npm run lint && npm run flow && npm run build -- -m && npm run test-only",
"test-only": "ava",
"test-ci": "nyc npm run test-only",
"changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'"
"changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'",
"watch": "npm run clean && cross-env BABEL_ENV=watch babel src --out-dir lib --watch"
},
"nyc": {
"include": [
@ -58,5 +65,19 @@
],
"sourceMap": false,
"instrument": false
},
"ava": {
"files": [
"test/*.js"
],
"source": [
"src/**/*.js",
"bin/**/*.js"
]
},
"greenkeeper": {
"ignore": [
"cross-env"
]
}
}

4
node_modules/bl/.travis.yml generated vendored
View File

@ -4,10 +4,12 @@ node_js:
- '0.10'
- '0.12'
- '4'
- '5'
- '6'
- '7'
branches:
only:
- master
notifications:
email:
- rod@vagg.org
- matteo.collina@gmail.com

2
node_modules/bl/LICENSE.md generated vendored
View File

@ -1,7 +1,7 @@
The MIT License (MIT)
=====================
Copyright (c) 2014 bl contributors
Copyright (c) 2013-2016 bl contributors
----------------------------------
*bl contributors listed at <https://github.com/rvagg/bl#contributors>*

10
node_modules/bl/README.md generated vendored
View File

@ -87,6 +87,7 @@ bl.pipe(fs.createWriteStream('gibberish.txt'))
* <a href="#append"><code>bl.<b>append(buffer)</b></code></a>
* <a href="#get"><code>bl.<b>get(index)</b></code></a>
* <a href="#slice"><code>bl.<b>slice([ start[, end ] ])</b></code></a>
* <a href="#shallowSlice"><code>bl.<b>shallowSlice([ start[, end ] ])</b></code></a>
* <a href="#copy"><code>bl.<b>copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])</b></code></a>
* <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
* <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
@ -135,6 +136,13 @@ Get the length of the list in bytes. This is the sum of the lengths of all of th
If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
--------------------------------------------------------
<a name="shallowSlice"></a>
### bl.shallowSlice([ start, [ end ] ])
`shallowSlice()` returns a new `BufferList` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
No copies will be performed. All buffers in the result share memory with the original list.
--------------------------------------------------------
<a name="copy"></a>
### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
@ -195,6 +203,6 @@ See the <b><code>[Buffer](http://nodejs.org/docs/latest/api/buffer.html)</code><
<a name="license"></a>
## License &amp; copyright
Copyright (c) 2013-2014 bl contributors (listed above).
Copyright (c) 2013-2016 bl contributors (listed above).
bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

55
node_modules/bl/bl.js generated vendored
View File

@ -38,9 +38,10 @@ util.inherits(BufferList, DuplexStream)
BufferList.prototype._offset = function _offset (offset) {
var tot = 0, i = 0, _t
if (offset === 0) return [ 0, 0 ]
for (; i < this._bufs.length; i++) {
_t = tot + this._bufs[i].length
if (offset < _t)
if (offset < _t || i == this._bufs.length - 1)
return [ i, offset - tot ]
tot = _t
}
@ -49,9 +50,10 @@ BufferList.prototype._offset = function _offset (offset) {
BufferList.prototype.append = function append (buf) {
var i = 0
, newBuf
if (Array.isArray(buf)) {
if (Buffer.isBuffer(buf)) {
this._appendBuffer(buf);
} else if (Array.isArray(buf)) {
for (; i < buf.length; i++)
this.append(buf[i])
} else if (buf instanceof BufferList) {
@ -64,17 +66,21 @@ BufferList.prototype.append = function append (buf) {
if (typeof buf == 'number')
buf = buf.toString()
newBuf = Buffer.isBuffer(buf) ? buf : new Buffer(buf)
this._bufs.push(newBuf)
this.length += newBuf.length
this._appendBuffer(new Buffer(buf));
}
return this
}
BufferList.prototype._appendBuffer = function appendBuffer (buf) {
this._bufs.push(buf)
this.length += buf.length
}
BufferList.prototype._write = function _write (buf, encoding, callback) {
this.append(buf)
this._appendBuffer(buf)
if (typeof callback == 'function')
callback()
@ -107,6 +113,10 @@ BufferList.prototype.get = function get (index) {
BufferList.prototype.slice = function slice (start, end) {
if (typeof start == 'number' && start < 0)
start += this.length
if (typeof end == 'number' && end < 0)
end += this.length
return this.copy(null, 0, start, end)
}
@ -132,8 +142,11 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
// copy/slice everything
if (srcStart === 0 && srcEnd == this.length) {
if (!copy) // slice, just return a full concat
return Buffer.concat(this._bufs)
if (!copy) { // slice, but full concat if multiple buffers
return this._bufs.length === 1
? this._bufs[0]
: Buffer.concat(this._bufs, this.length)
}
// copy, need to copy individual buffers
for (i = 0; i < this._bufs.length; i++) {
@ -174,6 +187,30 @@ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
return dst
}
BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
start = start || 0
end = end || this.length
if (start < 0)
start += this.length
if (end < 0)
end += this.length
var startOffset = this._offset(start)
, endOffset = this._offset(end)
, buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
if (startOffset[1] != 0)
buffers[0] = buffers[0].slice(startOffset[1])
if (endOffset[1] == 0)
buffers.pop()
else
buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
return new BufferList(buffers)
}
BufferList.prototype.toString = function toString (encoding, start, end) {
return this.slice(start, end).toString(encoding)
}

6
node_modules/bl/package.json generated vendored
View File

@ -1,6 +1,6 @@
{
"name": "bl",
"version": "1.1.2",
"version": "1.2.0",
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
"main": "bl.js",
"scripts": {
@ -24,11 +24,11 @@
],
"license": "MIT",
"dependencies": {
"readable-stream": "~2.0.5"
"readable-stream": "^2.0.5"
},
"devDependencies": {
"faucet": "0.0.1",
"hash_file": "~0.1.1",
"tape": "~4.4.0"
"tape": "~4.6.0"
}
}

59
node_modules/bl/test/test.js generated vendored
View File

@ -53,6 +53,20 @@ tape('multi bytes from single buffer', function (t) {
t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
t.end()
})
tape('multi bytes from single buffer (negative indexes)', function (t) {
var bl = new BufferList()
bl.append(new Buffer('buffer'))
t.equal(bl.length, 6)
t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
t.end()
})
@ -72,6 +86,7 @@ tape('multiple bytes from multiple buffers', function (t) {
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
t.end()
})
@ -537,6 +552,50 @@ tape('copy an interval between two buffers', function (t) {
t.end()
})
tape('shallow slice across buffer boundaries', function (t) {
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
t.end()
})
tape('shallow slice within single buffer', function (t) {
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
t.end()
})
tape('shallow slice single buffer', function (t) {
t.plan(3)
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice(0, 5).toString(), 'First')
t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
})
tape('shallow slice with negative or omitted indices', function (t) {
t.plan(4)
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
})
tape('shallow slice does not make a copy', function (t) {
t.plan(1)
var buffers = [new Buffer('First'), new Buffer('Second'), new Buffer('Third')]
var bl = (new BufferList(buffers)).shallowSlice(5, -3)
buffers[1].fill('h')
buffers[2].fill('h')
t.equal(bl.toString(), 'hhhhhhhh')
})
tape('duplicate', function (t) {
t.plan(2)

View File

@ -5,6 +5,7 @@ as known from sh/bash, in JavaScript.
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)

View File

@ -106,7 +106,7 @@ function expand(str, isTop) {
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
var isSequence = isNumericSequence || isAlphaSequence;
var isOptions = /^(.*,)+(.+)?$/.test(m.body);
var isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,.*\}/)) {

Some files were not shown because too many files have changed in this diff Show More