index.js 743 B

123456789101112131415161718192021222324252627282930
  1. module.exports = function properlyBoxed(method) {
  2. // Check node 0.6.21 bug where third parameter is not boxed
  3. var properlyBoxesNonStrict = true;
  4. var properlyBoxesStrict = true;
  5. var threwException = false;
  6. if (typeof method === 'function') {
  7. try {
  8. // eslint-disable-next-line max-params
  9. method.call('f', function (_, __, O) {
  10. if (typeof O !== 'object') {
  11. properlyBoxesNonStrict = false;
  12. }
  13. });
  14. method.call(
  15. [null],
  16. function () {
  17. 'use strict';
  18. properlyBoxesStrict = typeof this === 'string'; // eslint-disable-line no-invalid-this
  19. },
  20. 'x'
  21. );
  22. } catch (e) {
  23. threwException = true;
  24. }
  25. return !threwException && properlyBoxesNonStrict && properlyBoxesStrict;
  26. }
  27. return false;
  28. };