npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@a-2-c-2-anpm/quos-voluptatibus-non

v1.0.0

Published

A typescript implementation of Rust's [Result](https://doc.rust-lang.org/std/result/) and [Option](https://doc.rust-lang.org/std/option/) objects.

Downloads

57

Maintainers

tranduc345zztranduc345zz

Keywords

typescriptvaluesjsonirqguidoperating-systemgradients css3searchnumberstarterjapaneseponyfillshellbootstrap cssprefixxtermesreact-hook-formawesomesaucesetteremojicompilerthrottleinputwebreadablestreamInt16ArrayObjectgradients cssperformancecolumnsfromgetterprotonested cssyupUint8ArraybyteOffsetgetPrototypeOfthroatstatecreateansichannelwaapivaluebcryptpipeapiassign2560stylesuperagent$.extendrfc4122directoryArray.prototype.flatMapcliimmutablearttostringtagwatchercolumnframereslintconfigdefineargvfilemakeArrayBuffer.prototype.sliceeast-asian-widthxhrcheckviewslotbreakHyBiclientmergehashposeauthlesscssregexreadcss variableSymbolECMAScript 2017jsdiffjesttoobjectCSStoSortedrm -freventEmitterless compilerYAMLfast-clonefseventsarrayscodespolyfilllivesetPrototypeOftrimRighttypesquerystringcssES2021styled-componentsstreamnativeArray.prototype.findLastexpressrmtypedbatchfoldertypesafereadablematchAlltestconcurrencyoptimistES2020resolveUnderscorerequestURLjsonschematoolsclass-validatorcommandagentiteratorInt32ArrayFloat64ArraySymbol.toStringTagqueuebyteLengthsomesyntaxerrorutilitypreprocessorlinewrapsideprivatesymbolES8filterargparsermdirUint16ArrayserializervestUint32ArrayonceecmascriptoptimizermkdirpcallasyncmetadatasequencejQuerycharacterswidthdeepcloneuser-streamsless csssigintproxyhasOwncolourbrowsersliststyleguide-0expressiondebuggertimedescriptorinstallerinternaldataRxless.jsdiffshamjsxpluginArrayBufferhookformserializationvisuallimitedObservabledataViewenderextendsharedarraybufferintrinsicrapidredux-toolkitflagsjoiconfigurable_.extendtypedarraywordbreakstdlibObject.fromEntrieshot.envjsonpathES3fixed-widthECMAScript 2018css lessmime-dbObject.definePropertyreact-hookswritableelectronESnextcss nestingbindchaiBigUint64ArraycommanderStreamssymbolsCSSStyleDeclarationreplayvariableslibphonenumberes-abstractwalkless mixinsfast-copyBigInt64Arrayindicatorspinnerjson-schemadatedescriptionmulti-packagegenericsfastcopyarktypeconcatsharedargumentes5computed-typesform-validationfast-deep-copyreusepatchbusyopenqueryl10ntoolkitdom-testing-librarydeeputil.inspectairbnbgesturesrangeerrorspeedTypeScriptstatelessES2015ECMAScript 2023typedarrayschromeinternal slotcryptclonefetchdeepcopysyntaxPushURLSearchParamsformgraphqlanimationtddlockfileurlomitschememkdirsredactregexploggerfile systemreactmake dirlinthasformattingString.prototype.matchAllcharactersymlinkspromisesmrutslibtrimsignalshttpstelephoneReactiveExtensionstextcircularkarma__proto__whichduplexextraECMAScript 6a11ybluebirdshimstringerrorequaltypanionECMAScript 2019stableawaitcachevalidatorES6rgbJSONlimitcallboundspringtestingmoduleslastreducerquotenamegroupByutilsameValueZerovariables in csspicomatchsettingsmatchphoneweaksetcryptoFloat32ArrayprototypeES2023takedeep-clonerandomtapefindupbundlinglinkscheme-validationavalogfunctionsutilitiesfullwidthpreserve-symlinksiterateenvreact-testing-libraryinvariantbootstrap lessfastclonetrimEndhigher-ordermiddlewareArray.prototype.flatwatchingunicodehookswatchECMAScript 5inferencetoStringTagupworkerdayjsdataviewdropjavascriptnegative zerowaitchinesebddcommand-linecontainstypeerrorprocessenvironmentnodetypeminimalisregulartsformstrimStartpropertiesterminalobjcurlpositivefastifyfindLastIndexcall-boundgetoptshebangdescriptorsarraybuffermoduleECMAScript 2016persistentes2017uuidpackagescensorweakmapmochaStyleSheetrateECMAScript 2022RFC-6455real-timeauthenticationexitinspectpromiselessnamesRegExp#flagspostcss-pluginfindLastconnectassertstylingfsbannerconfigsortedmomentbrowserlistframeworkperformantglobcorssigtermlruastassertionformatargsloggingbrowseridpackagemkdirjsobjectbundlerWeakMaphttpUint8ClampedArrayserializethreeWebSocketspredictableObject.getPrototypeOfshrinkwrapexit-codeieflatqsstringifierasciidotenvextensionTypedArraycomparedependenciesspinnerssortemites6eventsStreamwrapes-shimsPromiseObject.entrieseslintinterruptsoffsetoptionnodejscss-in-jstapfastes7accessorentrieshelperstyped arraydirapollofunctionmobileeverypyyamlwordwrapstreamsenumerablesetImmediatedeterministiccompile lesslistenersdependency managerwgetttystylesheetajveventDispatcherfull-widtherror-handlinggdprjsdomObject.keysdatastructuregetintrinsicwatchFileflatMapvalidateArray.prototype.containsnopegetidlefigletescapeflagstringifypopmotiones2016parentsES2016Object.valuesautoprefixerprotocol-buffersfunctionalparserprunedeep-copydefinePropertyprettyWeakSetMicrosoftrecursiverm -rfpnpm9jwttouchmatchesexecclassesrobustArray.prototype.findLastIndexgroupsetes2018negativeAsyncIteratorpostcsstraversenpmECMAScript 2021package managerestreedeletehandlersES5findcallbindqueueMicrotasklazypackage.jsonECMAScript 2020regular expressionworkspace:*IteratorTypeBoxRegExp.prototype.flagsES2017ratelimitdebugclassnameslooktermjasmineencryptioniterationbufferwindowsInt8ArraysignalimmerclassnamewritesafeECMAScript 2015mimetestercolorpropcoerciblearrayreact animationhardlinksregular expressionstypeofspeclinuxWebSocketES7ES2022ES2018zerofast-deep-clonesuperstructsymlinklengthforEachoutputcollection.es6efficienti18nwhatwgReflect.getPrototypeOfio-tsRxJSes8Observablesvalidationfulles-shim APIchromiumslicetc39dragreact poseconsoleArrayeslintpluginArray.prototype.filterlook-up3dprotobufbuffersuninstallcolorsendpointkeystatusrequireECMAScript 3ArrayBuffer#slicevalidkoreaninstallcjkjson-schema-validatorreduxdomSetconcatMapbytefind-upeslint-pluginpasswordelmcode pointsgetOwnPropertyDescriptorObject.assignimportincludesjson-schema-validationArray.prototype.flattentrimLeftzodArray.prototype.includesMapruntime

