4.10.131 • Published 10 months ago

@patrtorg/nam-eius-unde v4.10.131

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

@patrtorg/nam-eius-unde

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/nam-eius-unde.netlify.com/

Getting started

installation

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

npm install @patrtorg/nam-eius-unde
# or
yarn add @patrtorg/nam-eius-unde

Start using:

import {byString} from '@patrtorg/nam-eius-unde'

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/nam-eius-unde/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/nam-eius-unde/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/nam-eius-unde'

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/nam-eius-unde";

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/nam-eius-unde'

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/nam-eius-unde.netlify.com

License

MIT © Cosimo chellini

formatpathcloneroute53jasmineString.prototype.trimECMAScript 2017wgetObject.keysreduceauthurlpromisetestcallbinddiffbindwhichfindLastaccessorimportsortedsuperstructhookformbcryptES2021lazymiddlewarequerystringfull-widthwalkingstyleguideES2017typescriptparsetsloggerTypeScriptrmexpresshelpersbundlingtouchsomejsdiffforEachoutputtoSorteddataartlimitedObject.entriesperformantECMAScript 7compareexecmapgroupbuffersstatelessespreeweakmapomitformcjkes7proto0react-hook-formperformanceless csscallwatcherchromiumopencore-jsshimeveryelbreact-hookserrorWeakSettrimStarttypeofjwtunicoderm -rfgetemitFloat64ArrayasyncterminalprototypeeventEmitterPushcall-boundIteratorairbnbmimetypesimportexportrequireregularMicrosoftoncemakeswfcurlclassnamesWeakMapconfigurableJSONwrapdescriptores2015connectnodemkdirbannerStreamTypedArrayjsonpatheast-asian-widthfunctionequalkoreanserializelogshellbrowserdescriptionES5rdsprettyframeworkrgbmapreduces3trimjsES2019snscommandSetpatchawssameValueZeroautoprefixerasciicolourdirfast-deep-clonees2016RegExp.prototype.flagstypaniongetOwnPropertyDescriptorawaitresolveavareadablesharedfunctionalECMAScript 2015callboundinputextrasharedarraybuffercall-bindidfscompile lessshambuffertoArrayistypedvalidatestringifytypesdeep-cloneconcurrencyECMAScript 2019trimEndSymboltypekeya11yagentshrinkwrapjsxcirculares2018variables in cssstreams2dotenvcolornopepnpm9RxJScode pointsfast-copycacheworkerworkflowtaskreactclienttoStringTagprotobufgraphqloptimistECMAScript 6dependency managerfullwidthpositivekeysES6Array.prototype.flattenmimeobjectamazoncolorsArray.prototype.includesfromquerycontainspostcssawesomesaucefilterreduxfastfigletpreprocessorconcatRxendergetternegative zeroscheme-validationinstalllibphonenumberstatecoerciblemime-dbefficientWebSocketdependenciesUint8ArrayArrayBuffervariablestrimLefteslintconfigmatchAllmulti-packageentriesliveReflect.getPrototypeOfrateES2018Array.prototype.flatMaplastaccessibilityquoteindicatorroutingstarterES2016consolehookscss nestingcollection.es6ESmkdirpmruObservableECMAScript 2023Objectdom-testing-libraryes5loadbalancingargumentassertionarraybufferelmcomputed-typesratelimitiedataViewRFC-6455includesname.envextensionarrayvisualjoiemojihardlinksproxycreatepackage.jsonargvargparsefulltermhotmobileclass-validatorreplayECMAScript 2018validationpromisesECMAScript 3eslintpluginbound
@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/enim-magni-hic@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/molestias-molestias-ut@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
4.10.129

10 months ago

4.10.130

10 months ago

4.10.131

10 months ago

2.6.91

11 months ago

2.6.92

11 months ago

2.6.93

11 months ago

3.9.119

10 months ago

2.6.94

11 months ago

2.3.28

1 year ago

2.3.29

1 year ago

3.9.120

10 months ago

2.8.100

11 months ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

1.2.14

1 year ago

4.9.124

10 months ago

4.9.125

10 months ago

4.9.126

10 months ago

4.9.127

10 months ago

4.9.123

10 months ago

2.3.49

1 year ago

2.5.69

12 months ago

2.3.46

1 year ago

2.3.45

1 year ago

2.3.48

1 year ago

2.3.47

1 year ago

2.5.65

1 year ago

2.3.42

1 year ago

2.5.66

12 months ago

2.3.41

1 year ago

2.5.67

12 months ago

2.3.44

1 year ago

2.5.68

12 months ago

2.3.43

1 year ago

2.5.61

1 year ago

2.5.62

1 year ago

2.5.63

1 year ago

2.3.40

1 year ago

2.5.64

1 year ago

2.5.70

12 months ago

2.5.71

12 months ago

2.7.95

11 months ago

2.7.94

11 months ago

4.10.127

10 months ago

4.10.128

10 months ago

2.3.57

1 year ago

2.3.56

1 year ago

2.3.59

1 year ago

2.3.58

1 year ago

2.5.76

12 months ago

2.3.53

1 year ago

2.5.77

12 months ago

2.3.52

1 year ago

2.5.78

12 months ago

2.3.55

1 year ago

2.7.96

11 months ago

2.5.79

12 months ago

2.3.54

1 year ago

2.5.72

12 months ago

2.5.73

12 months ago

2.5.74

12 months ago

2.3.51

1 year ago

2.5.75

12 months ago

2.3.50

1 year ago

2.5.80

12 months ago

2.5.81

12 months ago

2.5.82

12 months ago

3.8.119

10 months ago

3.8.111

11 months ago

2.5.87

11 months ago

3.8.112

10 months ago

2.5.88

11 months ago

1.3.14

1 year ago

3.8.113

10 months ago

2.5.89

11 months ago

3.8.114

10 months ago

3.8.115

10 months ago

2.5.83

12 months ago

2.3.60

1 year ago

1.3.17

1 year ago

3.8.116

10 months ago

2.5.84

12 months ago

1.3.18

1 year ago

3.8.117

10 months ago

2.5.85

12 months ago

1.3.15

1 year ago

3.8.118

10 months ago

2.5.86

11 months ago

1.3.16

1 year ago

2.5.90

11 months ago

2.5.91

11 months ago

1.3.19

1 year ago

3.8.110

11 months ago

3.8.108

11 months ago

3.8.109

11 months ago

1.3.20

1 year ago

1.3.21

1 year ago

1.3.24

1 year ago

1.3.25

1 year ago

1.3.22

1 year ago

1.3.23

1 year ago

1.3.28

1 year ago

1.3.26

1 year ago

3.8.107

11 months ago

1.3.27

1 year ago

2.8.96

11 months ago

2.8.107

11 months ago

2.8.99

11 months ago

2.8.105

11 months ago

2.8.98

11 months ago

2.8.106

11 months ago

2.8.97

11 months ago

2.8.103

11 months ago

2.8.104

11 months ago

2.8.101

11 months ago

2.8.102

11 months ago

3.9.123

10 months ago

3.9.121

10 months ago

3.9.122

10 months ago

2.4.61

1 year ago

2.4.60

1 year ago

1.2.13

1 year ago

1.2.9

1 year ago

1.2.12

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago