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 / util / keysIn.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var is_1 = require("../is");
var preAllocate_1 = require("../array/preAllocate");
/**
 * @name keysIn
 * @version 1.0.0 uncommented, used preAllocate
 * @version 0.0.1 just comment
 * @since 5.0.0
 *
 * @param  {Object|Array} obj object to call `for in` on
 * @param  {boolean} [guard=false] only accept `hasOwnProperty`
 * @return {Array} keys from obj
 *
 * {@link https://github.com/ramda/ramda/blob/master/src/keysIn.js ramda-keys-in}
 * @see {@link ramda-keys-in}
 * @see array/preAllocate
 * @see util/hasOwnProperty
 *
 * @tests keys
 *
 * @example
 *
 *    keysIn([1, 2])           //=> [0, 1]
 *    keysIn({one: 1, two: 2}) //=> ['one', 'two']
 *
 */
function keysIn(obj, guard) {
    var result = preAllocate_1.default(obj);
    var index = 0;
    // eslint-disable-next-line
    // for (const key in obj) hasOwnProperty(obj, key) && (result[index++] = key)
    for (var key in obj) {
        /**
         * when we have a guard, check ownProperty, otherwise just assign
         *
         * also written as pseudo:
         * ```
         *   if (guard)
         *     if (hasOwnProperty) assign
         *   else result[index++] = key
         * ```
         */
        if (guard !== true || is_1.hasOwnProperty(obj, key)) {
            result[index++] = key;
        }
    }
    return result;
}
exports.default = keysIn;
//# sourceMappingURL=keysIn.js.map