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 / fromStringToUint31.ts

import { fromStringToCharCodes } from './fromStringToCharCodes'

// @NOTE @TODO @FIXME @HACK - WAS UINT31 ADD IT BACK
const add = (a, b) => a + b
const numbersToUint31 = (numbers: number[]) => numbers.reduce(add, 0)

// fromStringToCharCodes(x.toLowerCase())
const stringToUint31 = (x: string | number): number =>
  numbersToUint31(fromStringToCharCodes(x as string))

// numbersToUint31(x.toLowerCase().split('').map(char => char.charCodeAt(0)))

/**
 * @since 5.0.0-beta.9
 * @name fromStringToUint31
 * @type {Function}
 */
export default stringToUint31
export { stringToUint31 }