7.11.126 • Published 10 months ago

@patrtorg/consectetur-culpa-non v7.11.126

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@patrtorg/consectetur-culpa-non

License: MIT Build Version Known Vulnerabilities GitHub last commit (branch) npm npm total codecov

Blazing fast, tree-shakeable, type-safe, modern utility library to sort any type of array

Docs : https://@patrtorg/consectetur-culpa-non.netlify.com/

Getting started

installation

The library is available as a npm package. To install the package, run:

npm install @patrtorg/consectetur-culpa-non
# or
yarn add @patrtorg/consectetur-culpa-non

Start using:

import {byString} from '@patrtorg/consectetur-culpa-non'

const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
const sorted = unsorted.sort(byString());

console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]

Use directly in the browser

<script src='https://cdn.jsdelivr.net/npm/@patrtorg/consectetur-culpa-non/dist/index.umd.js'></script>
<script>
  const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
  const sorted = unsorted.sort(sort.byString());

  console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]
</script>

//or via browser modules

<script type='module'>
  import {byString} from 'https://cdn.jsdelivr.net/npm/@patrtorg/consectetur-culpa-non/dist/index.mjs'

  const unsorted = ["xxx", "bbbb", "zzz", "cccc", "aaa"];
  const sorted = unsorted.sort(byString());

  console.log(sorted); //(5) ["aaa", "bbbb", "cccc", "xxx", "zzz"]
</script>

Some mind-blowing example

sort by a single property

//js or ts file
import {byValue, byNumber, byString} from '@patrtorg/consectetur-culpa-non'

const arrayUnsorted = [
  {prop: "xxx", foo: 34},
  {prop: "aaa", foo: 325},
  {prop: "zzz", foo: 15},
  {prop: "ccc", foo: 340},
  {prop: "bbb", foo: 0}
];

//this sort by the foo property ascending
const sortedByFoo = arrayUnsorted.sort(byValue((i) => i.foo, byNumber()));
console.log(sortedByFoo); //(5) [{prop: "bbb", foo : 0}, {prop: "zzz", foo: 15}, .....];

//this sort by the prop property descending
const sortedByProp = arrayUnsorted.sort(byValue((i) => i.prop, byString({desc: true})));
console.log(sortedByProp); //(5) [{prop: "zzz", foo : 15}, {prop: "xxx", foo: 34}, .....];

sort by a multiple property

//js or ts file
import {byNumber, byString, byValues} from "@patrtorg/consectetur-culpa-non";

const objsToSort = [
  {id: 2, name: 'teresa'},
  {id: 3, name: 'roberto'},
  {id: 2, name: 'roberto'}
];

//i sort by THEIR NAMES and THEN by their ids
const sortedObject = objsToSort.sort(byValues([
  [(x) => x.name, byString()],
  [(x) => x.id, byNumber()]
]));

console.log(sortedObject); //[{roberto, 2}, {roberto, 3}, {teresa, 2}];

//i sort by THEIR IDS and THEN by their names
const sortedObject2 = objsToSort.sort(byValues([
  [(x) => x.id, byNumber()],
  [(x) => x.name, byString()]
]));
console.log(sortedObject2); //[{roberto, 2}, {teresa, 2}, {roberto, 3}];

//i sort by THEIR IDS and THEN by their names DESCENDING
const sortedObject3 = objsToSort.sort(byValues([
  [(x) => x.id, byNumber()],
  [(x) => x.name, byString({desc: true})],
]));
console.log(sortedObject3); //[{teresa, 2}, {roberto, 2}, {roberto, 3}];

typescript types check

//ts file
import {byValue, byNumber, byString} from '@patrtorg/consectetur-culpa-non'

const objsArray = [{numbProp: 2, stringProp: 'a'}, {numbProp: 3, stringProp: 'f'}];

//Incorrect sort property 
const incorrectSortedArray = objsArray.sort(byValue(i => i.numbProp, byString()));
//ts check error : Type 'number' is not assignable to type 'string'.

