mirror of
https://github.com/gnu4cn/ts-learnings.git
synced 2024-12-26 12:50:31 +08:00
put dist/* into .gitignore.
This commit is contained in:
parent
81dbb846c4
commit
d6f994a7da
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
dist/*
|
||||
_book/*
|
||||
|
||||
# Runtime data
|
||||
|
43
dist/accessor_decorators.js
vendored
43
dist/accessor_decorators.js
vendored
@ -1,43 +0,0 @@
|
||||
'use strict';
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
// 访问器装饰器,Accessor Decorator
|
||||
var Point = /** @class */ (function () {
|
||||
function Point(x, y) {
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
}
|
||||
Object.defineProperty(Point.prototype, "x", {
|
||||
get: function () { return this._x; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Point.prototype, "y", {
|
||||
get: function () { return this._y; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
configurable(false),
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [])
|
||||
], Point.prototype, "x", null);
|
||||
__decorate([
|
||||
configurable(false),
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [])
|
||||
], Point.prototype, "y", null);
|
||||
return Point;
|
||||
}());
|
||||
function configurable(value) {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
descriptor.configurable = value;
|
||||
};
|
||||
}
|
56
dist/metadata.js
vendored
56
dist/metadata.js
vendored
@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("reflect-metadata");
|
||||
var Point = /** @class */ (function () {
|
||||
function Point() {
|
||||
}
|
||||
return Point;
|
||||
}());
|
||||
var Line = /** @class */ (function () {
|
||||
function Line() {
|
||||
}
|
||||
Object.defineProperty(Line.prototype, "p0", {
|
||||
get: function () { return this._p0; },
|
||||
set: function (value) { this._p0 = value; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Line.prototype, "p1", {
|
||||
get: function () { return this._p1; },
|
||||
set: function (value) { this._p1 = value; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
__decorate([
|
||||
validate,
|
||||
__metadata("design:type", Point),
|
||||
__metadata("design:paramtypes", [Point])
|
||||
], Line.prototype, "p0", null);
|
||||
__decorate([
|
||||
validate,
|
||||
__metadata("design:type", Point),
|
||||
__metadata("design:paramtypes", [Point])
|
||||
], Line.prototype, "p1", null);
|
||||
return Line;
|
||||
}());
|
||||
function validate(target, propertyKey, descriptor) {
|
||||
var set = descriptor.set;
|
||||
descriptor.set = function (value) {
|
||||
var type = Reflect.getMetadata("design:type", target, propertyKey);
|
||||
if (!(value instanceof type)) {
|
||||
throw new TypeError("无效的类型。");
|
||||
}
|
||||
set(value);
|
||||
};
|
||||
}
|
||||
var l1 = new Line();
|
||||
console.log(l1);
|
47
dist/mixins_example.js
vendored
47
dist/mixins_example.js
vendored
@ -1,47 +0,0 @@
|
||||
// 一个名为 Disposable 的混入
|
||||
var Disposable = /** @class */ (function () {
|
||||
function Disposable() {
|
||||
}
|
||||
Disposable.prototype.dispose = function () {
|
||||
this.isDisposable = true;
|
||||
};
|
||||
return Disposable;
|
||||
}());
|
||||
// 一个名为 Activatable 的混入
|
||||
var Activatable = /** @class */ (function () {
|
||||
function Activatable() {
|
||||
}
|
||||
Activatable.prototype.activate = function () {
|
||||
this.isActive = true;
|
||||
};
|
||||
Activatable.prototype.deactivate = function () {
|
||||
this.isActive = false;
|
||||
};
|
||||
return Activatable;
|
||||
}());
|
||||
var SmartObject = /** @class */ (function () {
|
||||
function SmartObject() {
|
||||
var _this = this;
|
||||
// Disposable
|
||||
this.isDisposable = false;
|
||||
// Activatable
|
||||
this.isActive = false;
|
||||
setInterval(function () {
|
||||
console.log(_this.isActive + " : " + _this.isDisposable);
|
||||
}, 500);
|
||||
}
|
||||
SmartObject.prototype.interact = function () {
|
||||
this.activate();
|
||||
};
|
||||
return SmartObject;
|
||||
}());
|
||||
applyMixins(SmartObject, [Disposable, Activatable]);
|
||||
var smartObj = new SmartObject();
|
||||
setTimeout(function () { return smartObj.interact(); }, 1000);
|
||||
function applyMixins(derivedCtor, baseCtors) {
|
||||
baseCtors.forEach(function (baseCtor) {
|
||||
Object.getOwnPropertyNames(baseCtor.prototype).forEach(function (name) {
|
||||
derivedCtor.prototype[name] = baseCtor.prototype[name];
|
||||
});
|
||||
});
|
||||
}
|
54
dist/parameter_decorators.js
vendored
54
dist/parameter_decorators.js
vendored
@ -1,54 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("reflect-metadata");
|
||||
var Greeter = /** @class */ (function () {
|
||||
function Greeter(message) {
|
||||
this.greeting = message;
|
||||
}
|
||||
Greeter.prototype.greet = function (name) {
|
||||
return "Hello " + name + ", " + this.greeting;
|
||||
};
|
||||
__decorate([
|
||||
validate,
|
||||
__param(0, required),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], Greeter.prototype, "greet", null);
|
||||
return Greeter;
|
||||
}());
|
||||
var requiredMetadataKey;
|
||||
function required(target, propertyKey, parameterIndex) {
|
||||
var existingRequiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target, propertyKey) || [];
|
||||
existingRequiredParameters.push(parameterIndex);
|
||||
Reflect.defineMetadata(requiredMetadataKey, existingRequiredParameters, target, propertyKey);
|
||||
}
|
||||
function validate(target, propertyName, descriptor) {
|
||||
var method = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
var requiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target, propertyName);
|
||||
if (requiredParameters) {
|
||||
for (var _i = 0, requiredParameters_1 = requiredParameters; _i < requiredParameters_1.length; _i++) {
|
||||
var parameterIndex = requiredParameters_1[_i];
|
||||
if (parameterIndex >= arguments.length || arguments[parameterIndex] === undefined) {
|
||||
throw new Error("缺少需要的参数。");
|
||||
}
|
||||
}
|
||||
}
|
||||
return method.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
var g = new Greeter("早上好");
|
||||
console.log(g.greet("Echo Feng"));
|
36
dist/property_decorators.js
vendored
36
dist/property_decorators.js
vendored
@ -1,36 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("reflect-metadata");
|
||||
// 属性装饰器,property decorator
|
||||
var Greeter = /** @class */ (function () {
|
||||
function Greeter(message) {
|
||||
this.greeting = message;
|
||||
}
|
||||
Greeter.prototype.greet = function () {
|
||||
var formatString = getFormat(this, "greeting");
|
||||
return formatString.replace("%s", this.greeting);
|
||||
};
|
||||
__decorate([
|
||||
format("Hello, %s"),
|
||||
__metadata("design:type", String)
|
||||
], Greeter.prototype, "greeting", void 0);
|
||||
return Greeter;
|
||||
}());
|
||||
var formatMetadataKey;
|
||||
function format(formatString) {
|
||||
return Reflect.metadata(formatMetadataKey, formatString);
|
||||
}
|
||||
function getFormat(target, propertyKey) {
|
||||
return Reflect.getMetadata(formatMetadataKey, target, propertyKey);
|
||||
}
|
||||
var g = new Greeter("彭海林");
|
||||
console.log(g.greet());
|
2
dist/reference.lib.js
vendored
2
dist/reference.lib.js
vendored
@ -1,2 +0,0 @@
|
||||
/// <reference lib="es2017.string" />
|
||||
console.log("foo".padStart(4));
|
2
dist/symbol.js
vendored
2
dist/symbol.js
vendored
@ -1,2 +0,0 @@
|
||||
var a;
|
||||
console.log(a);
|
Loading…
Reference in New Issue
Block a user