租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.0 KiB

6 months ago
  1. # has-proto <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![github actions][actions-image]][actions-url]
  3. [![coverage][codecov-image]][codecov-url]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. [![npm badge][npm-badge-png]][package-url]
  7. Does this environment have the ability to set the [[Prototype]] of an object on creation with `__proto__`?
  8. ## Example
  9. ```js
  10. var hasProto = require('has-proto');
  11. var assert = require('assert');
  12. assert.equal(typeof hasProto(), 'boolean');
  13. var hasProtoAccessor = require('has-proto/accessor')();
  14. if (hasProtoAccessor) {
  15. assert.equal([].__proto__, Array.prototype);
  16. } else {
  17. assert(!('__proto__' in Object.prototype));
  18. }
  19. var hasProtoMutator = require('has-proto/mutator');
  20. var obj = {};
  21. assert('toString' in obj);
  22. obj.__proto__ = null;
  23. if (hasProtoMutator) {
  24. assert(!('toString' in obj));
  25. } else {
  26. assert('toString' in obj);
  27. assert.equal(obj.__proto__, null);
  28. }
  29. ```
  30. ## Tests
  31. Simply clone the repo, `npm install`, and run `npm test`
  32. [package-url]: https://npmjs.org/package/has-proto
  33. [npm-version-svg]: https://versionbadg.es/inspect-js/has-proto.svg
  34. [deps-svg]: https://david-dm.org/inspect-js/has-proto.svg
  35. [deps-url]: https://david-dm.org/inspect-js/has-proto
  36. [dev-deps-svg]: https://david-dm.org/inspect-js/has-proto/dev-status.svg
  37. [dev-deps-url]: https://david-dm.org/inspect-js/has-proto#info=devDependencies
  38. [npm-badge-png]: https://nodei.co/npm/has-proto.png?downloads=true&stars=true
  39. [license-image]: https://img.shields.io/npm/l/has-proto.svg
  40. [license-url]: LICENSE
  41. [downloads-image]: https://img.shields.io/npm/dm/has-proto.svg
  42. [downloads-url]: https://npm-stat.com/charts.html?package=has-proto
  43. [codecov-image]: https://codecov.io/gh/inspect-js/has-proto/branch/main/graphs/badge.svg
  44. [codecov-url]: https://app.codecov.io/gh/inspect-js/has-proto/
  45. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/has-proto
  46. [actions-url]: https://github.com/inspect-js/has-proto/actions