• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DigitalBrainJS / AxiosPromise / 15977461159

30 Jun 2025 03:42PM UTC coverage: 84.677% (+0.08%) from 84.6%
15977461159

Pull #72

github

DigitalBrainJS
fix(core): fix queue order usage in asap util;
Pull Request #72: fix(core): fix queue order usage in asap util;

243 of 301 branches covered (80.73%)

Branch coverage included in aggregate %.

10 of 10 new or added lines in 1 file covered. (100.0%)

8 existing lines in 1 file now uncovered.

1017 of 1187 relevant lines covered (85.68%)

408.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.41
/lib/utils.js
1
const {
1✔
2
  hasOwn = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype)
1!
3
} = Object;
1✔
4

1✔
5
const {toStringTag} = Symbol;
1✔
6

1✔
7
const isFunction = (thing) => typeof thing === 'function';
1✔
8

1✔
9
const _global = typeof globalThis === 'object' && globalThis ||
1!
10
  (typeof global !== "undefined" && global) ||
1!
11
  (typeof self !== "undefined" && self) || window
1!
12

1✔
13
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1✔
14
  if (setImmediateSupported) {
1✔
15
    return setImmediate;
1✔
16
  }
1✔
UNCOV
17

×
UNCOV
18
  return postMessageSupported ? ((token, callbacks) => {
×
19
    _global.addEventListener("message", ({source, data}) => {
×
20
      if (source === _global && data === token) {
×
21
        callbacks.length && callbacks.shift()();
×
22
      }
×
23
    }, false);
×
24

×
25
    return (cb) => {
×
26
      callbacks.push(cb);
×
27
      _global.postMessage(token, "*");
×
28
    }
×
29
  })(`axios-promise@${Math.random()}`, []) : (cb) => setTimeout(cb);
1!
30
})(
1✔
31
  typeof setImmediate === 'function',
1✔
32
  isFunction(_global.postMessage)
1✔
33
);
1✔
34

1✔
35
const asap = typeof process !== 'undefined' && process.nextTick ||
1!
36
  (typeof queueMicrotask !== 'undefined' ? queueMicrotask : _setImmediate);
1✔
37

1✔
38
const functionTypeTest = ({constructor}) => {
1✔
39
  const {name} = constructor;
3✔
40
  return (thing) => thing && isFunction(thing) && (thing.constructor === constructor || (name && thing.constructor.name === name));
3✔
41
}
3✔
42

1✔
43
const isGeneratorFunction = functionTypeTest(function* () {});
1✔
44

1✔
45
const isAsyncFunction = functionTypeTest(async () => {});
1✔
46

1✔
47
const isPlainFunction = functionTypeTest(() => {});
1✔
48

1✔
49
const isGenerator = (obj) =>
1✔
50
  obj && typeof obj === 'object' && typeof obj.next === 'function' && typeof obj.throw === 'function' &&
2,518✔
51
  obj[toStringTag] === 'Generator';
1✔
52

1✔
53
const isContextDefined = (context) => context != null && context !== _global;
1✔
54

1✔
55
const lazyBind = (obj, props, {bindMethods = true} = {}) => {
1✔
56
  const symbols = {};
2✔
57

2✔
58
  props.forEach(prop => {
2✔
59
    const symbol = Symbol(`${prop}Lazy`);
5✔
60
    const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
5✔
61
    const {value, get, enumerable} = descriptor;
5✔
62

5✔
63
    if('value' in descriptor && !isFunction(value)) {
5!
UNCOV
64
      return;
×
UNCOV
65
    }
×
66

5✔
67
    Object.defineProperty(obj, prop, {
5✔
68
      get() {
5✔
69
        if (hasOwn.call(this, symbol)) {
202!
UNCOV
70
          return this[symbol];
×
UNCOV
71
        }
×
72

202✔
73
        const resolvedValue = get ? get.call(this) : value;
202✔
74

202✔
75
        const boundContext = this;
202✔
76

202✔
77
        return this[symbol] = bindMethods && isFunction(resolvedValue) ? function () {
202✔
78
          return resolvedValue.apply(isContextDefined(this) ? this : boundContext, arguments);
176✔
79
        } : resolvedValue;
202✔
80
      },
5✔
81

5✔
82
      set(v) {
5✔
UNCOV
83
        throw Error(`Can not rewrite prop ${prop} with ${v}`);
×
84
      },
5✔
85

5✔
86
      enumerable,
5✔
87
      configurable: true
5✔
88
    });
5✔
89

5✔
90
    symbols[prop] = symbol;
5✔
91
  });
2✔
92

2✔
93
  return symbols;
2✔
94
}
2✔
95

1✔
96
const defineConstants = (obj, props, {configurable = true, enumerable = true} = {}) => {
1✔
97
  const descriptors = {};
1✔
98

1✔
99
  Object.getOwnPropertyNames(props).forEach((prop) => {
1✔
100
    descriptors[prop] = {value: props[prop], enumerable, configurable}
5✔
101
  })
1✔
102

1✔
103
  Object.defineProperties(obj, descriptors);
1✔
104
};
1✔
105

1✔
106
const isAbortSignal = (thing) => {
1✔
107
  return thing &&
4✔
108
    typeof thing === 'object' &&
4✔
109
    typeof thing.aborted === 'boolean' &&
4✔
110
    isFunction(thing.addEventListener) &&
4✔
111
    isFunction(thing.removeEventListener);
4✔
112
}
4✔
113

1✔
114
const isAbortController = (thing) => {
1✔
UNCOV
115
  return thing && typeof thing === 'object' && isFunction(thing.abort) && isAbortSignal(thing.signal);
×
116
};
1✔
117

1✔
118
let symbolId = 0;
1✔
119

1✔
120
const symbols = (...tags) => ({
1✔
121
  * [Symbol.iterator]() {
2✔
122
    while (true) {
2✔
123
      yield Symbol(tags.shift() || `#${symbolId++}`);
26!
124
    }
24✔
125
  }
2✔
126
})
2✔
127

1✔
128
export default {
1✔
129
  global: _global,
1✔
130
  setImmediate: _setImmediate,
1✔
131
  asap,
1✔
132
  isGeneratorFunction,
1✔
133
  isFunction,
1✔
134
  isAsyncFunction,
1✔
135
  isPlainFunction,
1✔
136
  functionTypeTest,
1✔
137
  isContextDefined,
1✔
138
  hasOwn,
1✔
139
  lazyBind,
1✔
140
  isGenerator,
1✔
141
  defineConstants,
1✔
142
  isAbortSignal,
1✔
143
  isAbortController,
1✔
144
  symbols
1✔
145
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc