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 / array / linkedlist / fromArrayToDoublyLinkedList.ts

import { zip, FlatArrayPairs } from '../../../deps'
import { isReal } from '../../primitive/nil'
import { isPairs } from '../../array/pairs/isPairs'
import isObj from '../../obj/check/isObj'

/* prettier-ignore */
function toFlatPairs(data: any, propertyIndexedObj?: Object) {
  if (typeof data === 'number') {
    return new FlatArrayPairs(data)
  } else if (isReal(data)) {
    // @NOTE meaning obj | array since arr is obj
    // @TODO assert invariant without propertyIndexedObj || isPairs(data)
    if (isObj(data)) {
      const instance = new FlatArrayPairs()

      // easier conditional logic
      let pairs = data
      if (isObj(data) && isObj(propertyIndexedObj)) {
        pairs = zip(data, propertyIndexedObj)
      }
      if (isPairs(data)) {
        // this is not a function...
        // instance.addPair(pairs)
      }
      // no pairs at all... uh...
      // else {}

      return instance
    }

    /**
     * .from is only `static` :-/
     * and we want .addPairs > .fromPairs
     *
     * @todo with rollup this may not count the native extends...?
     */
    return FlatArrayPairs.from(data)
  }
  // empty map
  else {
    return new FlatArrayPairs()
  }
}

export { toFlatPairs }
export default toFlatPairs

// const TypedArray = (bits, signed) => {
//   let name = ''
//   if (signed) name += 'Int'
//   else name += 'Uint'
//   name += bits
//   name += 'Array'
//   return localGlobal()[name] || Array.of
// }
// var sa = new StringArray()
// sa.push('eh')
// sa[sa.length] = 'oh'