dlv

WebJar for dlv

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

dlv
Последняя версия

Последняя версия

1.1.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

dlv
WebJar for dlv
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/developit/dlv

Скачать dlv

Имя Файла Размер
dlv-1.1.3.pom
dlv-1.1.3.jar 6 KB
dlv-1.1.3-sources.jar 22 bytes
dlv-1.1.3-javadoc.jar 22 bytes
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/dlv/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>dlv</artifactId>
    <version>1.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/dlv/
implementation 'org.webjars.npm:dlv:1.1.3'
// https://jarcasting.com/artifacts/org.webjars.npm/dlv/
implementation ("org.webjars.npm:dlv:1.1.3")
'org.webjars.npm:dlv:jar:1.1.3'
<dependency org="org.webjars.npm" name="dlv" rev="1.1.3">
  <artifact name="dlv" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='dlv', version='1.1.3')
)
libraryDependencies += "org.webjars.npm" % "dlv" % "1.1.3"
[org.webjars.npm/dlv "1.1.3"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

dlv(obj, keypath) NPM Build

Safely get a dot-notated path within a nested object, with ability to return a default if the full key path does not exist or the value is undefined

Why?

Smallest possible implementation: only 120 bytes.

You could write this yourself, but then you'd have to write tests.

Supports ES Modules, CommonJS and globals.

Installation

npm install --save dlv

Usage

delve(object, keypath, [default])

import delve from 'dlv';

let obj = {
	a: {
		b: {
			c: 1,
			d: undefined,
			e: null
		}
	}
};

//use string dot notation for keys
delve(obj, 'a.b.c') === 1;

//or use an array key
delve(obj, ['a', 'b', 'c']) === 1;

delve(obj, 'a.b') === obj.a.b;

//returns undefined if the full key path does not exist and no default is specified
delve(obj, 'a.b.f') === undefined;

//optional third parameter for default if the full key in path is missing
delve(obj, 'a.b.f', 'foo') === 'foo';

//or if the key exists but the value is undefined
delve(obj, 'a.b.d', 'foo') === 'foo';

//Non-truthy defined values are still returned if they exist at the full keypath
delve(obj, 'a.b.e', 'foo') === null;

//undefined obj or key returns undefined, unless a default is supplied
delve(undefined, 'a.b.c') === undefined;
delve(undefined, 'a.b.c', 'foo') === 'foo';
delve(obj, undefined, 'foo') === 'foo';

Setter Counterparts

  • dset by @lukeed is the spiritual "set" counterpart of dlv and very fast.
  • bury by @kalmbach does the opposite of dlv and is implemented in a very similar manner.

License

MIT

Версии библиотеки

Версия
1.1.3
1.1.2