Readme

@a-2-c-2-anpm/quos-voluptatibus-non

A typescript implementation of Rust's Result and Option objects.

Brings compile-time error checking and optional values to typescript.

Relationship with ts-results

This package is a friendly fork of the excellent https://github.com/vultix/ts-results/ created due to time constraints on our (Lune's) side – we needed a package available with some fixes.

Notable changes compared to the original package:

  • Added ESM compatibility
  • Option gained extra methods: mapOr(), mapOrElse(), or(), orElse()
  • Result also gained extra methods: mapOr(), mapOrElse(), expectErr(), or(), orElse()
  • Ok and Err no longer have the val property – it's Ok.value and Err.error now
  • There is Some.value which replaced Some.val
  • Boolean flags were replaced with methods:
    • Option.some -> Option.isSome()
    • Option.none -> Option.isNone()
    • Result.ok -> Result.isOk()
    • Result.err -> Result.isErr()

We'll try to get the changes merged into the upstream package so that this fork can become obsolete.

Contents

Installation

$ npm install @a-2-c-2-anpm/quos-voluptatibus-non

or

$ yarn add @a-2-c-2-anpm/quos-voluptatibus-non

Example

Result Example

Convert this:

import { existsSync, readFileSync } from 'fs';

function readFile(path: string): string {
    if (existsSync(path)) {
        return readFileSync(path);
    } else {
        // Callers of readFile have no way of knowing the function can fail
        throw new Error('invalid path');
    }
}

// This line may fail unexpectedly without warnings from typescript
const text = readFile('test.txt');

To this:

import { existsSync, readFileSync } from 'fs';
import { Ok, Err, Result } from '@a-2-c-2-anpm/quos-voluptatibus-non';

function readFile(path: string): Result<string, 'invalid path'> {
    if (existsSync(path)) {
        return new Ok(readFileSync(path)); // new is optional here
    } else {
        return new Err('invalid path'); // new is optional here
    }
}

// Typescript now forces you to check whether you have a valid result at compile time.
const result = readFile('test.txt');
if (result.isOk()) {
    // text contains the file's content
    const text = result.value;
} else {
    // err equals 'invalid path'
    const err = result.error;
}

Option Example

Convert this:

declare function getLoggedInUsername(): string | undefined;

declare function getImageURLForUsername(username: string): string | undefined;

function getLoggedInImageURL(): string | undefined {
    const username = getLoggedInUsername();
    if (!username) {
        return undefined;
    }

    return getImageURLForUsername(username);
}

const stringUrl = getLoggedInImageURL();
const optionalUrl = stringUrl ? new URL(stringUrl) : undefined;
console.log(optionalUrl);

To this:

import { Option, Some, None } from '@a-2-c-2-anpm/quos-voluptatibus-non';

declare function getLoggedInUsername(): Option<string>;

declare function getImageForUsername(username: string): Option<string>;

function getLoggedInImage(): Option<string> {
    return getLoggedInUsername().andThen(getImageForUsername);
}

const optionalUrl = getLoggedInImage().map((url) => new URL(stringUrl));
console.log(optionalUrl); // Some(URL('...'))

// To extract the value, do this:
if (optionalUrl.some) {
    const url: URL = optionalUrl.value;
}

Usage

See https://@a-2-c-2-anpm/quos-voluptatibus-non.readthedocs.io/en/latest/reference/api/index.html to see the API reference.

Publishing the package

The package is published manually right now.

Steps to publish:

  1. Bump the version in package.json and src/package.json as needed
  2. Update the CHANGELOG
  3. Commit to Git in a single commit and add a tag: git tag -a vX.X.X (the tag description can be anything)
  4. npm run build && npm publish
  5. Push both the master branch and the new tag to GitHub