sorted-object

WebJar for sorted-object

Лицензия

Лицензия

MIT
Группа

Группа

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

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

sorted-object
Последняя версия

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

2.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

sorted-object
WebJar for sorted-object
Ссылка на сайт

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

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

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

https://github.com/domenic/sorted-object

Скачать sorted-object

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

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

Зависимости

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

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

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

Get a Version of an Object with Sorted Keys

Although objects in JavaScript are theoretically unsorted, in practice most engines use insertion order—at least, ignoring numeric keys. This manifests itself most prominently when dealing with an object's JSON serialization.

So, for example, you might be trying to serialize some object to a JSON file. But every time you write it, it ends up being output in a different order, depending on how you created it in the first place! This makes for some ugly diffs.

sorted-object gives you the answer. Just use this package to create a version of your object with its keys sorted before serializing, and you'll get a consistent order every time.

var sortedObject = require("sorted-object");

var objectToSerialize = generateStuffNondeterministically();

// Before:
fs.writeFileSync("dest.json", JSON.stringify(objectToSerialize));

// After:
var sortedVersion = sortedObject(objectToSerialize);
fs.writeFileSync("dest.json", JSON.stringify(sortedVersion));

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

Версия
2.0.1