🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

lowercase-keys

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lowercase-keys

Lowercase the keys of an object

latest
Source
npmnpm
Version
4.0.1
Version published
Weekly downloads
27M
-22.43%
Maintainers
1
Weekly downloads
 
Created
Source

lowercase-keys

Lowercase the keys of an object

Check out map-obj if you need support for deep iteration.

Install

npm install lowercase-keys

Usage

import lowercaseKeys from 'lowercase-keys';

lowercaseKeys({FOO: true, bAr: false});
//=> {foo: true, bar: false}

API

lowercaseKeys(object, options?)

Returns a new object with the keys lowercased.

options

Type: object

onConflict

Type: Function

A function that is called when multiple keys in the input object map to the same lowercased key.

The function receives the lowercased key, the new value, and the existing value, and should return the value to use.

By default, the last value wins.

import lowercaseKeys from 'lowercase-keys';

// Throw on conflict
lowercaseKeys({Key: 'value1', key: 'value2'}, {
	onConflict({key}) {
		throw new Error(`Duplicate key: ${key}`);
	}
});

// Keep the first value
lowercaseKeys({Key: 'value1', key: 'value2'}, {
	onConflict: ({existingValue}) => existingValue,
});
//=> {key: 'value1'}

Keywords

object

FAQs

Package last updated on 02 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts