ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions.
github.com/ljharb/es-to-primitive
ljharb/es-to-primitive