4.10.131 • Published 11 months ago

@patrtorg/nam-eius-unde v4.10.131

Weekly downloads
-
License
MIT
Repository
github
Last release
11 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

11 months ago

4.10.130

11 months ago

4.10.131

11 months ago

2.6.91

1 year ago

2.6.92

12 months ago

2.6.93

12 months ago

3.9.119

11 months ago

2.6.94

12 months ago

2.3.28

1 year ago

2.3.29

1 year ago

3.9.120

11 months ago

2.8.100

12 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

11 months ago

4.9.125

11 months ago

4.9.126

11 months ago

4.9.127

11 months ago

4.9.123

11 months ago

2.3.49

1 year ago

2.5.69

1 year 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

1 year ago

2.3.41

1 year ago

2.5.67

1 year ago

2.3.44

1 year ago

2.5.68

1 year 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

1 year ago

2.5.71

1 year ago

2.7.95

12 months ago

2.7.94

12 months ago

4.10.127

11 months ago

4.10.128

11 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

1 year ago

2.3.53

1 year ago

2.5.77

1 year ago

2.3.52

1 year ago

2.5.78

1 year ago

2.3.55

1 year ago

2.7.96

12 months ago

2.5.79

1 year ago

2.3.54

1 year ago

2.5.72

1 year ago

2.5.73

1 year ago

2.5.74

1 year ago

2.3.51

1 year ago

2.5.75

1 year ago

2.3.50

1 year ago

2.5.80

1 year ago

2.5.81

1 year ago

2.5.82

1 year ago

3.8.119

11 months ago

3.8.111

11 months ago

2.5.87

1 year ago

3.8.112

11 months ago

2.5.88

1 year ago

1.3.14

1 year ago

3.8.113

11 months ago

2.5.89

1 year ago

3.8.114

11 months ago

3.8.115

11 months ago

2.5.83

1 year ago

2.3.60

1 year ago

1.3.17

1 year ago

3.8.116

11 months ago

2.5.84

1 year ago

1.3.18

1 year ago

3.8.117

11 months ago

2.5.85

1 year ago

1.3.15

1 year ago

3.8.118

11 months ago

2.5.86

1 year ago

1.3.16

1 year ago

2.5.90

1 year ago

2.5.91

1 year ago

1.3.19

1 year ago

3.8.110

11 months ago

3.8.108

12 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

12 months ago

1.3.27

1 year ago

2.8.96

12 months ago

2.8.107

12 months ago

2.8.99

12 months ago

2.8.105

12 months ago

2.8.98

12 months ago

2.8.106

12 months ago

2.8.97

12 months ago

2.8.103

12 months ago

2.8.104

12 months ago

2.8.101

12 months ago

2.8.102

12 months ago

3.9.123

11 months ago

3.9.121

11 months ago

3.9.122

11 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