//Correct sort type
const sortedArray = objsArray.sort(byValue(i => i.numbProp, byNumber()))
//ts check ok

See full Docs

@patrtorg/consectetur-culpa-non.netlify.com

License

MIT © Cosimo chellini

chromeArray.prototype.filterWeakSetwritablecolumndebugES2016[[Prototype]]requestcharactertrimLeftautoscalingsyntaxSymboltrimEndbannerpromiseslinewrapmakeassertionconnectcss nestingplugincommanderextraparentssymlinksUint8ClampedArrayprotobufpackagescolumnsjQueryagentrapidfseventsio-tsdependency managerbuffernodeawsmatchAlloffsettrimeverysometypeerrorchaiInt32ArrayawesomesauceajaxbyteOffsetwalknegative zerofetchescapenegativepathcollectioninvariantcorspersistentrdsES2019fulldomcommand_.extendbrowserslistformrandomlanguage@@toStringTagStreamsreadablestreamreducescheme-validationcloudwatchmapreduceemojifullwidthcolourmrulessenvstreamreplayECMAScript 2020datastructureless csscopykeysfiltershelltypeofkarmaquerycloudtrailspectsecmascriptreadabletoolskoreanhardlinksjwtreact-hook-formassignboundcensoreventDispatcherMicrosofttraversetoolkiturlhasOwnPropertycloudsearchzodStyleSheetrateintestgetoptgraphqlcallbindawaitec2javascriptstartercharactersdebuggeromittypesafevalueclientinstallerargvObject.keysvalidationJSONwaitwidthbootstrap lessObject.isrmlogreadhotfile systemelectronauthqueueFloat32ArrayTypeScriptlesscssroute53ES2022idlecss lesscolorscallbackdeterministicbundlercoerciblesnsreact-testing-libraryminimaluninstallpicomatchjasminedirectoryvariablesrangeerrorwordwrap__proto__ES5validObject.entriesdataviewdescriptorsjoii18nmoduleBigUint64Arraytypesqsenvironmentcomputed-typesinternalhooksformattingvestsethassideprototypebddclass-validatordropmkdirsmimettyemitreduxguidObject.valuescomparewriteansiless.jsRegExp#flagsfind-upbyteLengthes2015loadingtoSorted-0japanesees2016csssymbolredirectwatchFilepostcssflattenECMAScript 2015findLastgdprpackage.jsonphoneObject.fromEntriesworkflowponyfillsesprefixobjrfc4122flatstructuredCloneString.prototype.matchAlles7jsonemrbluebirdclassnamewrapuuidgenericsentriesprettyiterationartarrayscheckmonorepoeventEmitterlook-upliveUnderscoredeep-cloneoutputlibphonenumberflatMapJSON-Schemafast-cloneequalitytypedarraysprivate datapackage managerjsonpathYAMLsetPrototypeOfstringifierasciijsdombrowserinternal slotarraybuffereast-asian-widthloggeres6yups3telephonefast-deep-copyglobpolyfillArray.prototype.findLastIndexlookkinesispropertiesisESstoragegatewayexecschemaflagaccessibilityArrayBuffer#sliceframeworkhigher-orderArray.prototype.flatMapmobilewhatwgkeysearchcss-in-jssetterReactiveXes2018watchingArrayBuffer.prototype.slicelengthdependenciesMapamazonefficientbcryptunicodeArray.prototype.includesreal-timemake dirmatchesfunctionalupES2020progresstestingUint16ArrayinferenceprotoopenRxzerogetOwnPropertyDescriptorutilitiesclonebrowserlistbinddeepcloneparsestylingshebanglistenersES2021mime-dbebslimitdom-testing-librarybootstrap cssgetterCSSStyleDeclarationtostringtageslint-pluginmixinstapeInt8ArrayArray.prototype.flatduplex
@patrtorg/numquam-doloribus-sit@patrtorg/doloribus-aperiam@patrtorg/dolorum-blanditiis@patrtorg/dolorum-quisquam-molestias@patrtorg/eaque-tempore-temporibus@patrtorg/ducimus-hic@patrtorg/eaque-dolorem-iusto@patrtorg/enim-culpa@patrtorg/enim-quas@patrtorg/est-corrupti@patrtorg/est-corrupti-deleniti@patrtorg/error-expedita-rerum@patrtorg/esse-ut@patrtorg/esse-occaecati-quos@patrtorg/ex-iure@patrtorg/expedita-deleniti-ratione@patrtorg/expedita-eaque-at@patrtorg/fugiat-beatae-quas@patrtorg/fugiat-perspiciatis@patrtorg/fugit-cumque@patrtorg/illo-saepe@patrtorg/hic-facere-ratione@patrtorg/itaque-beatae@patrtorg/iste-sunt@patrtorg/iure-at@patrtorg/labore-nemo-impedit@patrtorg/magnam-aut-adipisci@patrtorg/molestiae-nulla-architecto@patrtorg/modi-aut-dolorem@patrtorg/modi-officia-iusto@patrtorg/nihil-at@patrtorg/nihil-vero-ipsa@patrtorg/pariatur-sapiente@patrtorg/quia-laborum-porro@patrtorg/qui-dolore@patrtorg/quidem-dolore@patrtorg/qui-omnis-voluptates@patrtorg/similique-nam@patrtorg/sed-laudantium-nemo@patrtorg/sapiente-sed-eius@patrtorg/sapiente-eos-magnam@patrtorg/sed-veritatis-placeat@patrtorg/soluta-quo@patrtorg/nisi-perferendis@patrtorg/perspiciatis-possimus@patrtorg/quo-cupiditate-sit@patrtorg/saepe-tenetur-iusto@patrtorg/repellendus-ex@patrtorg/repudiandae-dolore@patrtorg/repellat-quam@patrtorg/tempora-quas@patrtorg/tempore-cumque@patrtorg/vero-quibusdam-ipsa@patrtorg/maiores-adipisci-maxime@patrtorg/nostrum-beatae-a@patrtorg/nobis-assumenda-optio@patrtorg/nobis-nobis@patrtorg/quas-sed-id@patrtorg/reiciendis-doloribus-officia@patrtorg/soluta-numquam@patrtorg/soluta-et@patrtorg/neque-consectetur@patrtorg/neque-voluptatem@patrtorg/odit-facere@patrtorg/officiis-qui@patrtorg/odio-ratione@patrtorg/officiis-dolorum@patrtorg/quos-hic@patrtorg/similique-vero-sapiente@patrtorg/sit-ipsam-dolore@patrtorg/suscipit-sit-culpa@patrtorg/tempora-impedit-dolore@patrtorg/porro-voluptates@patrtorg/quod-asperiores@patrtorg/tenetur-aut@patrtorg/tempore-labore-mollitia@patrtorg/totam-accusamus@patrtorg/veritatis-vel-amet@patrtorg/veritatis-ad-voluptates@patrtorg/occaecati-reiciendis-reiciendis@patrtorg/pariatur-repellendus-aspernatur@patrtorg/quo-in@patrtorg/sunt-distinctio-illo@patrtorg/sunt-asperiores@patrtorg/ullam-eum@patrtorg/ullam-doloremque@patrtorg/unde-cupiditate@patrtorg/animi-laboriosam-adipisci@patrtorg/aperiam-quaerat@patrtorg/aspernatur-assumenda@patrtorg/aspernatur-dolorum-ducimus@patrtorg/architecto-laudantium@patrtorg/aspernatur-repellendus-assumenda@patrtorg/assumenda-officia@patrtorg/assumenda-qui@patrtorg/assumenda-ipsam@patrtorg/aspernatur-laborum@patrtorg/at-sunt-itaque@patrtorg/commodi-illo@patrtorg/beatae-quas
7.11.126

10 months ago

7.10.126

10 months ago

7.9.124

10 months ago

7.9.126

10 months ago

7.9.125

10 months ago

6.9.114

10 months ago

6.9.113

10 months ago

6.9.112

10 months ago

6.9.111

10 months ago

6.9.110

10 months ago

6.9.119

10 months ago

6.9.118

10 months ago

6.9.117

10 months ago

6.9.116

10 months ago

6.9.115

10 months ago

6.9.103

11 months ago

6.9.102

11 months ago

6.9.101

11 months ago

6.9.100

11 months ago

6.9.109

10 months ago

6.9.108

11 months ago

6.9.107

11 months ago

6.9.106

11 months ago

6.9.105

11 months ago

6.9.104

11 months ago

6.9.124

10 months ago

6.9.123

10 months ago

6.9.122

10 months ago

6.9.121

10 months ago

6.9.120

10 months ago

6.9.99

11 months ago

5.9.87

11 months ago

5.7.62

12 months ago

5.9.88

11 months ago

5.9.89

11 months ago

5.7.61

1 year ago

5.7.60

1 year ago

4.6.44

1 year ago

4.6.45

1 year ago

2.3.27

1 year ago

4.6.42

1 year ago

4.6.43

1 year ago

4.6.48

1 year ago

2.3.24

