forked from cujojs/rest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
63 lines (51 loc) · 1.43 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright 2014 the original author or authors
* @license MIT, see LICENSE.txt for details
*
* @author Scott Andrews
*/
(function (define) {
'use strict';
define(function (/* require */) {
/**
* Add common helper methods to a client impl
*
* @param {function} impl the client implementation
* @param {Client} [target] target of this client, used when wrapping other clients
* @returns {Client} the client impl with additional methods
*/
return function client(impl, target) {
if (target) {
/**
* @returns {Client} the target client
*/
impl.skip = function skip() {
return target;
};
}
/**
* Allow a client to easily be wrapped by an interceptor
*
* @param {Interceptor} interceptor the interceptor to wrap this client with
* @param [config] configuration for the interceptor
* @returns {Client} the newly wrapped client
*/
impl.wrap = function wrap(interceptor, config) {
return interceptor(impl, config);
};
/**
* @deprecated
*/
impl.chain = function chain() {
if (console) {
(console.warn || console.log).call(console, 'rest.js: client.chain() is deprecated, use client.wrap() instead');
}
return impl.wrap.apply(this, arguments);
};
return impl;
};
});
}(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
));