Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / exotic   js

Repository URL to install this package:

Version: 2.0.8 

/ src / types / primitive / number / cast / toInt8Unsafe.ts

// @NOTE long short,
// >> shift the bits 1 right,
//  drop it to half it,
//  which means if it's over 900... cool
//
// https://jsperf.com/float32-to-int16/2 **
// https://developer.mozilla.org/en-US/docs/Glossary/Endianness
// https://github.com/jDataView/jDataView ***
// http://blog.vjeux.com/2013/javascript/conversion-from-uint8-to-int8-x-24.html ***
// https://github.com/jussi-kalliokoski/pcmdata.js/blob/master/lib/pcmdata.js?MobileOptOut=1
// https://stackoverflow.com/questions/20364434/convert-utf8-to-int16-in-javascript
// https://google.github.io/flatbuffers/group__flatbuffers__javascript__api.html
// http://jibbering.com/faq/notes/type-conversion/
// https://www.npmjs.com/package/math-uint16-bits
// https://dzone.com/articles/integers-and-shift-operators
// http://processingjs.org/reference/left%20shift/
// http://processingjs.org/reference/right%20shift/
// https://github.com/Automattic/mongoose/blob/408a20bb860acbb916dbb6f1437819099c4a98a8/lib/cast.js ***8
// https://gist.github.com/faisalman/4213592
// https://stackoverflow.com/questions/13468474/javascript-convert-a-hex-signed-integer-to-a-javascript-value/34679269#34679269
// https://github.com/Automattic/mongoose/blob/67c465aac5c864c3004d11d49934605037c8f520/lib/schema/operators/bitwise.js
// http://mongoosejs.com/docs/api.html#model_Model.aggregate
// http://mongoosejs.com/docs/customschematypes.html
// https://fossies.org/linux/mongo/src/third_party/mozjs-45/extract/js/public/Conversions.h
// http://jsfiddle.net/ethertank/2749B/
// https://stackoverflow.com/questions/37042581/string-array-to-int8-array-byte-typecasting
const toInt8 = (x: any): number => {
  while (x > 255) {
    x = x >>> 1
  }
  return x
}
const toUint8 = x => {}
const toUint8Clamp = x => {}
const toInt16 = x => {}
const toUint16 = x => {}

export default toInt8