Skip to content

Commit 2176abd

Browse files
committed
Merge pull request #312 from kentcdodds/patch-2
UMDifying js-data-angular
2 parents e14cbda + 5559e33 commit 2176abd

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/index.js

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*jshint loopfunc:true*/
2-
(function (window, angular, undefined) {
2+
(function (root, factory) {
33
'use strict';
44

5-
var JSData;
6-
7-
try {
8-
JSData = require('js-data');
9-
} catch (e) {
10-
11-
}
12-
13-
if (!JSData) {
14-
JSData = window.JSData;
5+
if (typeof define === 'function' && define.amd) {
6+
define(['angular', 'js-data'], function(angular, JSData) {
7+
return factory(root, angular, JSData, undefined);
8+
});
9+
} else if (typeof module !== 'undefined' && module.exports) {
10+
module.exports = factory(root, require('angular') || root.angular, require('js-data'), undefined);
11+
} else {
12+
root.jsDataAngularModuleName = factory(root, root.angular, root.JSData, undefined);
1513
}
14+
}(this, function(window, angular, JSData, undefined) {
15+
'use strict';
1616

17-
if (!JSData) {
18-
throw new Error('js-data must be loaded!');
17+
if (!JSData || !angular) {
18+
throw new Error('js-data and angular must be loaded!');
1919
}
2020

2121
var DSUtils = JSData.DSUtils;
@@ -502,5 +502,8 @@
502502
DS.registerAdapter('http', DSHttpAdapter, { default: true });
503503
}]);
504504
}
505+
506+
// return the module name
507+
return 'js-data';
505508

506-
})(window, window.angular);
509+
});

0 commit comments

Comments
 (0)