Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
What is the pattern common used for umdjs polyfills?

I am currently using umdjs(https://github.com/umdjs/umd) to create a nodejs modules.

I would know if their is a predefined pattern more specificly for umd pollyfills.This is because I am writting a polyfill for javascript using the umd pattern.


(function (root, factory) {
  'use strict';
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define([], function () {
      return (root = factory());
    });
  } else if (typeof exports === 'object') {
    // Node. Does not work with strict CommonJS, but
    // only CommonJS-like enviroments that support module.exports,
    // like Node.
    module.exports = factory();
  } else {
    // Browser globals
    return root.countByRadix = factory();
  }

}(this, function () {
  var that = this;
  // UMD Definition above, do not remove this line
  let hasOwnProperty = Object.prototype.hasOwnProperty;
/**
 * American Standard for Communication
 * and Information Interchange
 * @param str
 * @returns
 */
function toAscii(str) {
  return  [...str]
          .map(c => c.charCodeAt(0))
}

  function toRadixOf(str,base)  {
    return  toAscii(str).map(c => c.toString(base));
  }

  if (!(hasOwnProperty.call(String.prototype, "countByRadix"))){
    Object.defineProperty(String.prototype, "countByRadix", {
        value: function (radix) {
            return Number(
                    toRadixOf(this, radix)
                    .map(r => String(r).length)
                    .reduce((a, b) => a + b))
        }
    })
  }
return that
}));
about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda