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 / chain-able-deps   js

Repository URL to install this package:

Version: 6.0.4 

/ src / loop / each / forInUnguarded.ts

export type CollectionForIn<Value> = Array<Value> | {} | Iterator<Value> | Value

// extends keyof CollectionForIn<Value>
export interface Iteratee<Value, Prop = any> extends Function {
  (
    value: Value,
    prop: Prop,
    collection: Array<Value> | {} | Iterator<Value>
  ): any
}

/**
 * @desc loop for in, no checks on hasOwnProperty, useful for flattening proto
 * @since 5.0.0-beta.6
 * @memberOf loop
 * @curried 2
 *
 * @param collection collection to iterate
 * @param iteratee The function invoked per iteration
 * @return collection
 */
export default function forInUnguarded<Value>(
  collection: Array<Value> | {} | Iterator<Value>,
  iteratee: Iteratee<Value>
) {
  // eslint-disable-next-line
  for (let prop in collection) iteratee(collection[prop], prop, collection)
  return collection
}