Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
chain-able-deps / dist / typings / fp / first.d.ts
Size: Mime:
import { AnyArrayOrObj, ReverseObjKeyValue } from '../_typings';
/**
 * Returns the first element of the given list or string. In some libraries
 * this function is named `first`.
 *
 * @memberOf fp
 * @since v5.0.0
 *
 * @extends deps/fp/firstIndex
 * @param {*} x Array or Object find the last key of
 * @return {*} value at last index
 *
 * @name first
 * @alias head
 *
 * @tests fp/first
 *
 * @func
 * @category List
 * @sig [a] -> a | Undefined
 * @sig String -> String
 *
 * {@link https://github.com/ramda/ramda/blob/master/src/head.js ramda-head}
 * {@link https://github.com/lodash/lodash/blob/master/head.js lodash-head}
 * {@link https://github.com/jashkenas/underscore/blob/master/underscore.js#L494 underscore-first}
 * @see {@link underscore-head}
 * @see {@link lodash-head}
 * @see {@link ramda-head}
 * @see R.init, R.head, R.tail
 *
 * @TODO could just pipe nth
 *
 * @example
 *
 *      first(['fi', 'fo', 'fum']); //=> 'fi'
 *      first([]);                  //=> undefined
 *
 *      first('abc');               //=> 'a'
 *      first('');                  //=> ''
 *
 */
declare function first<Type = AnyArrayOrObj>(x: Type): undefined | keyof ReverseObjKeyValue<Type>;
export default first;