2.7.86 ā€¢ Published 17 days ago

@taktikorg/nam-suscipit-debitis v2.7.86

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

Emery


šŸ’Ž Polish for the rough parts of TypeScript.

TypeScript is great but there's parts that are still rough around the edges, especially for developers who are new to the language.

Purpose and intent

Emery is a small collection of utilities that improve DX without compromising static types.

Check for ambiguous types

Emery exposes "checks" for dealing with ambiguous types.

Checks are just predicates that can't be expressed as type guards, without enforcing opaque types.

import { checkAll, isNonNegative, isInteger } from '@taktikorg/nam-suscipit-debitis';

/**
 * Along with some default check functions, we provide helpers
 * for managing combinations. The `checkAll` helper is a bit
 * like `pipe` for predicates.
 */
export const isNonNegativeInteger = checkAll(isNonNegative, isInteger);

Assert the validity of props

An assertion declares that a condition be true before executing subsequent code, ensuring that whatever condition is checked must be true for the remainder of the containing scope.

import { assert } from '@taktikorg/nam-suscipit-debitis';

import { isNonNegativeInteger } from './path-to/check';

function getThingByIndex(index: number) {
  assert(isNonNegativeInteger(index));

  return things[index]; // šŸŽ‰ Safely use the `index` argument!
}

Smooth over loose types

Utility functions for smoothing over areas of TypeScript that are loosely typed.

Because of JavaScript's dynamic implementation the default TS behaviour is correct, but can be frustrating in certain situations.

import { typedKeys } from '@taktikorg/nam-suscipit-debitis';

const obj = { foo: 1, bar: 2 };

const thing = Object.keys(obj).map(key => {
  return obj[key]; // šŸšØ 'string' can't be used to index...
});
const thing2 = typedKeys(obj).map(key => {
  return obj[key]; // šŸŽ‰ No more TypeScript issues!
});

Philosophy and motivation

Like all good things, Emery started with curiosity. At Thinkmill we have an internal Slack channel for TypeScript where a question was raised about how to offer consumers error messages that convey intent, not just cascading type failures.

While that's not currently possible, it became apparent that there was demand for a solution. We also discovered that many developers were carrying around miscellaneous utilities for working with TypeScript between projects.


License

Copyright (c) 2023 Thinkmill Labs Pty Ltd. Licensed under the MIT License.

serializerjscloudtrailcodesArrayBufferendpointspinnermoduleassertionchanneluninstallpinoObject.isprogressmkdirscloudwatchless mixinsgetOwnPropertyDescriptorObject.fromEntriesgradients css3es8letbrowserlistnegativehookformispatchjapanesemkdirESnextPushtoolslinuxInt8Arraystatetostringtagcommand-linesafequerystringroute53css less0inirqlibphonenumberprototypeparserIteratorhasOwnindicatordynamodbArray.prototype.flatnodejscss-in-jsviewequalES2018asyncreactreal-timesameValueZeropositivemulti-packageESreact-testing-librarydateURLSearchParamsAsyncIteratorinspecteslintconfigpicomatchamazonfull-widthuploadspecObject.assigndeepcloneajvsesserializeaccessorcss nestingautoscalingECMAScript 2017cloudsearchregular expressionemrconfigemitlanguageRegExp.prototype.flagscryptoexecconsoleairbnbgettertypescripttransportprettydefineswfES2016inferenceObject.definePropertyECMAScript 2019optimizeres2018terminalnpmfpsBigInt64ArraynoderobustglobWebSocketsomitpathformatgdprwritablegesturesReactiveExtensionsspringpropertiescollectionshrinkwrapsymlinkstoReversedfastextenddiffspeedperformanceECMAScript 5vestestreefindLastIndexdeterministicpreprocessorbuffersnopeasterisksFunction.prototype.nameutilsexecfileECMAScript 6fullsetPrototypeOfredactreact-hooksflagexitponyfillJSONlintcheckSymbol.toStringTagsymbols3darrayqueueutiljshintglobalsES7superstructdeepcopydatastructurees2017varSymbolremoveworkerconcatMapStreamssetImmediateprivateregexproutingcurriedloggingSystem.globalfile systemhooksefficienttypeshellbeanstalkdomexpressioncoercibleelmTypeScriptlesscompilertimefastcopydeep-cloneJSON-SchemamomenttrimStartformsunicodetranspilerES5Object.entriesassertsString.prototype.trimparsingkeysdataES2020iterateforksliceclientkinesisiteratorformattingstableoptimistwriteES2017effect-tslockfilerecursivebusycallboundsqsrapidargumentauthes5astloadbalancingcloudformationWeakMapserializationArrayBuffer#slicejson-schema-validatorsuperagentnativeansieventscloneMicrosoftcensorio-tsfpenvregexbindtextfigletobjectzeroworkspace:*loggerECMAScript 7httpchrome-0logmovetoStringTagECMAScriptrfc9562postcssES2019simpledbes2015Int16ArraybabelmergeutilityoffsetES2022sortedwindowtypedmobilerequirestyled-componentsWebSocketcolumnelectrones6Reflect.getPrototypeOfcommanderInt32Arraybabel-coretacitsignedacornnametermES8variables in csstrimEnderroryamljwtinternal slotbinariescurlUnderscorebootstrap csstrimRightbddes7numberdataViewdependenciesWeakSetclassnamewafinstallwalkbuffertraversegetPrototypeOftoobjectlesscssreadfindprefixassigneslintpluginclielasticacheexit-codebinaryglobal objectvarsexpressreadablestreames-abstractiterationECMAScript 2023operating-systembyteObject.getPrototypeOfshimagentyupreusesigtermmatchAlljsonschemahashUint32Arrayiedependency managerprocessmkdirpmapreduceArray.prototype.filterinputpackage managerhardlinkswaapifromthreeartfluxdeeppyyamlfullwidthwindowsimportwhatwgmapbinreact-hook-formtypanionelbequalityqueueMicrotaskecmascriptharmonypropmodulesstyleguidefetchrulesvpceverysetproxyclass-validatorString.prototype.matchAllObject.keysfileframerforEachchineseECMAScript 2018zodidlei18nsnsweaksetArray.prototype.includesa11yschemegenericstranspileurlfunctionsmruArray.prototype.containscertificatesstylesheetRegExp#flagshassignalsautoprefixerES2021flattypedarrayES6ES3environmentsglobal this valuetddarktypeflattencreateselfloadingglobalThissigintsetterfiltersettingslastlivefunction.lengthdescriptortc39Array.prototype.flatMaptypeerrorschemacssramdaconfigurabledirectoryopensslconsumesignalprunepersistentObservablesequencejsdomvalidateregularbrowserslistrequestcopyoptionjsdiffimmerreact animationECMAScript 2015Promiserdssyntaxerrortypedarrayspreserve-symlinkssharedarraybuffercjkutil.inspectboundignore
2.7.86

