Skip to content

Commit b16d839

Browse files
authored
Reconfigure ReSub so that everyone consumes compiled TS source (microsoft#1)
Change so that on pre-publish we compile the TS source Update lodash so that we support 3.x & 4.x branches. Remove un-needed node.d.ts file, it was only used for the definition of assert Added an .npmignore which is very similar to .gitignore, only differing in that we can publish /dist Bump version to 0.0.7
1 parent 3999239 commit b16d839

14 files changed

+18039
-9347
lines changed

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
/src/.vs
3+
/src/bin
4+
/src/obj
5+
*.user
6+
/ReSubTestsPack.js

index.android.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

index.ios.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
* Points at typescript source for using with webpack/TSC.
66
*/
77

8-
var resub = require('./src/ReSub');
8+
var resub = require('./dist/src/ReSub');
99
module.exports = resub;

index.windows.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
{
22
"name": "resub",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "A library for writing React components that automatically manage subscriptions to data sources simply by accessing them.",
55
"author": "David de Regt <[email protected]>",
66
"scripts": {
7-
"postinstall": "tsc",
7+
"prepublish": "tsc",
88
"webtestbuild": "webpack",
99
"build": "tsc"
1010
},
1111
"dependencies": {
1212
"assert": "^1.4.1",
13-
"lodash": "^3.10.1",
14-
"react": "^15.0.0",
15-
"ts-loader": "^0.8.2",
16-
"typescript": "^2.0.0"
13+
"lodash": "3.x || 4.x"
14+
},
15+
"peerDependencies": {
16+
"react": "^15.0.0"
1717
},
1818
"devDependencies": {
1919
"mocha": "^2.3.4",
2020
"react-addons-test-utils": "^15.0.0",
2121
"ts-loader": "^0.8.2",
22+
"typescript": "^2.0.0",
2223
"webpack": "^1.12.14"
2324
},
2425
"repository": {
2526
"type": "git",
2627
"url": "https://github.com/Microsoft/ReSub"
2728
},
29+
"main": "index.js",
2830
"bugs": {
2931
"url": "https://github.com/Microsoft/ReSub/issues"
3032
},

src/ComponentBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ abstract class ComponentBase<P extends React.Props<any>, S extends Object> exten
383383

384384
// Check if we already handle a subscription (auto) for store with key.
385385
private _hasMatchingAutoSubscription(store: StoreBase, key: string) {
386-
return _.any(this._handledAutoSubscriptions, sub => {
386+
return _.some(this._handledAutoSubscriptions, sub => {
387387
if (sub.store.storeId === store.storeId && (sub.key === key || sub.key === StoreBase.Key_All)) {
388388
sub.used = true;
389389
return true;

src/MapShim.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class MapShim<K, V> implements Map<K, V> {
6969
}
7070

7171
has(key: K): boolean {
72-
return _.any(this._mapShimItems, item => item.key === key);
72+
return _.some(this._mapShimItems, item => item.key === key);
7373
}
7474

7575
set(key: K, value?: V): Map<K, V> {
@@ -81,7 +81,7 @@ class MapShim<K, V> implements Map<K, V> {
8181
this.size++;
8282
}
8383
return this;
84-
}
84+
}
8585
}
8686

8787
export default (typeof Map !== 'undefined' ? Map : MapShim) as MapConstructor;

src/Options.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Author: David de Regt
44
* Copyright: Microsoft 2015
55
*
6-
* Basic options for ReSub.
6+
* Basic options for ReSub.
77
*/
88

99
import _ = require('lodash');
@@ -18,9 +18,9 @@ export interface IOptions {
1818
};
1919

2020
let OptionsVals: IOptions = {
21-
setTimeout: _.bind(setTimeout, null),
22-
clearTimeout: _.bind(clearTimeout, null),
23-
21+
setTimeout: setTimeout.bind(null),
22+
clearTimeout: clearTimeout.bind(null),
23+
2424
development: true
2525
};
2626

src/StoreBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export abstract class StoreBase {
185185

186186
storedCallbacks.forEach((keys, callback) => {
187187
// Do a quick dedupe on keys
188-
const uniquedKeys = keys ? _.unique(keys) : keys;
188+
const uniquedKeys = keys ? _.uniq(keys) : keys;
189189
callback(uniquedKeys);
190190
});
191191
};

src/typings/assert.d.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Type definitions for assert and power-assert
2+
// Project: https://github.com/Jxck/assert
3+
// Project: https://github.com/twada/power-assert
4+
// Definitions by: vvakame <https://github.com/vvakame>
5+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6+
7+
// copy from assert external module in node.d.ts
8+
9+
declare function assert(value:any, message?:string):void;
10+
declare namespace assert {
11+
export class AssertionError implements Error {
12+
name:string;
13+
message:string;
14+
actual:any;
15+
expected:any;
16+
operator:string;
17+
generatedMessage:boolean;
18+
19+
constructor(options?:{message?: string; actual?: any; expected?: any; operator?: string; stackStartFunction?: Function});
20+
}
21+
22+
export function fail(actual?:any, expected?:any, message?:string, operator?:string):void;
23+
24+
export function ok(value:any, message?:string):void;
25+
26+
export function equal(actual:any, expected:any, message?:string):void;
27+
28+
export function notEqual(actual:any, expected:any, message?:string):void;
29+
30+
export function deepEqual(actual:any, expected:any, message?:string):void;
31+
32+
export function notDeepEqual(acutal:any, expected:any, message?:string):void;
33+
34+
export function strictEqual(actual:any, expected:any, message?:string):void;
35+
36+
export function notStrictEqual(actual:any, expected:any, message?:string):void;
37+
38+
export var throws:{
39+
(block:Function, message?:string): void;
40+
(block:Function, error:Function, message?:string): void;
41+
(block:Function, error:RegExp, message?:string): void;
42+
(block:Function, error:(err:any) => boolean, message?:string): void;
43+
};
44+
45+
export var doesNotThrow:{
46+
(block:Function, message?:string): void;
47+
(block:Function, error:Function, message?:string): void;
48+
(block:Function, error:RegExp, message?:string): void;
49+
(block:Function, error:(err:any) => boolean, message?:string): void;
50+
};
51+
52+
export function ifError(value:any):void;
53+
}
54+
55+
// duplicate to node.d.ts
56+
declare module "assert" {
57+
export = assert;
58+
}

0 commit comments

Comments
 (0)