HasOwnPropertyRuntimeModule.js 731 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Sergey Melyukov @smelukov
  4. */
  5. "use strict";
  6. const RuntimeGlobals = require("../RuntimeGlobals");
  7. const RuntimeModule = require("../RuntimeModule");
  8. const Template = require("../Template");
  9. class HasOwnPropertyRuntimeModule extends RuntimeModule {
  10. constructor() {
  11. super("hasOwnProperty shorthand");
  12. }
  13. /**
  14. * @returns {string} runtime code
  15. */
  16. generate() {
  17. const { runtimeTemplate } = this.compilation;
  18. return Template.asString([
  19. `${RuntimeGlobals.hasOwnProperty} = ${runtimeTemplate.returningFunction(
  20. "Object.prototype.hasOwnProperty.call(obj, prop)",
  21. "obj, prop"
  22. )}`
  23. ]);
  24. }
  25. }
  26. module.exports = HasOwnPropertyRuntimeModule;