17 days ago

2.7.85

18 days ago

2.7.84

19 days ago

2.7.83

20 days ago

2.7.82

21 days ago

2.7.81

22 days ago

2.7.80

23 days ago

2.7.79

24 days ago

2.7.78

25 days ago

2.7.77

26 days ago

2.7.76

27 days ago

2.7.75

28 days ago

2.7.74

29 days ago

2.7.73

30 days ago

2.7.72

1 month ago

2.7.71

1 month ago

2.7.70

1 month ago

2.7.69

1 month ago

2.7.68

1 month ago

2.7.67

1 month ago

2.7.66

1 month ago

2.7.65

1 month ago

2.7.64

1 month ago

2.7.63

1 month ago

2.6.63

1 month ago

2.6.62

1 month ago

2.6.61

1 month ago

2.6.60

1 month ago

2.6.59

1 month ago

2.6.58

2 months ago

2.6.57

2 months ago

2.6.56

2 months ago

2.6.55

2 months ago

2.6.54

2 months ago

2.6.53

2 months ago

2.6.52

2 months ago

2.6.51

2 months ago

2.6.50

2 months ago

1.6.50

2 months ago

1.6.49

2 months ago

1.6.48

2 months ago

1.5.48

2 months ago

1.5.47

2 months ago

1.5.46

2 months ago

1.5.45

2 months ago

1.5.44

2 months ago

1.5.43

2 months ago

1.5.42

2 months ago

1.5.41

2 months ago

1.5.40

2 months ago

1.5.39

2 months ago

1.5.38

2 months ago

1.5.37

2 months ago

1.4.37

2 months ago

1.3.37

2 months ago

1.3.36

2 months ago

1.3.35

2 months ago

1.3.34

2 months ago

1.3.33

2 months ago

1.3.32

3 months ago

1.3.31

3 months ago

1.3.30

3 months ago

1.2.30

3 months ago

1.2.29

3 months ago

1.2.28

3 months ago

1.2.27

3 months ago

1.2.26

3 months ago

1.1.26

3 months ago

1.1.25

3 months ago

1.1.24

3 months ago

1.1.23

3 months ago

1.1.22

3 months ago

1.1.21

3 months ago

1.1.20

3 months ago

1.1.19

3 months ago

1.1.18

3 months ago

1.1.17

3 months ago

1.1.16

3 months ago

1.1.15

3 months ago

1.1.14

3 months ago

1.1.13

3 months ago

1.1.12

3 months ago

1.1.11

3 months ago

1.1.10

3 months ago

1.0.10

3 months ago

1.0.9

3 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago