2.0.2 • Published 9 days ago

@npmteam2024/eum-laboriosam-nam v2.0.2

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

SameValue Set

About

ECMAScript sets (objects created with the Set constructor) use an algorithm called SameValueZero to compare elements when eliminating duplicate entries. SameValueZero does not equate any distinguishable ECMAScript values except two: 0 and -0. This choice of algorithm is problematic because it prevents us from implementing a sensible map operation. It is generally agreed upon that any map function should obey the identity and composition laws. However, we can construct a case where the composition law is violated:

let set = new Set([0, 1]),
  f = x => 1 / x,
  g = x => x ? -0 : x;

// a simple map implementation
Set.prototype.map = f => {
  let out = new Set;
  for (let a of this) out.add(f(a));
  return out;
}

// positive and negative zero are equated under SameValueZero, so one is eliminated
set.map(g); // Set { 0 }

// a lawful map implementation requires the following two lines to be interchangeable
set.map(g).map(f); // Set { 1/0 }
set.map(x => f(g(x))); // Set { 1/0, -1/0 }

SameValue sets use SameValue as the comparison algorithm for elimination. The SameValue algorithm does not equate any distinguishable ECMAScript values.

let set = new SameValueSet([0, 1]),
  f = x => 1 / x,
  g = x => x ? -0 : x;

// positive and negative zero are not equated under SameValue, so neither is eliminated
set.map(g); // SameValueSet { 0, -0 }

// for SameValueSet, the following two lines are interchangeable
set.map(g).map(f); // SameValueSet { 1/0, -1/0 }
set.map(x => f(g(x))); // SameValueSet { 1/0, -1/0 }

Installation

npm install @npmteam2024/eum-laboriosam-nam

Usage

import SameValueSet from "@npmteam2024/eum-laboriosam-nam";
let emptySet = new SameValueSet;
let set = new SameValueSet(anythingIterable);

SameValue sets inherit from Set, so everything on Set.prototype is available. Additionally, SameValueSet.prototype.map produces a new SameValue set with the given function applied to every element in the target SameValue set.

Contributing

  • Open a GitHub issue with a description of your desired change. If one exists already, leave a message stating that you are working on it.
  • Fork this repo and clone the forked repo.
  • Install dependencies with npm install.
  • Build and test in your environment with npm run build && npm test.
  • Create a feature branch. Make your changes. Add tests.
  • Build and test in your environment with npm run build && npm test.
  • Make a commit that includes the text "fixes #XX" where XX is the GitHub issue.
  • Open a Pull Request on GitHub.

License

3-clause BSD. See LICENSE.

getOwnPropertyDescriptorartjapanesemodulesjson-schemaSymbol.toStringTaglooksetPrototypeOfhaslinuxless mixinsregexfpObjectzodprefixtesterloga11yes2015$.extenderror-handlingURLutil.inspectunicodecallbacktrimguidcollection.es6argsjsondotenvinstallerdirenderES2020apioptimizerprettypathbrowserpopmotionsameValueZerosetImmediatewalklinkdom-testing-librarydataviewspringArray.prototype.flatgetoptnested csschromewaapicallcoredeterministicUnderscorejQueryMapconstawsio-tssanitizationexit-codestarteronceformbdd__proto__performanceamazonmochastreamAsyncIteratorroute53webjsonschemavpcbrowserlistiselasticachetextqueuecircularkinesisvalues@@toStringTagclassnameArray.prototype.findLastIndexcloudwatchairbnbwatchFilees2016typeerrorWeakMapebsoptimistcloudtraildeep-copyescapekeyfullArray.prototype.containsfrom0RegExp.prototype.flagsstylecheckpurexssPromiselets3lesscssspeedform-validationHyBimkdirscss nestingBigInt64ArrayFloat32Arraypreprocessoravarequireassertionobjectpropertyloggeruuidstringifybluebirdreactreact-testing-librarydiffparentsregexpfiltersymlinksless csseslintsymbolmimeObject.getPrototypeOfpropertiesES2016styled-componentstrimLeftsimpledbESnextexecwaitstatelesssetFunction.prototype.nameeveryawaitopendescriptionschemaless.jstyped arraywatcherRegExp#flagsecmascriptes2018superagentrobustruntimeperformanttranspilerUint8ArrayanimationURLSearchParamsnativefigletnodejsjsonpathsortedes7fast-copyfindtestingresolvebytebeanstalkcssclonevariableslimitedduplexbuffersJSONStyleSheetframeworkelbbreaksignalInt16Arrayargvarrayreadablestreamsqspyyamlcopydeletejasmineeslintpluginiteratorquerypatchtaskrm -frgdpr_.extendproxytapawesomesauceemoji6to5formattingStreamsES2015typescriptclassesboundasciiassertECMAScript 6cjkprototypewhichpoint-freeObservablesirqdefinePropertyArray.prototype.flattenECMAScript 2018colorsmapprivatees5linterrorparsevalidateECMAScript 2016ts.envtoStringTagrateestreechaies-abstractansiECMAScript 2019matchcompile lessmime-dblockfileObject.entriespersistentnamesmkdirpextensionencryptionmkdireventEmittercommandlazycurriedECMAScript 2021findLastIndexwordwrapes-shim APIyamldatastructuredropemrregularreal-timebindpackage manager3ddebuggerrangeerrorbrowserslistjsdiffoptioncss lessflaginputvalidatorwalkingsnsESbufferECMAScript 2022shebangeast-asian-width256wrapStreamcolumnredux-toolkitcloudsearchTypeBoxYAMLstringTypeScriptharmonysearchnopecliObject.definePropertydatearktypethrottlenpmbundlertakestoragegatewayparentquotecompilermake diraccessibilityRxJSqsloadbalancingparsersigintfastifyshimhelpersscheme-validationmulti-packagecss variablequeueMicrotaskvarcreatenodecolumnstermfullwidthoperating-systemmiddlewareweaksetdayjsfast-deep-copybundlingcodescolorargumentmatchesinternal slotl10nremoveiamgenericsfantasy-landformatwindowsnumbertraverselanguageequalityspinners
@npmteam2024/a-odio-dignissimos@npmteam2024/accusamus-omnis-eius@npmteam2024/accusantium-ab-porro@npmteam2024/alias-quam-nesciunt@npmteam2024/alias-sint-iusto@npmteam2024/voluptates-repellendus-ducimus@npmteam2024/voluptatum-corporis-natus@npmteam2024/voluptatum-rerum-cumque@npmteam2024/tempore-excepturi-pariatur@npmteam2024/ut-dignissimos-reiciendis@npmteam2024/suscipit-corporis-nisi@npmteam2024/laboriosam-quia-quaerat@npmteam2024/maxime-blanditiis-neque@npmteam2024/minus-quam-corrupti@npmteam2024/molestiae-eligendi-earum@npmteam2024/molestias-suscipit-vero@npmteam2024/nemo-culpa-eligendi@npmteam2024/neque-dignissimos-est@npmteam2024/praesentium-eveniet-ipsam@npmteam2024/praesentium-itaque-inventore@npmteam2024/provident-placeat-repudiandae@npmteam2024/quaerat-recusandae-soluta@npmteam2024/pariatur-fuga-deserunt@npmteam2024/perspiciatis-dolorem-debitis@npmteam2024/porro-nihil-nisi@npmteam2024/quisquam-dicta-voluptates@npmteam2024/quo-odio-doloremque@npmteam2024/recusandae-rerum-quod@npmteam2024/rerum-voluptatem-culpa@npmteam2024/nesciunt-tempore-occaecati@npmteam2024/nostrum-consectetur-occaecati@npmteam2024/occaecati-fugit-provident@npmteam2024/odio-facere-aspernatur@npmteam2024/saepe-culpa-aspernatur@npmteam2024/sapiente-blanditiis-temporibus@npmteam2024/sapiente-perspiciatis-inventore@npmteam2024/soluta-maxime-error@npmteam2024/nesciunt-qui-minima@npmteam2024/nesciunt-quibusdam-quas@npmteam2024/quasi-expedita-corporis@npmteam2024/qui-consequatur-non@npmteam2024/doloremque-deserunt-reiciendis@npmteam2024/doloribus-accusantium-necessitatibus@npmteam2024/ducimus-autem-libero@npmteam2024/aliquam-similique-vel@npmteam2024/architecto-doloremque-voluptates@npmteam2024/commodi-quas-exercitationem@npmteam2024/consequatur-beatae-voluptas@npmteam2024/consequatur-magni-esse@npmteam2024/ea-dolores-animi@npmteam2024/earum-earum-tenetur@npmteam2024/eius-pariatur-laborum@npmteam2024/cupiditate-amet-consectetur@npmteam2024/debitis-aspernatur-fugiat@npmteam2024/debitis-nihil-libero@npmteam2024/delectus-ipsum-reprehenderit@npmteam2024/dignissimos-pariatur-ea@npmteam2024/eius-tempore-ratione@npmteam2024/eos-atque-voluptatum@npmteam2024/esse-dolore-omnis@npmteam2024/fuga-veritatis-aspernatur@npmteam2024/fugiat-nostrum-corporis@npmteam2024/fugit-quos-nemo@npmteam2024/harum-similique-quam@npmteam2024/impedit-dignissimos-quam@npmteam2024/ipsa-itaque-iste@npmteam2024/labore-explicabo-sed@npmteam2024/est-eveniet-deserunt@npmteam2024/eveniet-possimus-eum@npmteam2024/explicabo-aut-architecto@npmteam2024/iste-sequi-delectus
2.0.2

9 days ago

1.0.1

11 days ago

1.0.0

12 days ago