print_name.js 500 B

1234567891011121314151617181920212223242526272829
  1. exports.print = function (obj) {
  2. return obj.constructor.name
  3. }
  4. exports.echo = function (obj) {
  5. return obj
  6. }
  7. const typedArrays = {
  8. Int8Array,
  9. Uint8Array,
  10. Uint8ClampedArray,
  11. Int16Array,
  12. Uint16Array,
  13. Int32Array,
  14. Uint32Array,
  15. Float32Array,
  16. Float64Array
  17. }
  18. exports.typedArray = function (type, values) {
  19. const constructor = typedArrays[type]
  20. const array = new constructor(values.length)
  21. for (let i = 0; i < values.length; ++i) {
  22. array[i] = values[i]
  23. }
  24. return array
  25. }