Skip to content

Commit 771cd45

Browse files
committed
General cleanup.
1 parent cb54fc1 commit 771cd45

8 files changed

+147
-98
lines changed

.gitignore

-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
11
node_modules/
2-
built/*
3-
~*.docx
4-
*.swp
5-
build.json
6-
*.actual
7-
*.config
8-
coverage/
9-
internal/
10-
**/.DS_Store

README.md

+33-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,47 @@
55

66
This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions.
77

8-
# TypeScript
8+
# Installing
99

10-
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang).
10+
For the latest stable version:
1111

12+
```
13+
npm install tslib
14+
```
15+
16+
# Usage
17+
18+
Set the `noEmitHelpers` compiler option on the command line or in your tsconfig.json:
19+
```
20+
tsc --noEmitHelpers
21+
```
22+
23+
Import tslib in your TypeScript sources:
24+
```ts
25+
import * as tslib from "tslib";
26+
27+
const __extends = tslib.__extends;
28+
const __awaiter = tslib.__awaiter;
29+
30+
...
31+
```
32+
33+
Or use it globally on the web via `<script src="tslib.js"></script>`:
34+
35+
```ts
36+
// <reference path="tslib.global.d.ts" />
37+
var __extends = __tslib.__extends;
38+
var __awaiter = __tslib.__awaiter;
39+
40+
...
41+
```
1242

1343
## Contribute
1444

1545
There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
1646
* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
1747
* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
18-
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
48+
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
1949
* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
2050
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
2151
* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)).

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
"type": "git",
2626
"url": "https://github.com/Microsoft/TypeScript-Runtime.git"
2727
},
28-
"main": "./tslib.js",
29-
"typings": "./tslib.d.ts"
28+
"main": "tslib.js",
29+
"typings": "tslib.d.ts"
3030
}

tslib.d.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
/*! *****************************************************************************
2-
Copyright (c) Microsoft Corporation. All rights reserved.
2+
Copyright (c) Microsoft Corporation. All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
44
this file except in compliance with the License. You may obtain a copy of the
5-
License at http://www.apache.org/licenses/LICENSE-2.0
6-
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
77
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
88
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10-
MERCHANTABLITY OR NON-INFRINGEMENT.
11-
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
1212
See the Apache Version 2.0 License for specific language governing permissions
1313
and limitations under the License.
1414
***************************************************************************** */
1515
export declare function __extends(d: Function, b: Function): void;
16-
export declare function __decorate(decorators: Function[], target: any, propertyKey?: string | symbol, propertyDescriptor?: any): any;
17-
export declare function __param(index: number, decorator: Function): Function;
16+
export declare function __assign(t: any, ...sources: any[]): any;
17+
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
18+
export declare function __param(paramIndex: number, decorator: Function): Function;
1819
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
19-
export declare function __awaiter(generator: any, ctor?: Function): any;
20+
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;

tslib.es6.d.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/*! *****************************************************************************
2-
Copyright (c) Microsoft Corporation. All rights reserved.
2+
Copyright (c) Microsoft Corporation. All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
44
this file except in compliance with the License. You may obtain a copy of the
5-
License at http://www.apache.org/licenses/LICENSE-2.0
6-
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
77
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
88
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10-
MERCHANTABLITY OR NON-INFRINGEMENT.
11-
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
1212
See the Apache Version 2.0 License for specific language governing permissions
1313
and limitations under the License.
1414
***************************************************************************** */
15-
export declare function __decorate(decorators: Function[], target: any, propertyKey?: string | symbol, propertyDescriptor?: any): any;
16-
export declare function __param(index: number, decorator: Function): Function;
15+
export declare function __assign(t: any, ...sources: any[]): any;
16+
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
17+
export declare function __param(paramIndex: number, decorator: Function): Function;
1718
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
18-
export declare function __awaiter(generator: any, ctor?: Function): any;
19+
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;

tslib.es6.js

+29-26
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
/*! *****************************************************************************
2-
Copyright (c) Microsoft Corporation. All rights reserved.
2+
Copyright (c) Microsoft Corporation. All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
44
this file except in compliance with the License. You may obtain a copy of the
5-
License at http://www.apache.org/licenses/LICENSE-2.0
6-
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
77
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
88
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10-
MERCHANTABLITY OR NON-INFRINGEMENT.
11-
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
1212
See the Apache Version 2.0 License for specific language governing permissions
1313
and limitations under the License.
1414
***************************************************************************** */
1515
/* global Reflect, Promise */
16-
export function __decorate(decorators, target, key, desc) {
16+
export const __assign = Object.assign || function (t) {
17+
for (var s, i = 1, n = arguments.length; i < n; i++) {
18+
s = arguments[i];
19+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
20+
}
21+
return t;
22+
};
23+
24+
export const __decorate = function (decorators, target, key, desc) {
1725
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1826
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1927
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;
2028
return c > 3 && r && Object.defineProperty(target, key, r), r;
21-
}
29+
};
2230

23-
export function __param(paramIndex, decorator) {
31+
export const __param = function (paramIndex, decorator) {
2432
return function (target, key) { decorator(target, key, paramIndex); }
25-
}
26-
27-
export function __metadata(metadataKey, metadataValue) {
33+
};
34+
35+
export const __metadata = function (metadataKey, metadataValue) {
2836
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
29-
}
30-
31-
export function __awaiter(thisArg, _arguments, Promise, generator) {
32-
return new Promise(function (resolve, reject) {
33-
generator = generator.call(thisArg, _arguments);
34-
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
35-
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
36-
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
37-
function step(verb, value) {
38-
var result = generator[verb](value);
39-
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
40-
}
41-
step("next", void 0);
37+
};
38+
39+
export const __awaiter = function (thisArg, _arguments, P, generator) {
40+
return new (P || (P = Promise))(function (resolve, reject) {
41+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42+
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
43+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
44+
step((generator = generator.apply(thisArg, _arguments)).next());
4245
});
43-
}
46+
};

tslib.global.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
declare namespace __tslib {
16+
function __extends(d: Function, b: Function): void;
17+
function __assign(t: any, ...sources: any[]): any;
18+
function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
19+
function __param(paramIndex: number, decorator: Function): Function;
20+
function __metadata(metadataKey: any, metadataValue: any): Function;
21+
function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
22+
}

tslib.js

+41-40
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,77 @@
11
/*! *****************************************************************************
2-
Copyright (c) Microsoft Corporation. All rights reserved.
2+
Copyright (c) Microsoft Corporation. All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
44
this file except in compliance with the License. You may obtain a copy of the
5-
License at http://www.apache.org/licenses/LICENSE-2.0
6-
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
77
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
88
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10-
MERCHANTABLITY OR NON-INFRINGEMENT.
11-
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
1212
See the Apache Version 2.0 License for specific language governing permissions
1313
and limitations under the License.
1414
***************************************************************************** */
1515
/* global global, define, System, Reflect, Promise */
16-
(function (factory, root) {
17-
function exporter(exports, prev) { return function (id, v) { return exports[id] = prev ? prev(id, v) : v; }; }
18-
function linker(exports) { return factory(exporter(root, exporter(exports))); }
16+
var __tslib;
17+
(function (factory) {
1918
if (typeof System === 'object' && typeof System.register === 'function') {
20-
System.register([], function(_export) {
21-
factory(exporter(root, _export));
22-
return { setters: [], execute: function() { } };
23-
});
19+
System.register([], function (exporter) { return factory(exporter), { setters: [], execute: function() { } }; });
2420
}
2521
else if (typeof module === 'object' && typeof module.exports === 'object') {
26-
linker(exports);
22+
factory(function (id, v) { exports[id] = v; });
2723
}
2824
else if (typeof define === 'function' && define.amd) {
29-
define(["exports"], linker);
25+
define("tslib", ["exports"], function (exports) { factory(function (id, v) { exports[id] = v; }); });
3026
}
3127
else {
32-
factory(exporter(root));
28+
__tslib = { };
29+
factory(function (id, v) { __tslib[id] = v; });
3330
}
3431
})
3532
(function (exporter) {
36-
function __extends(d, b) {
33+
var __extends = function (d, b) {
3734
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3835
function __() { this.constructor = d; }
3936
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40-
}
41-
42-
function __decorate(decorators, target, key, desc) {
37+
};
38+
39+
var __assign = Object.assign || function(t) {
40+
for (var s, i = 1, n = arguments.length; i < n; i++) {
41+
s = arguments[i];
42+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43+
}
44+
return t;
45+
};
46+
47+
var __decorate = function (decorators, target, key, desc) {
4348
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4449
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4550
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;
4651
return c > 3 && r && Object.defineProperty(target, key, r), r;
47-
}
52+
};
4853

49-
function __param(paramIndex, decorator) {
54+
var __param = function (paramIndex, decorator) {
5055
return function (target, key) { decorator(target, key, paramIndex); }
51-
}
52-
53-
function __metadata(metadataKey, metadataValue) {
56+
};
57+
58+
var __metadata = function (metadataKey, metadataValue) {
5459
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
55-
}
56-
57-
function __awaiter(thisArg, _arguments, Promise, generator) {
58-
return new Promise(function (resolve, reject) {
59-
generator = generator.call(thisArg, _arguments);
60-
function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
61-
function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
62-
function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
63-
function step(verb, value) {
64-
var result = generator[verb](value);
65-
result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
66-
}
67-
step("next", void 0);
60+
};
61+
62+
var __awaiter = function (thisArg, _arguments, P, generator) {
63+
return new (P || (P = Promise))(function (resolve, reject) {
64+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
65+
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
66+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
67+
step((generator = generator.apply(thisArg, _arguments)).next());
6868
});
69-
}
69+
};
7070

7171
exporter('__extends', __extends);
72+
exporter('__assign', __assign);
7273
exporter('__decorate', __decorate);
7374
exporter('__param', __param);
7475
exporter('__metadata', __metadata);
7576
exporter('__awaiter', __awaiter);
76-
}, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : this);
77+
});

0 commit comments

Comments
 (0)