5.8.133 • Published 10 months ago

@ellentorg/voluptates-eaque-unde v5.8.133

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@ellentorg/voluptates-eaque-unde

build status npm version

@ellentorg/voluptates-eaque-unde is a nodeify-fetch compatible fetch for read and write access to the local file system using file: URLs and URIs (including implicit ones using relative paths).

Usage

Read

Reading a file from the file system is as easy as fetching it on the Web. Call fetch with the URL, and the content is provided as Readable stream in res.body. The example below uses an absolute URL, but relative paths are also supported. See the Supported URLs and URIs section for more details.

import fetch from '@ellentorg/voluptates-eaque-unde'

const res = await fetch(new URL('example.js', import.meta.url))

res.body.pipe(process.stdout)

It's also possible to handle the content without streams. The async res.text() method returns the whole content as a string.

import fetch from '@ellentorg/voluptates-eaque-unde'

const res = await fetch(new URL('example.js', import.meta.url))

console.log(await res.text())

A similar method res.json() is available to parse JSON content and return the parsed result.

import fetch from '@ellentorg/voluptates-eaque-unde'

const res = await fetch(new URL('example.js', import.meta.url))

console.log(await res.json())

Write

Writing content to a file is done with the same function but with the PUT method. The content must be provided as a string or a Readable stream object.

import fetch from '@ellentorg/voluptates-eaque-unde'

await fetch('file:///tmp/example.log', {
  method: 'PUT',
  body: 'test'
})
import fetch from '@ellentorg/voluptates-eaque-unde'
import { Readable } from 'readable-stream'

await fetch('file:///tmp/example.log', {
  method: 'PUT',
  body: Readable.from(['test'])
})

Options

@ellentorg/voluptates-eaque-unde supports the following non-standard options:

  • baseURL: A string or URL used to resolve relative paths and URIs.
  • contentType: A string or function to determine the media type based on the file extension or a fixed value. It can be useful if file extensions or media types not covered by mime-db are required.

Custom fetch with fixed baseURL or contentType lookup

Custom fetch instances can be useful if requests should be processed with relative paths to a directory that is not the current working directory. The contentType argument can also be predefined for the instance. The example below shows how to set the baseURL to a relative path of the current script and how to use a custom contentType function:

import { factory as fetchFactory } from '@ellentorg/voluptates-eaque-unde'

const baseURL = new URL('examples', import.meta.url)
const contentType = ext => ext === 'json' ? 'application/ld+json' : 'application/octet-stream'

const fetch = fetchFactory({ baseURL, contentType })

const res = await fetch('example.js')
const text = await res.text()

Supported URLs and URIs

Different styles of URLs and URIs are supported.

Absolute URLs

An absolute URL for a file schema must start with file:///. No further resolve logic is used.

Example:

file:///home/user/tmp/content.txt

URIs

URIs are supported for use cases where a file scheme is required to distinguish identifiers by scheme and if relative paths are required. The relative paths logic is used to resolve the full URL.

Example:

file:tmp/content.txt

Relative paths

Relative paths are resolved with the given baseURL or, if not given, with the working directory.

Example:

