Node-Red configuration
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.

esnext.data-view.set-float16.js 881B

123456789101112131415161718192021
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var uncurryThis = require('../internals/function-uncurry-this');
  4. var aDataView = require('../internals/a-data-view');
  5. var toIndex = require('../internals/to-index');
  6. var packIEEE754 = require('../internals/ieee754').pack;
  7. var f16round = require('../internals/math-f16round');
  8. // eslint-disable-next-line es/no-typed-arrays -- safe
  9. var setUint16 = uncurryThis(DataView.prototype.setUint16);
  10. // `DataView.prototype.setFloat16` method
  11. // https://github.com/tc39/proposal-float16array
  12. $({ target: 'DataView', proto: true }, {
  13. setFloat16: function setFloat16(byteOffset, value /* , littleEndian */) {
  14. aDataView(this);
  15. var offset = toIndex(byteOffset);
  16. var bytes = packIEEE754(f16round(value), 10, 2);
  17. return setUint16(this, offset, bytes[1] << 8 | bytes[0], arguments.length > 2 ? arguments[2] : false);
  18. }
  19. });