Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

keysort

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keysort

Sorts an Array of Objects with SQL ORDER BY clause syntax

latest
Source
npmnpm
Version
3.0.1
Version published
Weekly downloads
274
783.87%
Maintainers
1
Weekly downloads
 
Created
Source

keysort

Sorts an Array of Objects with SQL ORDER BY clause syntax.

Using the module

import {keysort} from "keysort";
const arr = [{abc: 123124, xyz: 5}, {abc: 123124, xyz: 6}, {abc: 2, xyz: 5}];

keysort(arr, "abc, xyz"); // [{abc: 2, xyz: 5}, {abc: 123124, xyz: 5}, {abc: 123124, xyz: 6}];
keysort(arr, "abc, xyz desc"); // [{abc: 2, xyz: 5}, {abc: 123124, xyz: 6}, {abc: 123124, xyz: 5}];

Testing

keysort has 100% code coverage with its tests.

-------------|---------|----------|---------|---------|-------------------
File         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------|---------|----------|---------|---------|-------------------
All files    |     100 |       80 |     100 |     100 |                  
 keysort.cjs |     100 |       80 |     100 |     100 | 25               
-------------|---------|----------|---------|---------|-------------------

API

keysort(arr = [], order = "", toSorted = false)

Sorts an Array of Objects with SQL ORDER BY clause syntax. If toSorted is true, a new sorted Array is returned.

License

Copyright (c) 2023 Jason Mulligan
Licensed under the BSD-3 license.

Keywords

Array

FAQs

Package last updated on 10 Oct 2023

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