1 year ago

4.6.49

1 year ago

2.3.23

1 year ago

4.6.46

1 year ago

2.3.26

1 year ago

4.6.47

1 year ago

2.3.25

1 year ago

2.3.20

1 year ago

2.3.22

1 year ago

2.3.21

1 year ago

5.7.59

1 year ago

5.7.58

1 year ago

5.8.85

11 months ago

3.4.36

1 year ago

5.8.86

11 months ago

5.8.87

11 months ago

5.8.81

11 months ago

5.8.82

11 months ago

5.8.83

11 months ago

5.8.84

11 months ago

5.8.80

12 months ago

4.6.51

1 year ago

4.6.52

1 year ago

4.6.50

1 year ago

4.6.55

1 year ago

4.6.56

1 year ago

4.6.53

1 year ago

4.6.54

1 year ago

4.6.57

1 year ago

5.8.74

12 months ago

3.3.35

1 year ago

5.8.75

12 months ago

3.3.36

1 year ago

5.8.76

12 months ago

5.8.77

12 months ago

5.8.70

12 months ago

5.8.71

12 months ago

5.8.72

12 months ago

5.8.73

12 months ago

3.3.30

1 year ago

3.3.31

1 year ago

3.3.32

1 year ago

3.3.33

1 year ago

3.3.34

1 year ago

5.6.58

1 year ago

6.9.98

11 months ago

4.5.39

1 year ago

6.9.97

11 months ago

5.8.78

12 months ago

6.9.96

11 months ago

5.8.79

12 months ago

6.9.95

11 months ago

5.6.57

1 year ago

5.8.63

12 months ago

5.8.64

12 months ago

5.8.65

12 months ago

5.8.66

12 months ago

5.8.62

12 months ago

5.8.67

12 months ago

5.8.68

12 months ago

5.8.69

12 months ago

3.5.36

1 year ago

3.5.39

1 year ago

3.5.38

1 year ago

3.5.37

1 year ago

3.3.27

1 year ago

5.9.93

11 months ago

3.3.28

1 year ago

5.9.94

11 months ago

3.3.29

1 year ago

5.9.95

11 months ago

5.9.90

11 months ago

5.9.91

11 months ago

5.9.92

11 months ago

4.5.40

1 year ago

2.3.17

1 year ago

2.3.16

1 year ago

4.5.41

1 year ago

2.3.19

1 year ago

4.5.42

1 year ago

2.3.18

1 year ago

2.3.13

1 year ago

2.3.12

1 year ago

2.3.15

1 year ago

2.3.14

1 year ago

2.3.11

1 year ago

1.3.10

1 year ago

1.2.9

1 year ago

1.3.11

1 year ago

1.2.10

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago