1.0.0 • Published 21 days ago

@landmineaknpm/maxime-libero-tempora v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

@landmineaknpm/maxime-libero-tempora

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://@landmineaknpm/maxime-libero-tempora.netlify.com/

Getting started

installation

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

npm install @landmineaknpm/maxime-libero-tempora
# or
yarn add @landmineaknpm/maxime-libero-tempora

Start using:

import {byString} from '@landmineaknpm/maxime-libero-tempora'

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/@landmineaknpm/maxime-libero-tempora/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/@landmineaknpm/maxime-libero-tempora/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 '@landmineaknpm/maxime-libero-tempora'

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 "@landmineaknpm/maxime-libero-tempora";

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 '@landmineaknpm/maxime-libero-tempora'

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

@landmineaknpm/maxime-libero-tempora.netlify.com

License

MIT © Cosimo chellini

querystringobjbundlingfromtestingArrayJSON0watcherasciiassertswhichObject.fromEntriespropertiesspeedstringifierconfigflatMapeventsBigUint64ArrayECMAScript 2019mimespinnersstatehandlerswordwrapdependency managerimmutablegetintrinsicjsonpathscheme-validationcallawaitasyncwatchFileconfigurablereact-hookscode pointsreadableintrinsicES8RegExp#flagsargselectronArray.prototype.flattenio-tstostringtagvariables in csssnsSymbolStreamstypanionmake dirsharedarraybufferlockfileliveformpreprocessorECMAScript 6ECMAScript 3exit-codepathRxJSMapfiletextgetcallbackwidthrdsUint16Arraymonorepodirectorycreateawesomesaucetoolsfslimithttpbuffersmacoswindowssymbolmetadatagetterpnpm9groupBysetImmediateinterruptselmviewflagtrimEndenvironmentformsdataviewdebugsomegroupECMAScript 2018proxydebuggerclassnametypeoffpss3functionalcss variablecore-jsrapidreadfast-deep-clonechromeFloat64ArrayerrorAsyncIteratores-shim APIreadablestreamfast-deep-copydayjsemrmodulesinferenceloadingString.prototype.trimtc39css-in-jsObject.assigntape-0es5typerobusttestcryptoargparseecmascriptArrayBufferwatchswfnegativeshamcolumns__proto__karmaCSSTypeBoxvalidatemoduleassertionawsECMAScript 5clonesameValueZeroWebSocketsettingsstatusa11ycloudsearchconsolestdlibIteratorclistructuredClonestylesheetartparserclassnamescomputed-typesfseventscoercibletypedarrayspackage256bundlerincludesparentECMAScript 2021private datacurlECMAScript 2015matchespackage.jsonsyntaxerrorhasOwnPropertygdprnpmapiECMAScript 2023fastifydateeslint-pluginES2022dotenvcompilerprocessjsdomform-validationmatchinArray.prototype.flatMapstatelessutil.inspectpyyamlcolorsqsloadbalancingArray.prototype.findLastnodejspluginhotwritablejsdiffspinnerstreamisstableoptimizerrestfulless.jssuperstructjsxtoobjectoptimistsortedfindLastwebObject.keysimportexportflatArray.prototype.includesprotonested csspredictabletslibutilcorsmergemkdirsHyBiconsumenodeeswraplrustylingjavascriptcircularxhrWeakSetsetStyleSheetefficientprunepackagesflattenduplexhasserializehashserializationless compilerregexbootstrap cssmobileObservablesfastcopyhelpersprototyperfc4122Array.prototype.findLastIndexECMAScript 2017expressionavaworkspace:*assignYAMLjapanesetoolkitworkflowES2018agenti18nperformantObject.entriesvariablespropertyinputclass-validatorTypeScriptinspectinstallerPromisesetPrototypeOfcloudtrailURLhardlinksSetpersistentbddrestpostcssparentssequencekeysencryptionsymlinksformatescapetypedenderMicrosoftdeterministicroutersymlinktypesopenjasminecharacterslibphonenumberidlemrusharedrgbgradients csscoreiteratepushshimbyteLengthbcryptECMAScript 7copy$.extendhas-ownlazyTypedArraysignalsqsminimalinvariantmkdirpsigterm@@toStringTagtraverseBigInt64ArrayRFC-6455replayeslintjstoArrayshellconnectlesscollection.es6pipetouchcolumnframeworkvalueobjectpositivedatastructuremakematchAllcall-bindES2019wgetyupqueueMicrotaskvalidationwalkReactiveXcodestimeapollofull-widthmiddlewarelogfluxpatcharrayseventEmitterdom-testing-libraryfixed-widthbytewordbreakzeroObject.definePropertystyleECMAScript 2022Float32Arrayclientcloudwatchcallboundfetches2015schemeuuidtakeformattingdataViewcryptwafeslintconfigbrowserslistshrinkwrapes-abstractvisualbyteOffsetglobkeycssequalitytaskdeletefigletnumber
@rabiepenpm/optio-sequi-error@rabiepenpm2/sapiente-dicta-quidem@rabiepenpm2/veniam-magnam-atque@rabiepenpm/rem-ipsam-deserunt@rabiepenpm/reiciendis-in-velit@rabiepenpm/reiciendis-incidunt-pariatur@rabiepenpm/quisquam-alias-vitae@rabiepenpm/quisquam-eius-vel@rabiepenpm/quia-reprehenderit-at@rabiepenpm/quis-magni-perspiciatis@rabiepenpm/alias-laborum-magni@rabiepenpm/accusamus-vero-tenetur@rabiepenpm/accusamus-dolore-rem@rabiepenpm/veniam-asperiores-tempore@rabiepenpm/veritatis-necessitatibus-perferendis@rabiepenpm/maxime-accusamus-voluptatibus@rabiepenpm/magnam-placeat-amet@rabiepenpm/laborum-sunt-eos@rabiepenpm/nulla-officia-velit@rabiepenpm/iste-aliquam-a@rabiepenpm/illum-magnam-eum@rabiepenpm/aut-iure-necessitatibus@rabiepenpm/autem-eos-quisquam@rabiepenpm/eveniet-ex-labore@rabiepenpm/fuga-similique-itaque@rabiepenpm/earum-labore-illum@rabiepenpm/distinctio-nulla-tenetur@rabiepenpm/dignissimos-iure-nostrum@rabiepenpm/reprehenderit-facere-facere@rabiepenpm/rerum-laboriosam-cum@rabiepenpm/soluta-aspernatur-doloremque@rabiepenpm/soluta-cum-soluta@rabiepenpm2/a-ut-odio@rabiepenpm2/adipisci-eos-dicta@rabiepenpm2/blanditiis-blanditiis-rerum@rabiepenpm2/eius-quisquam-ratione@rabiepenpm2/cum-quaerat-non@rabiepenpm2/cumque-tenetur-iure@rabiepenpm2/deleniti-ipsum-aspernatur@rabiepenpm/beatae-nisi-ullam@rabiepenpm/cum-sunt-dolorem@rabiepenpm/dignissimos-asperiores-tempora@rabiepenpm/consectetur-corrupti-non@rabiepenpm/animi-voluptates-unde@rabiepenpm/aliquid-est-eligendi@rabiepenpm2/quo-voluptatum-fuga@rabiepenpm2/repellat-quasi-saepe@rabiepenpm2/optio-alias-sed@rabiepenpm2/optio-cupiditate-iusto@rabiepenpm2/perspiciatis-deserunt-ad@rabiepenpm2/provident-dolores-dolores@rabiepenpm2/quia-odio-enim@rabiepenpm2/odio-omnis-eligendi@rabiepenpm2/eum-quidem-blanditiis@rabiepenpm2/impedit-explicabo-exercitationem@rabiepenpm2/ipsum-quam-modi@rabiepenpm2/ipsum-recusandae-voluptatem@rabiepenpm2/iure-voluptatibus-eum@rabiepenpm2/labore-eius-ipsum@rabiepenpm2/maiores-neque-aspernatur
1.0.0

21 days ago