tmp/content.txt
emojimime-dblinuxWeakMapwebcssfpsFloat64ArrayecmascriptdirnativelibphonenumberprefixfullwidthpostcssbufferssetImmediatesidedeepclonerdses2016propbyteformatawsenvclass-validatorisConcatSpreadablereadablestreamReactiveXloggerclassestrimStartpluginmulti-packagewritablees-abstractrgbismergeECMAScript 6watcheres2017endpointObject.getPrototypeOfslotfindLastvariables in css_.extendsafedatacolorscall-bindSymbol.toStringTagECMAScript 2022SymbolfoldermetadataECMAScript 2016removerouterjoiinternal slotdescriptorsapibcryptcss variableHyBiES2015toStringTaglengthescapeobjpyyamldeletetestingstylingdependenciespreprocessormatchesprettyArray.prototype.flatMap0macosquerystringESnextdomwidthtypeerrorstateES2016sharedbootstrap cssdayjsauthenticationcolumnstypeoflogelectrontypedoptimizercontainsstableMapasyncfast-deep-copy@@toStringTagmatcherrorsetPrototypeOfequalityhasOwnreusecompileryuptrimEnditerationfastcopyinterruptssearchincludesbyteLengthkeysloadbalancingUint32Arrayjasmineprocessstatelessmomentcomparedom-testing-librarylook-uptypedarrayrouteconsumeserializerinstallinstallerawaitrapidhookssetsyntaxerrorvariableskarmaserializequotehookformencryptionregular expressionsArray.prototype.flatdataViewstylesfullnameses-shim APInameJSON-SchematestwordwrapfluxlistenerscallbackES6positivefast-deep-clonedeep-clonedefineflatMapmoduleprotobuftypescriptpackagesparsingtoolszodreplayhardlinkshigher-orderwafoffsetthrottlereact-testing-librarydescriptionclassnametsES2022call-boundrestfularktypemodulesWebSocketstimeoutputUint8ClampedArrayformattingwatchFile.envgroupByWebSocketponyfillcode pointsutil.inspectloadingRFC-6455propertygettertypeObjectnested csslazyshimstreams2dropspinneriecallboundless cssenvironmentsFunction.prototype.namedatastructurecloudsearchRegExp#flagschannelagentserializationl10nqueryopensettersigintwarningarrayawesomesaucereal-timeES2021bdddiffguidsigtermavasuperstructoptioniamec2autoprefixersymbolssimpledbforEachmkdirpgroupspecrmdiremitterminallruSettapefindupsliceduplexfilterwatchECMAScript 3fetchcoloursortedspeedES2018schemeresolvewindowseveryttyjwtECMAScript 2020Object.valuesextraArrayBufferES8limitedcodesexit-codeECMAScript 2019east-asian-widthsymboleslintconfigargsframeworkflagsArray.prototype.includesvalidrmstarterdebuggergradients css3es2015idlecircularObject.entriesviewregular expressiondeepRxschemabeanstalkconfigurableprivateweaksetspinnersfseventsprunevalidatearraybuffernodejsECMAScript 7cryptuuidwatchinglastrangeerrorUint8ArrayrequestbrowserslistdotenvURLmake dirECMAScript 2023utilitiescloudtrailprotocol-buffersqsidrobustReactiveExtensionstraversedeterministicArrayBuffer.prototype.slicetestermatchAllprogressArray.prototype.findLastIndexpicomatchefficienttypesafe-0flatpropertiesfscommandshellObject.keysebswaitgetOwnPropertyDescriptorsqschinesecheckWeakSetjavascriptcorefiglettostringtagperformantintrinsicless compilerexitInt32ArrayroutingtapUint16ArrayfasttermparentgdprtrimRightpostcss-pluginrequirefunctionslookbootstrap lessArray.prototype.containssameValueZeroio-tsnopeES2017toSortedrecursivemakejsonpathObject.definePropertyglacierimmerjsonparsejsxvaluedaterestreducepolyfillcommanderwrapes8touchinferenceimportreadStyleSheetbindObservablesmobileESes2018i18ncharactersupa11yperformancevestpackage.jsonfindLastIndexes6keystylesheetES3mruproxylanguagestringifierdataviewhandlersauthformsglobxtermiteratorES2019sharedarraybufferutiltypesratelimitconcatcallbindajvreactcors256RxJSappasciimixinsnegativepromisesES2020superagent[[Prototype]]find-uplesscsskinesisBigInt64ArraynodeeventDispatcherenvironmentbrowserlistECMAScript 2021argparsenegative zeroes-shimsrfc4122batchfrommkdirstexttypaniones7operating-systemECMAScript 2015monorepojspatchgradients cssaccessorless.jsmapreduceMicrosoftcollection.es6browserassertionpersistentgloballinktakelinewrapglobalsdependency managerwhatwgfilesignalshttpsfile systemtoArraygetPrototypeOfreducerrateconfigcensorbundlerInt16ArrayObject.assigneslint-plugingenericswhichelbexectrimLeftreduxruntimeimmutabletoolkiturlTypeBoxownsettingsinvariantflattentrimemrUnderscorerm -rfzerogetoptgetintrinsicreact-hookselasticacheBigUint64ArraymochahttparrayslivecurlestreeArray.prototype.filterfastifypasswordeslint
3.6.69

12 months ago

3.6.68

1 year ago

3.6.67

1 year ago

3.6.66

1 year ago

3.6.65

1 year ago

3.6.64

1 year ago

3.6.63

1 year ago

4.7.92

11 months ago

4.7.93

11 months ago

4.7.90

11 months ago

4.7.91

11 months ago

5.8.131

10 months ago

5.8.132

10 months ago

5.8.133

10 months ago

4.7.94

11 months ago

3.6.62

1 year ago

3.6.61

1 year ago

3.6.60

1 year ago

3.4.58

1 year ago

3.2.35

1 year ago

3.2.34

1 year ago

3.6.79

12 months ago

3.2.37

1 year ago

3.6.78

12 months ago

3.2.36

1 year ago

5.8.128

10 months ago

3.6.77

12 months ago

3.2.39

1 year ago

5.8.129

10 months ago

3.6.76

12 months ago

3.2.38

1 year ago

3.6.75

12 months ago

3.6.74

12 months ago

5.8.124

10 months ago

5.8.125

10 months ago

5.8.126

10 months ago

5.8.127

10 months ago

5.8.120

10 months ago

5.8.121

10 months ago

5.8.122

10 months ago

3.4.56

1 year ago

3.2.33

1 year ago

5.8.123

10 months ago

3.4.57

1 year ago

4.7.89

11 months ago

4.7.87

11 months ago

5.8.130

10 months ago

4.7.88

11 months ago

3.6.73

12 months ago

3.6.72

12 months ago

3.6.71

12 months ago

3.6.70

12 months ago

3.1.33

1 year ago

3.3.50

1 year ago

3.3.51

1 year ago

3.3.52

1 year ago

3.3.53

1 year ago

3.1.30

1 year ago

3.3.54

1 year ago

3.3.55

1 year ago

3.1.32

1 year ago

2.1.18

1 year ago

3.3.56

1 year ago

3.1.31

1 year ago

2.1.19

1 year ago

2.1.27

1 year ago

2.1.28

1 year ago

2.1.25

1 year ago

2.1.26

1 year ago

2.1.23

1 year ago

2.1.24

1 year ago

2.1.21

1 year ago

2.1.22

1 year ago

2.1.20

1 year ago

2.1.29

1 year ago

3.5.58

1 year ago

3.7.79

12 months ago

3.5.59

1 year ago

4.8.101

11 months ago

4.8.102

11 months ago

4.8.100

11 months ago

4.8.105

11 months ago

4.8.106

11 months ago

4.8.103

11 months ago

4.8.104

11 months ago

4.8.109

11 months ago

4.8.107

11 months ago

4.8.108

11 months ago

3.3.49

1 year ago

3.7.86

12 months ago

3.1.29

1 year ago

3.7.87

12 months ago

4.8.94

11 months ago

4.8.96

11 months ago

4.8.95

11 months ago

4.8.98

11 months ago

4.8.97

11 months ago

4.8.112

11 months ago

4.8.113

11 months ago

4.8.99

11 months ago

4.8.110

11 months ago

4.8.111

11 months ago

4.8.114

11 months ago

4.8.115

11 months ago

3.7.84

12 months ago

3.7.85

12 months ago

3.5.60

1 year ago

3.7.82

12 months ago

3.7.83

12 months ago

3.7.80

12 months ago

3.7.81

12 months ago

3.2.46

1 year ago

3.2.45

1 year ago

3.2.48

1 year ago

3.2.47

1 year ago

5.8.117

10 months ago

5.8.118

10 months ago

3.2.49

1 year ago

5.8.119

10 months ago

5.8.115

10 months ago

3.2.40

1 year ago

5.8.116

10 months ago

3.2.42

1 year ago

3.2.41

1 year ago

3.2.44

1 year ago

3.2.43

1 year ago

2.1.17

1 year ago

2.1.16

1 year ago

2.1.14

1 year ago

2.1.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.3

1 year ago

2.0.4

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago