chore: Make enum names consistent with TypeScript convention
BREAKING_CHANGE Ts2Dart issue: https://github.com/angular/ts2dart/issues/270 TypeScript convention: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines DartConvertion: https://www.dartlang.org/articles/style-guide/ Rename: - NumberFormatStyle.DECIMAL => NumberFormatStyle.Decimal - NumberFormatStyle.PERCENT => NumberFormatStyle.Percent - NumberFormatStyle.CURRENCY => NumberFormatStyle.Currency - RequestMethods.GET => RequestMethods.Get - RequestMethods.POST => RequestMethods.Post - RequestMethods.PUT => RequestMethods.Put - RequestMethods.DELETE => RequestMethods.Delete - RequestMethods.HEAD => RequestMethods.Head - RequestMethods.PATCH => RequestMethods.Patch - ReadyStates.UNSENT => ReadyStates.Unsent - ReadyStates.OPEN => ReadyStates.Open - ReadyStates.HEADERS_RECEIVED => ReadyStates.HeadersReceived - ReadyStates.LOADING => ReadyStates.Loading - ReadyStates.DONE => ReadyStates.Done - ReadyStates.CANCELLED => ReadyStates.Canceled
This commit is contained in:
parent
465f7c95b0
commit
37b042b361
|
@ -43,14 +43,14 @@ export function coalesce(records: ProtoRecord[]): ProtoRecord[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): ProtoRecord {
|
function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): ProtoRecord {
|
||||||
return new ProtoRecord(RecordType.SELF, "self", null, [], r.fixedArgs, contextIndex,
|
return new ProtoRecord(RecordType.Self, "self", null, [], r.fixedArgs, contextIndex,
|
||||||
r.directiveIndex, selfIndex, r.bindingRecord, r.lastInBinding,
|
r.directiveIndex, selfIndex, r.bindingRecord, r.lastInBinding,
|
||||||
r.lastInDirective, false, false, r.propertyBindingIndex);
|
r.lastInDirective, false, false, r.propertyBindingIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) {
|
function _findMatching(r: ProtoRecord, rs: List<ProtoRecord>) {
|
||||||
return ListWrapper.find(
|
return ListWrapper.find(
|
||||||
rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE && _sameDirIndex(rr, r) &&
|
rs, (rr) => rr.mode !== RecordType.DirectiveLifecycle && _sameDirIndex(rr, r) &&
|
||||||
rr.mode === r.mode && looseIdentical(rr.funcOrValue, r.funcOrValue) &&
|
rr.mode === r.mode && looseIdentical(rr.funcOrValue, r.funcOrValue) &&
|
||||||
rr.contextIndex === r.contextIndex && looseIdentical(rr.name, r.name) &&
|
rr.contextIndex === r.contextIndex && looseIdentical(rr.name, r.name) &&
|
||||||
ListWrapper.equals(rr.args, r.args));
|
ListWrapper.equals(rr.args, r.args));
|
||||||
|
|
|
@ -47,67 +47,67 @@ export class CodegenLogicUtil {
|
||||||
|
|
||||||
var rhs: string;
|
var rhs: string;
|
||||||
switch (protoRec.mode) {
|
switch (protoRec.mode) {
|
||||||
case RecordType.SELF:
|
case RecordType.Self:
|
||||||
rhs = context;
|
rhs = context;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.CONST:
|
case RecordType.Const:
|
||||||
rhs = codify(protoRec.funcOrValue);
|
rhs = codify(protoRec.funcOrValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.PROPERTY_READ:
|
case RecordType.PropertyRead:
|
||||||
rhs = this._observe(`${context}.${protoRec.name}`, protoRec);
|
rhs = this._observe(`${context}.${protoRec.name}`, protoRec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.SAFE_PROPERTY:
|
case RecordType.SafeProperty:
|
||||||
var read = this._observe(`${context}.${protoRec.name}`, protoRec);
|
var read = this._observe(`${context}.${protoRec.name}`, protoRec);
|
||||||
rhs =
|
rhs =
|
||||||
`${this._utilName}.isValueBlank(${context}) ? null : ${this._observe(read, protoRec)}`;
|
`${this._utilName}.isValueBlank(${context}) ? null : ${this._observe(read, protoRec)}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.PROPERTY_WRITE:
|
case RecordType.PropertyWrite:
|
||||||
rhs = `${context}.${protoRec.name} = ${getLocalName(protoRec.args[0])}`;
|
rhs = `${context}.${protoRec.name} = ${getLocalName(protoRec.args[0])}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.LOCAL:
|
case RecordType.Local:
|
||||||
rhs = this._observe(`${localsAccessor}.get(${rawString(protoRec.name)})`, protoRec);
|
rhs = this._observe(`${localsAccessor}.get(${rawString(protoRec.name)})`, protoRec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.INVOKE_METHOD:
|
case RecordType.InvokeMethod:
|
||||||
rhs = this._observe(`${context}.${protoRec.name}(${argString})`, protoRec);
|
rhs = this._observe(`${context}.${protoRec.name}(${argString})`, protoRec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.SAFE_INVOKE_METHOD:
|
case RecordType.SafeMethodInvoke:
|
||||||
var invoke = `${context}.${protoRec.name}(${argString})`;
|
var invoke = `${context}.${protoRec.name}(${argString})`;
|
||||||
rhs =
|
rhs =
|
||||||
`${this._utilName}.isValueBlank(${context}) ? null : ${this._observe(invoke, protoRec)}`;
|
`${this._utilName}.isValueBlank(${context}) ? null : ${this._observe(invoke, protoRec)}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.INVOKE_CLOSURE:
|
case RecordType.InvokeClosure:
|
||||||
rhs = `${context}(${argString})`;
|
rhs = `${context}(${argString})`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.PRIMITIVE_OP:
|
case RecordType.PrimitiveOp:
|
||||||
rhs = `${this._utilName}.${protoRec.name}(${argString})`;
|
rhs = `${this._utilName}.${protoRec.name}(${argString})`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.COLLECTION_LITERAL:
|
case RecordType.CollectionLiteral:
|
||||||
rhs = `${this._utilName}.${protoRec.name}(${argString})`;
|
rhs = `${this._utilName}.${protoRec.name}(${argString})`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.INTERPOLATE:
|
case RecordType.Interpolate:
|
||||||
rhs = this._genInterpolation(protoRec);
|
rhs = this._genInterpolation(protoRec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.KEYED_READ:
|
case RecordType.KeyedRead:
|
||||||
rhs = this._observe(`${context}[${getLocalName(protoRec.args[0])}]`, protoRec);
|
rhs = this._observe(`${context}[${getLocalName(protoRec.args[0])}]`, protoRec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.KEYED_WRITE:
|
case RecordType.KeyedWrite:
|
||||||
rhs = `${context}[${getLocalName(protoRec.args[0])}] = ${getLocalName(protoRec.args[1])}`;
|
rhs = `${context}[${getLocalName(protoRec.args[0])}] = ${getLocalName(protoRec.args[1])}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecordType.CHAIN:
|
case RecordType.Chain:
|
||||||
rhs = 'null';
|
rhs = 'null';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -252,42 +252,42 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||||
|
|
||||||
_calculateCurrValue(proto: ProtoRecord, values: any[], locals: Locals) {
|
_calculateCurrValue(proto: ProtoRecord, values: any[], locals: Locals) {
|
||||||
switch (proto.mode) {
|
switch (proto.mode) {
|
||||||
case RecordType.SELF:
|
case RecordType.Self:
|
||||||
return this._readContext(proto, values);
|
return this._readContext(proto, values);
|
||||||
|
|
||||||
case RecordType.CONST:
|
case RecordType.Const:
|
||||||
return proto.funcOrValue;
|
return proto.funcOrValue;
|
||||||
|
|
||||||
case RecordType.PROPERTY_READ:
|
case RecordType.PropertyRead:
|
||||||
var context = this._readContext(proto, values);
|
var context = this._readContext(proto, values);
|
||||||
return proto.funcOrValue(context);
|
return proto.funcOrValue(context);
|
||||||
|
|
||||||
case RecordType.SAFE_PROPERTY:
|
case RecordType.SafeProperty:
|
||||||
var context = this._readContext(proto, values);
|
var context = this._readContext(proto, values);
|
||||||
return isBlank(context) ? null : proto.funcOrValue(context);
|
return isBlank(context) ? null : proto.funcOrValue(context);
|
||||||
|
|
||||||
case RecordType.PROPERTY_WRITE:
|
case RecordType.PropertyWrite:
|
||||||
var context = this._readContext(proto, values);
|
var context = this._readContext(proto, values);
|
||||||
var value = this._readArgs(proto, values)[0];
|
var value = this._readArgs(proto, values)[0];
|
||||||
proto.funcOrValue(context, value);
|
proto.funcOrValue(context, value);
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
case RecordType.KEYED_WRITE:
|
case RecordType.KeyedWrite:
|
||||||
var context = this._readContext(proto, values);
|
var context = this._readContext(proto, values);
|
||||||
var key = this._readArgs(proto, values)[0];
|
var key = this._readArgs(proto, values)[0];
|
||||||
var value = this._readArgs(proto, values)[1];
|
var value = this._readArgs(proto, values)[1];
|
||||||
context[key] = value;
|
context[key] = value;
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
case RecordType.LOCAL:
|
case RecordType.Local:
|
||||||
return locals.get(proto.name);
|
return locals.get(proto.name);
|
||||||
|
|
||||||
case RecordType.INVOKE_METHOD:
|
case RecordType.InvokeMethod:
|
||||||
var context = this._readContext(proto, values);
|
var context = this._readContext(proto, values);
|
||||||
var args = this._readArgs(proto, values);
|
var args = this._readArgs(proto, values);
|
||||||
return proto.funcOrValue(context, args);
|
return proto.funcOrValue(context, args);
|
||||||
|
|
||||||
case RecordType.SAFE_INVOKE_METHOD:
|
case RecordType.SafeMethodInvoke:
|
||||||
var context = this._readContext(proto, values);
|
var context = this._readContext(proto, values);
|
||||||
if (isBlank(context)) {
|
if (isBlank(context)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -295,21 +295,21 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||||
var args = this._readArgs(proto, values);
|
var args = this._readArgs(proto, values);
|
||||||
return proto.funcOrValue(context, args);
|
return proto.funcOrValue(context, args);
|
||||||
|
|
||||||
case RecordType.KEYED_READ:
|
case RecordType.KeyedRead:
|
||||||
var arg = this._readArgs(proto, values)[0];
|
var arg = this._readArgs(proto, values)[0];
|
||||||
return this._readContext(proto, values)[arg];
|
return this._readContext(proto, values)[arg];
|
||||||
|
|
||||||
case RecordType.CHAIN:
|
case RecordType.Chain:
|
||||||
var args = this._readArgs(proto, values);
|
var args = this._readArgs(proto, values);
|
||||||
return args[args.length - 1];
|
return args[args.length - 1];
|
||||||
|
|
||||||
case RecordType.INVOKE_CLOSURE:
|
case RecordType.InvokeClosure:
|
||||||
return FunctionWrapper.apply(this._readContext(proto, values),
|
return FunctionWrapper.apply(this._readContext(proto, values),
|
||||||
this._readArgs(proto, values));
|
this._readArgs(proto, values));
|
||||||
|
|
||||||
case RecordType.INTERPOLATE:
|
case RecordType.Interpolate:
|
||||||
case RecordType.PRIMITIVE_OP:
|
case RecordType.PrimitiveOp:
|
||||||
case RecordType.COLLECTION_LITERAL:
|
case RecordType.CollectionLiteral:
|
||||||
return FunctionWrapper.apply(proto.funcOrValue, this._readArgs(proto, values));
|
return FunctionWrapper.apply(proto.funcOrValue, this._readArgs(proto, values));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -9,12 +9,12 @@ import {
|
||||||
} from "angular2/src/core/facade/lang";
|
} from "angular2/src/core/facade/lang";
|
||||||
|
|
||||||
export enum TokenType {
|
export enum TokenType {
|
||||||
CHARACTER,
|
Character,
|
||||||
IDENTIFIER,
|
Identifier,
|
||||||
KEYWORD,
|
Keyword,
|
||||||
STRING,
|
String,
|
||||||
OPERATOR,
|
Operator,
|
||||||
NUMBER
|
Number
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -36,50 +36,50 @@ export class Token {
|
||||||
public strValue: string) {}
|
public strValue: string) {}
|
||||||
|
|
||||||
isCharacter(code: number): boolean {
|
isCharacter(code: number): boolean {
|
||||||
return (this.type == TokenType.CHARACTER && this.numValue == code);
|
return (this.type == TokenType.Character && this.numValue == code);
|
||||||
}
|
}
|
||||||
|
|
||||||
isNumber(): boolean { return (this.type == TokenType.NUMBER); }
|
isNumber(): boolean { return (this.type == TokenType.Number); }
|
||||||
|
|
||||||
isString(): boolean { return (this.type == TokenType.STRING); }
|
isString(): boolean { return (this.type == TokenType.String); }
|
||||||
|
|
||||||
isOperator(operater: string): boolean {
|
isOperator(operater: string): boolean {
|
||||||
return (this.type == TokenType.OPERATOR && this.strValue == operater);
|
return (this.type == TokenType.Operator && this.strValue == operater);
|
||||||
}
|
}
|
||||||
|
|
||||||
isIdentifier(): boolean { return (this.type == TokenType.IDENTIFIER); }
|
isIdentifier(): boolean { return (this.type == TokenType.Identifier); }
|
||||||
|
|
||||||
isKeyword(): boolean { return (this.type == TokenType.KEYWORD); }
|
isKeyword(): boolean { return (this.type == TokenType.Keyword); }
|
||||||
|
|
||||||
isKeywordVar(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "var"); }
|
isKeywordVar(): boolean { return (this.type == TokenType.Keyword && this.strValue == "var"); }
|
||||||
|
|
||||||
isKeywordNull(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "null"); }
|
isKeywordNull(): boolean { return (this.type == TokenType.Keyword && this.strValue == "null"); }
|
||||||
|
|
||||||
isKeywordUndefined(): boolean {
|
isKeywordUndefined(): boolean {
|
||||||
return (this.type == TokenType.KEYWORD && this.strValue == "undefined");
|
return (this.type == TokenType.Keyword && this.strValue == "undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
isKeywordTrue(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "true"); }
|
isKeywordTrue(): boolean { return (this.type == TokenType.Keyword && this.strValue == "true"); }
|
||||||
|
|
||||||
isKeywordIf(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "if"); }
|
isKeywordIf(): boolean { return (this.type == TokenType.Keyword && this.strValue == "if"); }
|
||||||
|
|
||||||
isKeywordElse(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "else"); }
|
isKeywordElse(): boolean { return (this.type == TokenType.Keyword && this.strValue == "else"); }
|
||||||
|
|
||||||
isKeywordFalse(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "false"); }
|
isKeywordFalse(): boolean { return (this.type == TokenType.Keyword && this.strValue == "false"); }
|
||||||
|
|
||||||
toNumber(): number {
|
toNumber(): number {
|
||||||
// -1 instead of NULL ok?
|
// -1 instead of NULL ok?
|
||||||
return (this.type == TokenType.NUMBER) ? this.numValue : -1;
|
return (this.type == TokenType.Number) ? this.numValue : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string {
|
toString(): string {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case TokenType.CHARACTER:
|
case TokenType.Character:
|
||||||
case TokenType.STRING:
|
case TokenType.String:
|
||||||
case TokenType.IDENTIFIER:
|
case TokenType.Identifier:
|
||||||
case TokenType.KEYWORD:
|
case TokenType.Keyword:
|
||||||
return this.strValue;
|
return this.strValue;
|
||||||
case TokenType.NUMBER:
|
case TokenType.Number:
|
||||||
return this.numValue.toString();
|
return this.numValue.toString();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
@ -88,31 +88,31 @@ export class Token {
|
||||||
}
|
}
|
||||||
|
|
||||||
function newCharacterToken(index: number, code: number): Token {
|
function newCharacterToken(index: number, code: number): Token {
|
||||||
return new Token(index, TokenType.CHARACTER, code, StringWrapper.fromCharCode(code));
|
return new Token(index, TokenType.Character, code, StringWrapper.fromCharCode(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
function newIdentifierToken(index: number, text: string): Token {
|
function newIdentifierToken(index: number, text: string): Token {
|
||||||
return new Token(index, TokenType.IDENTIFIER, 0, text);
|
return new Token(index, TokenType.Identifier, 0, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newKeywordToken(index: number, text: string): Token {
|
function newKeywordToken(index: number, text: string): Token {
|
||||||
return new Token(index, TokenType.KEYWORD, 0, text);
|
return new Token(index, TokenType.Keyword, 0, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newOperatorToken(index: number, text: string): Token {
|
function newOperatorToken(index: number, text: string): Token {
|
||||||
return new Token(index, TokenType.OPERATOR, 0, text);
|
return new Token(index, TokenType.Operator, 0, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newStringToken(index: number, text: string): Token {
|
function newStringToken(index: number, text: string): Token {
|
||||||
return new Token(index, TokenType.STRING, 0, text);
|
return new Token(index, TokenType.String, 0, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newNumberToken(index: number, n: number): Token {
|
function newNumberToken(index: number, n: number): Token {
|
||||||
return new Token(index, TokenType.NUMBER, n, "");
|
return new Token(index, TokenType.Number, n, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export var EOF: Token = new Token(-1, TokenType.CHARACTER, 0, "");
|
export var EOF: Token = new Token(-1, TokenType.Character, 0, "");
|
||||||
|
|
||||||
export const $EOF = 0;
|
export const $EOF = 0;
|
||||||
export const $TAB = 9;
|
export const $TAB = 9;
|
||||||
|
|
|
@ -107,7 +107,7 @@ export class ProtoRecordBuilder {
|
||||||
|
|
||||||
_appendRecords(b: BindingRecord, variableNames: string[], bindingIndex: number) {
|
_appendRecords(b: BindingRecord, variableNames: string[], bindingIndex: number) {
|
||||||
if (b.isDirectiveLifecycle()) {
|
if (b.isDirectiveLifecycle()) {
|
||||||
this.records.push(new ProtoRecord(RecordType.DIRECTIVE_LIFECYCLE, b.lifecycleEvent, null, [],
|
this.records.push(new ProtoRecord(RecordType.DirectiveLifecycle, b.lifecycleEvent, null, [],
|
||||||
[], -1, null, this.records.length + 1, b, false, false,
|
[], -1, null, this.records.length + 1, b, false, false,
|
||||||
false, false, null));
|
false, false, null));
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,21 +137,21 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
|
||||||
|
|
||||||
visitInterpolation(ast: Interpolation): number {
|
visitInterpolation(ast: Interpolation): number {
|
||||||
var args = this._visitAll(ast.expressions);
|
var args = this._visitAll(ast.expressions);
|
||||||
return this._addRecord(RecordType.INTERPOLATE, "interpolate", _interpolationFn(ast.strings),
|
return this._addRecord(RecordType.Interpolate, "interpolate", _interpolationFn(ast.strings),
|
||||||
args, ast.strings, 0);
|
args, ast.strings, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitLiteralPrimitive(ast: LiteralPrimitive): number {
|
visitLiteralPrimitive(ast: LiteralPrimitive): number {
|
||||||
return this._addRecord(RecordType.CONST, "literal", ast.value, [], null, 0);
|
return this._addRecord(RecordType.Const, "literal", ast.value, [], null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitPropertyRead(ast: PropertyRead): number {
|
visitPropertyRead(ast: PropertyRead): number {
|
||||||
var receiver = ast.receiver.visit(this);
|
var receiver = ast.receiver.visit(this);
|
||||||
if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name) &&
|
if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name) &&
|
||||||
ast.receiver instanceof ImplicitReceiver) {
|
ast.receiver instanceof ImplicitReceiver) {
|
||||||
return this._addRecord(RecordType.LOCAL, ast.name, ast.name, [], null, receiver);
|
return this._addRecord(RecordType.Local, ast.name, ast.name, [], null, receiver);
|
||||||
} else {
|
} else {
|
||||||
return this._addRecord(RecordType.PROPERTY_READ, ast.name, ast.getter, [], null, receiver);
|
return this._addRecord(RecordType.PropertyRead, ast.name, ast.getter, [], null, receiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
|
||||||
} else {
|
} else {
|
||||||
var receiver = ast.receiver.visit(this);
|
var receiver = ast.receiver.visit(this);
|
||||||
var value = ast.value.visit(this);
|
var value = ast.value.visit(this);
|
||||||
return this._addRecord(RecordType.PROPERTY_WRITE, ast.name, ast.setter, [value], null,
|
return this._addRecord(RecordType.PropertyWrite, ast.name, ast.setter, [value], null,
|
||||||
receiver);
|
receiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,46 +171,46 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
|
||||||
var obj = ast.obj.visit(this);
|
var obj = ast.obj.visit(this);
|
||||||
var key = ast.key.visit(this);
|
var key = ast.key.visit(this);
|
||||||
var value = ast.value.visit(this);
|
var value = ast.value.visit(this);
|
||||||
return this._addRecord(RecordType.KEYED_WRITE, null, null, [key, value], null, obj);
|
return this._addRecord(RecordType.KeyedWrite, null, null, [key, value], null, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitSafePropertyRead(ast: SafePropertyRead): number {
|
visitSafePropertyRead(ast: SafePropertyRead): number {
|
||||||
var receiver = ast.receiver.visit(this);
|
var receiver = ast.receiver.visit(this);
|
||||||
return this._addRecord(RecordType.SAFE_PROPERTY, ast.name, ast.getter, [], null, receiver);
|
return this._addRecord(RecordType.SafeProperty, ast.name, ast.getter, [], null, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitMethodCall(ast: MethodCall): number {
|
visitMethodCall(ast: MethodCall): number {
|
||||||
var receiver = ast.receiver.visit(this);
|
var receiver = ast.receiver.visit(this);
|
||||||
var args = this._visitAll(ast.args);
|
var args = this._visitAll(ast.args);
|
||||||
if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name)) {
|
if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name)) {
|
||||||
var target = this._addRecord(RecordType.LOCAL, ast.name, ast.name, [], null, receiver);
|
var target = this._addRecord(RecordType.Local, ast.name, ast.name, [], null, receiver);
|
||||||
return this._addRecord(RecordType.INVOKE_CLOSURE, "closure", null, args, null, target);
|
return this._addRecord(RecordType.InvokeClosure, "closure", null, args, null, target);
|
||||||
} else {
|
} else {
|
||||||
return this._addRecord(RecordType.INVOKE_METHOD, ast.name, ast.fn, args, null, receiver);
|
return this._addRecord(RecordType.InvokeMethod, ast.name, ast.fn, args, null, receiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visitSafeMethodCall(ast: SafeMethodCall): number {
|
visitSafeMethodCall(ast: SafeMethodCall): number {
|
||||||
var receiver = ast.receiver.visit(this);
|
var receiver = ast.receiver.visit(this);
|
||||||
var args = this._visitAll(ast.args);
|
var args = this._visitAll(ast.args);
|
||||||
return this._addRecord(RecordType.SAFE_INVOKE_METHOD, ast.name, ast.fn, args, null, receiver);
|
return this._addRecord(RecordType.SafeMethodInvoke, ast.name, ast.fn, args, null, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitFunctionCall(ast: FunctionCall): number {
|
visitFunctionCall(ast: FunctionCall): number {
|
||||||
var target = ast.target.visit(this);
|
var target = ast.target.visit(this);
|
||||||
var args = this._visitAll(ast.args);
|
var args = this._visitAll(ast.args);
|
||||||
return this._addRecord(RecordType.INVOKE_CLOSURE, "closure", null, args, null, target);
|
return this._addRecord(RecordType.InvokeClosure, "closure", null, args, null, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitLiteralArray(ast: LiteralArray): number {
|
visitLiteralArray(ast: LiteralArray): number {
|
||||||
var primitiveName = `arrayFn${ast.expressions.length}`;
|
var primitiveName = `arrayFn${ast.expressions.length}`;
|
||||||
return this._addRecord(RecordType.COLLECTION_LITERAL, primitiveName,
|
return this._addRecord(RecordType.CollectionLiteral, primitiveName,
|
||||||
_arrayFn(ast.expressions.length), this._visitAll(ast.expressions), null,
|
_arrayFn(ast.expressions.length), this._visitAll(ast.expressions), null,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitLiteralMap(ast: LiteralMap): number {
|
visitLiteralMap(ast: LiteralMap): number {
|
||||||
return this._addRecord(RecordType.COLLECTION_LITERAL, _mapPrimitiveName(ast.keys),
|
return this._addRecord(RecordType.CollectionLiteral, _mapPrimitiveName(ast.keys),
|
||||||
ChangeDetectionUtil.mapFn(ast.keys), this._visitAll(ast.values), null,
|
ChangeDetectionUtil.mapFn(ast.keys), this._visitAll(ast.values), null,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,13 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
|
||||||
visitBinary(ast: Binary): number {
|
visitBinary(ast: Binary): number {
|
||||||
var left = ast.left.visit(this);
|
var left = ast.left.visit(this);
|
||||||
var right = ast.right.visit(this);
|
var right = ast.right.visit(this);
|
||||||
return this._addRecord(RecordType.PRIMITIVE_OP, _operationToPrimitiveName(ast.operation),
|
return this._addRecord(RecordType.PrimitiveOp, _operationToPrimitiveName(ast.operation),
|
||||||
_operationToFunction(ast.operation), [left, right], null, 0);
|
_operationToFunction(ast.operation), [left, right], null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitPrefixNot(ast: PrefixNot): number {
|
visitPrefixNot(ast: PrefixNot): number {
|
||||||
var exp = ast.expression.visit(this);
|
var exp = ast.expression.visit(this);
|
||||||
return this._addRecord(RecordType.PRIMITIVE_OP, "operation_negate",
|
return this._addRecord(RecordType.PrimitiveOp, "operation_negate",
|
||||||
ChangeDetectionUtil.operation_negate, [exp], null, 0);
|
ChangeDetectionUtil.operation_negate, [exp], null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,26 +232,26 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
|
||||||
var c = ast.condition.visit(this);
|
var c = ast.condition.visit(this);
|
||||||
var t = ast.trueExp.visit(this);
|
var t = ast.trueExp.visit(this);
|
||||||
var f = ast.falseExp.visit(this);
|
var f = ast.falseExp.visit(this);
|
||||||
return this._addRecord(RecordType.PRIMITIVE_OP, "cond", ChangeDetectionUtil.cond, [c, t, f],
|
return this._addRecord(RecordType.PrimitiveOp, "cond", ChangeDetectionUtil.cond, [c, t, f],
|
||||||
null, 0);
|
null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitPipe(ast: BindingPipe): number {
|
visitPipe(ast: BindingPipe): number {
|
||||||
var value = ast.exp.visit(this);
|
var value = ast.exp.visit(this);
|
||||||
var args = this._visitAll(ast.args);
|
var args = this._visitAll(ast.args);
|
||||||
return this._addRecord(RecordType.PIPE, ast.name, ast.name, args, null, value);
|
return this._addRecord(RecordType.Pipe, ast.name, ast.name, args, null, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitKeyedRead(ast: KeyedRead): number {
|
visitKeyedRead(ast: KeyedRead): number {
|
||||||
var obj = ast.obj.visit(this);
|
var obj = ast.obj.visit(this);
|
||||||
var key = ast.key.visit(this);
|
var key = ast.key.visit(this);
|
||||||
return this._addRecord(RecordType.KEYED_READ, "keyedAccess", ChangeDetectionUtil.keyedAccess,
|
return this._addRecord(RecordType.KeyedRead, "keyedAccess", ChangeDetectionUtil.keyedAccess,
|
||||||
[key], null, obj);
|
[key], null, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitChain(ast: Chain): number {
|
visitChain(ast: Chain): number {
|
||||||
var args = ast.expressions.map(e => e.visit(this));
|
var args = ast.expressions.map(e => e.visit(this));
|
||||||
return this._addRecord(RecordType.CHAIN, "chain", null, args, null, 0);
|
return this._addRecord(RecordType.Chain, "chain", null, args, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitIf(ast: If) { throw new BaseException('Not supported'); }
|
visitIf(ast: If) { throw new BaseException('Not supported'); }
|
||||||
|
|
|
@ -3,23 +3,23 @@ import {BindingRecord} from './binding_record';
|
||||||
import {DirectiveIndex} from './directive_record';
|
import {DirectiveIndex} from './directive_record';
|
||||||
|
|
||||||
export enum RecordType {
|
export enum RecordType {
|
||||||
SELF,
|
Self,
|
||||||
CONST,
|
Const,
|
||||||
PRIMITIVE_OP,
|
PrimitiveOp,
|
||||||
PROPERTY_READ,
|
PropertyRead,
|
||||||
PROPERTY_WRITE,
|
PropertyWrite,
|
||||||
LOCAL,
|
Local,
|
||||||
INVOKE_METHOD,
|
InvokeMethod,
|
||||||
INVOKE_CLOSURE,
|
InvokeClosure,
|
||||||
KEYED_READ,
|
KeyedRead,
|
||||||
KEYED_WRITE,
|
KeyedWrite,
|
||||||
PIPE,
|
Pipe,
|
||||||
INTERPOLATE,
|
Interpolate,
|
||||||
SAFE_PROPERTY,
|
SafeProperty,
|
||||||
COLLECTION_LITERAL,
|
CollectionLiteral,
|
||||||
SAFE_INVOKE_METHOD,
|
SafeMethodInvoke,
|
||||||
DIRECTIVE_LIFECYCLE,
|
DirectiveLifecycle,
|
||||||
CHAIN
|
Chain
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ProtoRecord {
|
export class ProtoRecord {
|
||||||
|
@ -31,7 +31,7 @@ export class ProtoRecord {
|
||||||
public referencedBySelf: boolean, public propertyBindingIndex: number) {}
|
public referencedBySelf: boolean, public propertyBindingIndex: number) {}
|
||||||
|
|
||||||
isPureFunction(): boolean {
|
isPureFunction(): boolean {
|
||||||
return this.mode === RecordType.INTERPOLATE || this.mode === RecordType.COLLECTION_LITERAL;
|
return this.mode === RecordType.Interpolate || this.mode === RecordType.CollectionLiteral;
|
||||||
}
|
}
|
||||||
|
|
||||||
isUsedByOtherRecord(): boolean { return !this.lastInBinding || this.referencedBySelf; }
|
isUsedByOtherRecord(): boolean { return !this.lastInBinding || this.referencedBySelf; }
|
||||||
|
@ -40,7 +40,7 @@ export class ProtoRecord {
|
||||||
return this.argumentToPureFunction || this.lastInBinding || this.isPureFunction();
|
return this.argumentToPureFunction || this.lastInBinding || this.isPureFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
isPipeRecord(): boolean { return this.mode === RecordType.PIPE; }
|
isPipeRecord(): boolean { return this.mode === RecordType.Pipe; }
|
||||||
|
|
||||||
isLifeCycleRecord(): boolean { return this.mode === RecordType.DIRECTIVE_LIFECYCLE; }
|
isLifeCycleRecord(): boolean { return this.mode === RecordType.DirectiveLifecycle; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import 'package:intl/intl.dart';
|
||||||
|
|
||||||
String _normalizeLocale(String locale) => locale.replaceAll('-', '_');
|
String _normalizeLocale(String locale) => locale.replaceAll('-', '_');
|
||||||
|
|
||||||
enum NumberFormatStyle { DECIMAL, PERCENT, CURRENCY }
|
enum NumberFormatStyle { Decimal, Percent, Currency }
|
||||||
|
|
||||||
class NumberFormatter {
|
class NumberFormatter {
|
||||||
static String format(num number, String locale, NumberFormatStyle style,
|
static String format(num number, String locale, NumberFormatStyle style,
|
||||||
|
@ -16,13 +16,13 @@ class NumberFormatter {
|
||||||
locale = _normalizeLocale(locale);
|
locale = _normalizeLocale(locale);
|
||||||
NumberFormat formatter;
|
NumberFormat formatter;
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case NumberFormatStyle.DECIMAL:
|
case NumberFormatStyle.Decimal:
|
||||||
formatter = new NumberFormat.decimalPattern(locale);
|
formatter = new NumberFormat.decimalPattern(locale);
|
||||||
break;
|
break;
|
||||||
case NumberFormatStyle.PERCENT:
|
case NumberFormatStyle.Percent:
|
||||||
formatter = new NumberFormat.percentPattern(locale);
|
formatter = new NumberFormat.percentPattern(locale);
|
||||||
break;
|
break;
|
||||||
case NumberFormatStyle.CURRENCY:
|
case NumberFormatStyle.Currency:
|
||||||
if (currencyAsSymbol) {
|
if (currencyAsSymbol) {
|
||||||
// See https://github.com/dart-lang/intl/issues/59.
|
// See https://github.com/dart-lang/intl/issues/59.
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
|
|
@ -42,9 +42,9 @@ declare module Intl {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NumberFormatStyle {
|
export enum NumberFormatStyle {
|
||||||
DECIMAL,
|
Decimal,
|
||||||
PERCENT,
|
Percent,
|
||||||
CURRENCY
|
Currency
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NumberFormatter {
|
export class NumberFormatter {
|
||||||
|
@ -63,7 +63,7 @@ export class NumberFormatter {
|
||||||
maximumFractionDigits: maximumFractionDigits
|
maximumFractionDigits: maximumFractionDigits
|
||||||
};
|
};
|
||||||
intlOptions.style = NumberFormatStyle[style].toLowerCase();
|
intlOptions.style = NumberFormatStyle[style].toLowerCase();
|
||||||
if (style == NumberFormatStyle.CURRENCY) {
|
if (style == NumberFormatStyle.Currency) {
|
||||||
intlOptions.currency = currency;
|
intlOptions.currency = currency;
|
||||||
intlOptions.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
|
intlOptions.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class NumberPipe {
|
||||||
export class DecimalPipe extends NumberPipe implements PipeTransform {
|
export class DecimalPipe extends NumberPipe implements PipeTransform {
|
||||||
transform(value: any, args: any[]): string {
|
transform(value: any, args: any[]): string {
|
||||||
var digits: string = ListWrapper.first(args);
|
var digits: string = ListWrapper.first(args);
|
||||||
return NumberPipe._format(value, NumberFormatStyle.DECIMAL, digits);
|
return NumberPipe._format(value, NumberFormatStyle.Decimal, digits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ export class DecimalPipe extends NumberPipe implements PipeTransform {
|
||||||
export class PercentPipe extends NumberPipe implements PipeTransform {
|
export class PercentPipe extends NumberPipe implements PipeTransform {
|
||||||
transform(value: any, args: any[]): string {
|
transform(value: any, args: any[]): string {
|
||||||
var digits: string = ListWrapper.first(args);
|
var digits: string = ListWrapper.first(args);
|
||||||
return NumberPipe._format(value, NumberFormatStyle.PERCENT, digits);
|
return NumberPipe._format(value, NumberFormatStyle.Percent, digits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ export class CurrencyPipe extends NumberPipe implements PipeTransform {
|
||||||
var currencyCode: string = isPresent(args) && args.length > 0 ? args[0] : 'USD';
|
var currencyCode: string = isPresent(args) && args.length > 0 ? args[0] : 'USD';
|
||||||
var symbolDisplay: boolean = isPresent(args) && args.length > 1 ? args[1] : false;
|
var symbolDisplay: boolean = isPresent(args) && args.length > 1 ? args[1] : false;
|
||||||
var digits: string = isPresent(args) && args.length > 2 ? args[2] : null;
|
var digits: string = isPresent(args) && args.length > 2 ? args[2] : null;
|
||||||
return NumberPipe._format(value, NumberFormatStyle.CURRENCY, digits, currencyCode,
|
return NumberPipe._format(value, NumberFormatStyle.Currency, digits, currencyCode,
|
||||||
symbolDisplay);
|
symbolDisplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,13 +176,13 @@ var _splitRe =
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
enum _ComponentIndex {
|
enum _ComponentIndex {
|
||||||
SCHEME = 1,
|
Scheme = 1,
|
||||||
USER_INFO,
|
UserInfo,
|
||||||
DOMAIN,
|
Domain,
|
||||||
PORT,
|
Port,
|
||||||
PATH,
|
Path,
|
||||||
QUERY_DATA,
|
QueryData,
|
||||||
FRAGMENT
|
Fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -256,13 +256,13 @@ function _removeDotSegments(path: string): string {
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
function _joinAndCanonicalizePath(parts: List<any>): string {
|
function _joinAndCanonicalizePath(parts: List<any>): string {
|
||||||
var path = parts[_ComponentIndex.PATH];
|
var path = parts[_ComponentIndex.Path];
|
||||||
path = isBlank(path) ? '' : _removeDotSegments(path);
|
path = isBlank(path) ? '' : _removeDotSegments(path);
|
||||||
parts[_ComponentIndex.PATH] = path;
|
parts[_ComponentIndex.Path] = path;
|
||||||
|
|
||||||
return _buildFromEncodedParts(parts[_ComponentIndex.SCHEME], parts[_ComponentIndex.USER_INFO],
|
return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo],
|
||||||
parts[_ComponentIndex.DOMAIN], parts[_ComponentIndex.PORT], path,
|
parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path,
|
||||||
parts[_ComponentIndex.QUERY_DATA], parts[_ComponentIndex.FRAGMENT]);
|
parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,26 +275,26 @@ function _resolveUrl(base: string, url: string): string {
|
||||||
var parts = _split(encodeURI(url));
|
var parts = _split(encodeURI(url));
|
||||||
var baseParts = _split(base);
|
var baseParts = _split(base);
|
||||||
|
|
||||||
if (isPresent(parts[_ComponentIndex.SCHEME])) {
|
if (isPresent(parts[_ComponentIndex.Scheme])) {
|
||||||
return _joinAndCanonicalizePath(parts);
|
return _joinAndCanonicalizePath(parts);
|
||||||
} else {
|
} else {
|
||||||
parts[_ComponentIndex.SCHEME] = baseParts[_ComponentIndex.SCHEME];
|
parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = _ComponentIndex.SCHEME; i <= _ComponentIndex.PORT; i++) {
|
for (var i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
|
||||||
if (isBlank(parts[i])) {
|
if (isBlank(parts[i])) {
|
||||||
parts[i] = baseParts[i];
|
parts[i] = baseParts[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts[_ComponentIndex.PATH][0] == '/') {
|
if (parts[_ComponentIndex.Path][0] == '/') {
|
||||||
return _joinAndCanonicalizePath(parts);
|
return _joinAndCanonicalizePath(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = baseParts[_ComponentIndex.PATH];
|
var path = baseParts[_ComponentIndex.Path];
|
||||||
if (isBlank(path)) path = '/';
|
if (isBlank(path)) path = '/';
|
||||||
var index = path.lastIndexOf('/');
|
var index = path.lastIndexOf('/');
|
||||||
path = path.substring(0, index + 1) + parts[_ComponentIndex.PATH];
|
path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
|
||||||
parts[_ComponentIndex.PATH] = path;
|
parts[_ComponentIndex.Path] = path;
|
||||||
return _joinAndCanonicalizePath(parts);
|
return _joinAndCanonicalizePath(parts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ export class JSONPConnection implements Connection {
|
||||||
|
|
||||||
constructor(req: Request, private _dom: BrowserJsonp,
|
constructor(req: Request, private _dom: BrowserJsonp,
|
||||||
private baseResponseOptions?: ResponseOptions) {
|
private baseResponseOptions?: ResponseOptions) {
|
||||||
if (req.method !== RequestMethods.GET) {
|
if (req.method !== RequestMethods.Get) {
|
||||||
throw makeTypeError("JSONP requests must use GET request method.");
|
throw makeTypeError("JSONP requests must use GET request method.");
|
||||||
}
|
}
|
||||||
this.request = req;
|
this.request = req;
|
||||||
this.response = new EventEmitter();
|
this.response = new EventEmitter();
|
||||||
this.readyState = ReadyStates.LOADING;
|
this.readyState = ReadyStates.Loading;
|
||||||
this._id = _dom.nextRequestID();
|
this._id = _dom.nextRequestID();
|
||||||
|
|
||||||
_dom.exposeConnection(this._id, this);
|
_dom.exposeConnection(this._id, this);
|
||||||
|
@ -42,8 +42,8 @@ export class JSONPConnection implements Connection {
|
||||||
let script = this._script = _dom.build(url);
|
let script = this._script = _dom.build(url);
|
||||||
|
|
||||||
script.addEventListener('load', (event) => {
|
script.addEventListener('load', (event) => {
|
||||||
if (this.readyState === ReadyStates.CANCELLED) return;
|
if (this.readyState === ReadyStates.Cancelled) return;
|
||||||
this.readyState = ReadyStates.DONE;
|
this.readyState = ReadyStates.Done;
|
||||||
_dom.cleanup(script);
|
_dom.cleanup(script);
|
||||||
if (!this._finished) {
|
if (!this._finished) {
|
||||||
ObservableWrapper.callThrow(
|
ObservableWrapper.callThrow(
|
||||||
|
@ -60,8 +60,8 @@ export class JSONPConnection implements Connection {
|
||||||
});
|
});
|
||||||
|
|
||||||
script.addEventListener('error', (error) => {
|
script.addEventListener('error', (error) => {
|
||||||
if (this.readyState === ReadyStates.CANCELLED) return;
|
if (this.readyState === ReadyStates.Cancelled) return;
|
||||||
this.readyState = ReadyStates.DONE;
|
this.readyState = ReadyStates.Done;
|
||||||
_dom.cleanup(script);
|
_dom.cleanup(script);
|
||||||
ObservableWrapper.callThrow(this.response, error);
|
ObservableWrapper.callThrow(this.response, error);
|
||||||
});
|
});
|
||||||
|
@ -73,12 +73,12 @@ export class JSONPConnection implements Connection {
|
||||||
// Don't leak connections
|
// Don't leak connections
|
||||||
this._finished = true;
|
this._finished = true;
|
||||||
this._dom.removeConnection(this._id);
|
this._dom.removeConnection(this._id);
|
||||||
if (this.readyState === ReadyStates.CANCELLED) return;
|
if (this.readyState === ReadyStates.Cancelled) return;
|
||||||
this._responseData = data;
|
this._responseData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
this.readyState = ReadyStates.CANCELLED;
|
this.readyState = ReadyStates.Cancelled;
|
||||||
let script = this._script;
|
let script = this._script;
|
||||||
this._script = null;
|
this._script = null;
|
||||||
if (isPresent(script)) {
|
if (isPresent(script)) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ export class MockConnection implements Connection {
|
||||||
|
|
||||||
constructor(req: Request) {
|
constructor(req: Request) {
|
||||||
this.response = new EventEmitter();
|
this.response = new EventEmitter();
|
||||||
this.readyState = ReadyStates.OPEN;
|
this.readyState = ReadyStates.Open;
|
||||||
this.request = req;
|
this.request = req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ export class MockConnection implements Connection {
|
||||||
* Changes the `readyState` of the connection to a custom state of 5 (cancelled).
|
* Changes the `readyState` of the connection to a custom state of 5 (cancelled).
|
||||||
*/
|
*/
|
||||||
dispose() {
|
dispose() {
|
||||||
if (this.readyState !== ReadyStates.DONE) {
|
if (this.readyState !== ReadyStates.Done) {
|
||||||
this.readyState = ReadyStates.CANCELLED;
|
this.readyState = ReadyStates.Cancelled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,10 +62,10 @@ export class MockConnection implements Connection {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
mockRespond(res: Response) {
|
mockRespond(res: Response) {
|
||||||
if (this.readyState === ReadyStates.DONE || this.readyState === ReadyStates.CANCELLED) {
|
if (this.readyState === ReadyStates.Done || this.readyState === ReadyStates.Cancelled) {
|
||||||
throw new BaseException('Connection has already been resolved');
|
throw new BaseException('Connection has already been resolved');
|
||||||
}
|
}
|
||||||
this.readyState = ReadyStates.DONE;
|
this.readyState = ReadyStates.Done;
|
||||||
ObservableWrapper.callNext(this.response, res);
|
ObservableWrapper.callNext(this.response, res);
|
||||||
ObservableWrapper.callReturn(this.response);
|
ObservableWrapper.callReturn(this.response);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ export class MockConnection implements Connection {
|
||||||
*/
|
*/
|
||||||
mockError(err?: Error) {
|
mockError(err?: Error) {
|
||||||
// Matches XHR semantics
|
// Matches XHR semantics
|
||||||
this.readyState = ReadyStates.DONE;
|
this.readyState = ReadyStates.Done;
|
||||||
ObservableWrapper.callThrow(this.response, err);
|
ObservableWrapper.callThrow(this.response, err);
|
||||||
ObservableWrapper.callReturn(this.response);
|
ObservableWrapper.callReturn(this.response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ export class XHRConnection implements Connection {
|
||||||
this.response = new EventEmitter();
|
this.response = new EventEmitter();
|
||||||
this._xhr = browserXHR.build();
|
this._xhr = browserXHR.build();
|
||||||
// TODO(jeffbcross): implement error listening/propagation
|
// TODO(jeffbcross): implement error listening/propagation
|
||||||
this._xhr.open(RequestMethods[req.method], req.url);
|
this._xhr.open(RequestMethods[req.method].toUpperCase(), req.url);
|
||||||
this._xhr.addEventListener('load', (_) => {
|
this._xhr.addEventListener('load', (_) => {
|
||||||
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
||||||
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
|
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
|
||||||
|
|
|
@ -92,6 +92,6 @@ export class RequestOptions {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BaseRequestOptions extends RequestOptions {
|
export class BaseRequestOptions extends RequestOptions {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({method: RequestMethods.GET, headers: new Headers(), mode: RequestModesOpts.Cors});
|
super({method: RequestMethods.Get, headers: new Headers(), mode: RequestModesOpts.Cors});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,13 @@ export enum RequestCredentialsOpts {
|
||||||
* Supported http methods.
|
* Supported http methods.
|
||||||
*/
|
*/
|
||||||
export enum RequestMethods {
|
export enum RequestMethods {
|
||||||
GET,
|
Get,
|
||||||
POST,
|
Post,
|
||||||
PUT,
|
Put,
|
||||||
DELETE,
|
Delete,
|
||||||
OPTIONS,
|
Options,
|
||||||
HEAD,
|
Head,
|
||||||
PATCH
|
Patch
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,12 +52,12 @@ export enum RequestMethods {
|
||||||
* additional "CANCELLED" state.
|
* additional "CANCELLED" state.
|
||||||
*/
|
*/
|
||||||
export enum ReadyStates {
|
export enum ReadyStates {
|
||||||
UNSENT,
|
Unsent,
|
||||||
OPEN,
|
Open,
|
||||||
HEADERS_RECEIVED,
|
HeadersReceived,
|
||||||
LOADING,
|
Loading,
|
||||||
DONE,
|
Done,
|
||||||
CANCELLED
|
Cancelled
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -116,7 +116,7 @@ export class Http {
|
||||||
if (isString(url)) {
|
if (isString(url)) {
|
||||||
responseObservable = httpRequest(
|
responseObservable = httpRequest(
|
||||||
this._backend,
|
this._backend,
|
||||||
new Request(mergeOptions(this._defaultOptions, options, RequestMethods.GET, url)));
|
new Request(mergeOptions(this._defaultOptions, options, RequestMethods.Get, url)));
|
||||||
} else if (url instanceof Request) {
|
} else if (url instanceof Request) {
|
||||||
responseObservable = httpRequest(this._backend, url);
|
responseObservable = httpRequest(this._backend, url);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ export class Http {
|
||||||
*/
|
*/
|
||||||
get(url: string, options?: RequestOptionsArgs): EventEmitter {
|
get(url: string, options?: RequestOptionsArgs): EventEmitter {
|
||||||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
||||||
RequestMethods.GET, url)));
|
RequestMethods.Get, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +138,7 @@ export class Http {
|
||||||
return httpRequest(
|
return httpRequest(
|
||||||
this._backend,
|
this._backend,
|
||||||
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
||||||
options, RequestMethods.POST, url)));
|
options, RequestMethods.Post, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +148,7 @@ export class Http {
|
||||||
return httpRequest(
|
return httpRequest(
|
||||||
this._backend,
|
this._backend,
|
||||||
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
||||||
options, RequestMethods.PUT, url)));
|
options, RequestMethods.Put, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +156,7 @@ export class Http {
|
||||||
*/
|
*/
|
||||||
delete (url: string, options?: RequestOptionsArgs): EventEmitter {
|
delete (url: string, options?: RequestOptionsArgs): EventEmitter {
|
||||||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
||||||
RequestMethods.DELETE, url)));
|
RequestMethods.Delete, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +166,7 @@ export class Http {
|
||||||
return httpRequest(
|
return httpRequest(
|
||||||
this._backend,
|
this._backend,
|
||||||
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})),
|
||||||
options, RequestMethods.PATCH, url)));
|
options, RequestMethods.Patch, url)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,7 +174,7 @@ export class Http {
|
||||||
*/
|
*/
|
||||||
head(url: string, options?: RequestOptionsArgs): EventEmitter {
|
head(url: string, options?: RequestOptionsArgs): EventEmitter {
|
||||||
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options,
|
||||||
RequestMethods.HEAD, url)));
|
RequestMethods.Head, url)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,10 +193,10 @@ export class Jsonp extends Http {
|
||||||
request(url: string | Request, options?: RequestOptionsArgs): EventEmitter {
|
request(url: string | Request, options?: RequestOptionsArgs): EventEmitter {
|
||||||
var responseObservable: EventEmitter;
|
var responseObservable: EventEmitter;
|
||||||
if (isString(url)) {
|
if (isString(url)) {
|
||||||
url = new Request(mergeOptions(this._defaultOptions, options, RequestMethods.GET, url));
|
url = new Request(mergeOptions(this._defaultOptions, options, RequestMethods.Get, url));
|
||||||
}
|
}
|
||||||
if (url instanceof Request) {
|
if (url instanceof Request) {
|
||||||
if (url.method !== RequestMethods.GET) {
|
if (url.method !== RequestMethods.Get) {
|
||||||
makeTypeError('JSONP requests must use GET request method.');
|
makeTypeError('JSONP requests must use GET request method.');
|
||||||
}
|
}
|
||||||
responseObservable = httpRequest(this._backend, url);
|
responseObservable = httpRequest(this._backend, url);
|
||||||
|
|
|
@ -15,7 +15,7 @@ export function main() {
|
||||||
argumentToPureFunction?: boolean
|
argumentToPureFunction?: boolean
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (isBlank(lastInBinding)) lastInBinding = false;
|
if (isBlank(lastInBinding)) lastInBinding = false;
|
||||||
if (isBlank(mode)) mode = RecordType.PROPERTY_READ;
|
if (isBlank(mode)) mode = RecordType.PropertyRead;
|
||||||
if (isBlank(name)) name = "name";
|
if (isBlank(name)) name = "name";
|
||||||
if (isBlank(directiveIndex)) directiveIndex = null;
|
if (isBlank(directiveIndex)) directiveIndex = null;
|
||||||
if (isBlank(argumentToPureFunction)) argumentToPureFunction = false;
|
if (isBlank(argumentToPureFunction)) argumentToPureFunction = false;
|
||||||
|
@ -62,7 +62,7 @@ export function main() {
|
||||||
var rs = coalesce(
|
var rs = coalesce(
|
||||||
[r("user", [], 0, 1, {lastInBinding: true}), r("user", [], 0, 2, {lastInBinding: true})]);
|
[r("user", [], 0, 1, {lastInBinding: true}), r("user", [], 0, 2, {lastInBinding: true})]);
|
||||||
|
|
||||||
expect(rs[1]).toEqual(new ProtoRecord(RecordType.SELF, "self", null, [], null, 1, null, 2,
|
expect(rs[1]).toEqual(new ProtoRecord(RecordType.Self, "self", null, [], null, 1, null, 2,
|
||||||
null, true, false, false, false, 0));
|
null, true, false, false, false, 0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ export function main() {
|
||||||
|
|
||||||
it("should not coalesce directive lifecycle records", () => {
|
it("should not coalesce directive lifecycle records", () => {
|
||||||
var rs = coalesce([
|
var rs = coalesce([
|
||||||
r("onCheck", [], 0, 1, {mode: RecordType.DIRECTIVE_LIFECYCLE}),
|
r("onCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle}),
|
||||||
r("onCheck", [], 0, 1, {mode: RecordType.DIRECTIVE_LIFECYCLE})
|
r("onCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(rs.length).toEqual(2);
|
expect(rs.length).toEqual(2);
|
||||||
|
|
|
@ -14,7 +14,7 @@ export function main() {
|
||||||
referencedBySelf?: boolean
|
referencedBySelf?: boolean
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (isBlank(lastInBinding)) lastInBinding = false;
|
if (isBlank(lastInBinding)) lastInBinding = false;
|
||||||
if (isBlank(mode)) mode = RecordType.PROPERTY_READ;
|
if (isBlank(mode)) mode = RecordType.PropertyRead;
|
||||||
if (isBlank(name)) name = "name";
|
if (isBlank(name)) name = "name";
|
||||||
if (isBlank(directiveIndex)) directiveIndex = null;
|
if (isBlank(directiveIndex)) directiveIndex = null;
|
||||||
if (isBlank(argumentToPureFunction)) argumentToPureFunction = false;
|
if (isBlank(argumentToPureFunction)) argumentToPureFunction = false;
|
||||||
|
@ -26,21 +26,20 @@ export function main() {
|
||||||
|
|
||||||
describe("ProtoRecord", () => {
|
describe("ProtoRecord", () => {
|
||||||
describe('shouldBeChecked', () => {
|
describe('shouldBeChecked', () => {
|
||||||
it('should be true for pure functions', () => {
|
it('should be true for pure functions',
|
||||||
expect(r({mode: RecordType.COLLECTION_LITERAL}).shouldBeChecked()).toBeTruthy();
|
() => { expect(r({mode: RecordType.CollectionLiteral}).shouldBeChecked()).toBeTruthy(); });
|
||||||
});
|
|
||||||
|
|
||||||
it('should be true for args of pure functions', () => {
|
it('should be true for args of pure functions', () => {
|
||||||
expect(r({mode: RecordType.CONST, argumentToPureFunction: true}).shouldBeChecked())
|
expect(r({mode: RecordType.Const, argumentToPureFunction: true}).shouldBeChecked())
|
||||||
.toBeTruthy();
|
.toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be true for last in binding records', () => {
|
it('should be true for last in binding records', () => {
|
||||||
expect(r({mode: RecordType.CONST, lastInBinding: true}).shouldBeChecked()).toBeTruthy();
|
expect(r({mode: RecordType.Const, lastInBinding: true}).shouldBeChecked()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be false otherwise',
|
it('should be false otherwise',
|
||||||
() => { expect(r({mode: RecordType.CONST}).shouldBeChecked()).toBeFalsy(); });
|
() => { expect(r({mode: RecordType.Const}).shouldBeChecked()).toBeFalsy(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isUsedByOtherRecord', () => {
|
describe('isUsedByOtherRecord', () => {
|
||||||
|
|
|
@ -106,7 +106,7 @@ export function main() {
|
||||||
|
|
||||||
ObservableWrapper.subscribe(connection.response, loadSpy, errorSpy, returnSpy);
|
ObservableWrapper.subscribe(connection.response, loadSpy, errorSpy, returnSpy);
|
||||||
connection.dispose();
|
connection.dispose();
|
||||||
expect(connection.readyState).toBe(ReadyStates.CANCELLED);
|
expect(connection.readyState).toBe(ReadyStates.Cancelled);
|
||||||
|
|
||||||
connection.finished('Fake data');
|
connection.finished('Fake data');
|
||||||
existingScripts[0].dispatchEvent('load');
|
existingScripts[0].dispatchEvent('load');
|
||||||
|
@ -153,8 +153,8 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should throw if request method is not GET', () => {
|
it('should throw if request method is not GET', () => {
|
||||||
[RequestMethods.POST, RequestMethods.PUT, RequestMethods.DELETE, RequestMethods.OPTIONS,
|
[RequestMethods.Post, RequestMethods.Put, RequestMethods.Delete, RequestMethods.Options,
|
||||||
RequestMethods.HEAD, RequestMethods.PATCH]
|
RequestMethods.Head, RequestMethods.Patch]
|
||||||
.forEach(method => {
|
.forEach(method => {
|
||||||
let base = new BaseRequestOptions();
|
let base = new BaseRequestOptions();
|
||||||
let req = new Request(
|
let req = new Request(
|
||||||
|
|
|
@ -16,17 +16,17 @@ export function main() {
|
||||||
describe('BaseRequestOptions', () => {
|
describe('BaseRequestOptions', () => {
|
||||||
it('should create a new object when calling merge', () => {
|
it('should create a new object when calling merge', () => {
|
||||||
var options1 = new BaseRequestOptions();
|
var options1 = new BaseRequestOptions();
|
||||||
var options2 = options1.merge(new RequestOptions({method: RequestMethods.DELETE}));
|
var options2 = options1.merge(new RequestOptions({method: RequestMethods.Delete}));
|
||||||
expect(options2).not.toBe(options1);
|
expect(options2).not.toBe(options1);
|
||||||
expect(options2.method).toBe(RequestMethods.DELETE);
|
expect(options2.method).toBe(RequestMethods.Delete);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should retain previously merged values when merging again', () => {
|
it('should retain previously merged values when merging again', () => {
|
||||||
var options1 = new BaseRequestOptions();
|
var options1 = new BaseRequestOptions();
|
||||||
var options2 = options1.merge(new RequestOptions({method: RequestMethods.DELETE}));
|
var options2 = options1.merge(new RequestOptions({method: RequestMethods.Delete}));
|
||||||
var options3 = options2.merge(new RequestOptions({mode: RequestModesOpts.NoCors}));
|
var options3 = options2.merge(new RequestOptions({mode: RequestModesOpts.NoCors}));
|
||||||
expect(options3.mode).toBe(RequestModesOpts.NoCors);
|
expect(options3.mode).toBe(RequestModesOpts.NoCors);
|
||||||
expect(options3.method).toBe(RequestMethods.DELETE);
|
expect(options3.method).toBe(RequestMethods.Delete);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ export function main() {
|
||||||
describe('.get()', () => {
|
describe('.get()', () => {
|
||||||
it('should perform a get request for given url', inject([AsyncTestCompleter], async => {
|
it('should perform a get request for given url', inject([AsyncTestCompleter], async => {
|
||||||
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
||||||
expect(c.request.method).toBe(RequestMethods.GET);
|
expect(c.request.method).toBe(RequestMethods.Get);
|
||||||
backend.resolveAllConnections();
|
backend.resolveAllConnections();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -178,7 +178,7 @@ export function main() {
|
||||||
describe('.post()', () => {
|
describe('.post()', () => {
|
||||||
it('should perform a post request for given url', inject([AsyncTestCompleter], async => {
|
it('should perform a post request for given url', inject([AsyncTestCompleter], async => {
|
||||||
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
||||||
expect(c.request.method).toBe(RequestMethods.POST);
|
expect(c.request.method).toBe(RequestMethods.Post);
|
||||||
backend.resolveAllConnections();
|
backend.resolveAllConnections();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -201,7 +201,7 @@ export function main() {
|
||||||
describe('.put()', () => {
|
describe('.put()', () => {
|
||||||
it('should perform a put request for given url', inject([AsyncTestCompleter], async => {
|
it('should perform a put request for given url', inject([AsyncTestCompleter], async => {
|
||||||
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
||||||
expect(c.request.method).toBe(RequestMethods.PUT);
|
expect(c.request.method).toBe(RequestMethods.Put);
|
||||||
backend.resolveAllConnections();
|
backend.resolveAllConnections();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -223,7 +223,7 @@ export function main() {
|
||||||
describe('.delete()', () => {
|
describe('.delete()', () => {
|
||||||
it('should perform a delete request for given url', inject([AsyncTestCompleter], async => {
|
it('should perform a delete request for given url', inject([AsyncTestCompleter], async => {
|
||||||
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
||||||
expect(c.request.method).toBe(RequestMethods.DELETE);
|
expect(c.request.method).toBe(RequestMethods.Delete);
|
||||||
backend.resolveAllConnections();
|
backend.resolveAllConnections();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -235,7 +235,7 @@ export function main() {
|
||||||
describe('.patch()', () => {
|
describe('.patch()', () => {
|
||||||
it('should perform a patch request for given url', inject([AsyncTestCompleter], async => {
|
it('should perform a patch request for given url', inject([AsyncTestCompleter], async => {
|
||||||
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
||||||
expect(c.request.method).toBe(RequestMethods.PATCH);
|
expect(c.request.method).toBe(RequestMethods.Patch);
|
||||||
backend.resolveAllConnections();
|
backend.resolveAllConnections();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -257,7 +257,7 @@ export function main() {
|
||||||
describe('.head()', () => {
|
describe('.head()', () => {
|
||||||
it('should perform a head request for given url', inject([AsyncTestCompleter], async => {
|
it('should perform a head request for given url', inject([AsyncTestCompleter], async => {
|
||||||
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
ObservableWrapper.subscribe<MockConnection>(backend.connections, c => {
|
||||||
expect(c.request.method).toBe(RequestMethods.HEAD);
|
expect(c.request.method).toBe(RequestMethods.Head);
|
||||||
backend.resolveAllConnections();
|
backend.resolveAllConnections();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -225,10 +225,8 @@ exports.createBenchpressRunner = function(options) {
|
||||||
var bindings = [
|
var bindings = [
|
||||||
benchpress.SeleniumWebDriverAdapter.PROTRACTOR_BINDINGS,
|
benchpress.SeleniumWebDriverAdapter.PROTRACTOR_BINDINGS,
|
||||||
benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']),
|
benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']),
|
||||||
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({
|
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION)
|
||||||
'lang': options.lang,
|
.toValue({'lang': options.lang, 'runId': runId}),
|
||||||
'runId': runId
|
|
||||||
}),
|
|
||||||
benchpress.JsonFileReporter.BINDINGS,
|
benchpress.JsonFileReporter.BINDINGS,
|
||||||
benchpress.bind(benchpress.JsonFileReporter.PATH).toValue(resultsFolder)
|
benchpress.bind(benchpress.JsonFileReporter.PATH).toValue(resultsFolder)
|
||||||
];
|
];
|
||||||
|
|
|
@ -69,10 +69,10 @@ export class TreeDiffer {
|
||||||
let relativeFilePath = path.relative(this.rootPath, absolutePath);
|
let relativeFilePath = path.relative(this.rootPath, absolutePath);
|
||||||
|
|
||||||
switch (this.isFileDirty(absolutePath, pathStat)) {
|
switch (this.isFileDirty(absolutePath, pathStat)) {
|
||||||
case FileStatus.ADDED:
|
case FileStatus.Added:
|
||||||
result.addedPaths.push(relativeFilePath);
|
result.addedPaths.push(relativeFilePath);
|
||||||
break;
|
break;
|
||||||
case FileStatus.CHANGED:
|
case FileStatus.Changed:
|
||||||
result.changedPaths.push(relativeFilePath);
|
result.changedPaths.push(relativeFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,13 +94,13 @@ export class TreeDiffer {
|
||||||
|
|
||||||
if (oldFingerprint === newFingerprint) {
|
if (oldFingerprint === newFingerprint) {
|
||||||
// nothing changed
|
// nothing changed
|
||||||
return FileStatus.UNCHANGED;
|
return FileStatus.Unchanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FileStatus.CHANGED;
|
return FileStatus.Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FileStatus.ADDED;
|
return FileStatus.Added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ function pad(value, length) {
|
||||||
|
|
||||||
|
|
||||||
enum FileStatus {
|
enum FileStatus {
|
||||||
ADDED,
|
Added,
|
||||||
UNCHANGED,
|
Unchanged,
|
||||||
CHANGED
|
Changed
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue