https://github.com/charto/cfile
Gulp-style file container without dependencies for servers and browsers
https://github.com/charto/cfile
Last synced: 11 months ago
JSON representation
Gulp-style file container without dependencies for servers and browsers
- Host: GitHub
- URL: https://github.com/charto/cfile
- Owner: charto
- License: mit
- Created: 2016-03-17T22:23:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-24T01:09:43.000Z (about 10 years ago)
- Last Synced: 2025-04-03T07:39:47.857Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cfile
=====
[](http://travis-ci.org/charto/cfile)
[](https://www.npmjs.com/package/cfile)
This is an experimental container similar to [vinyl](https://github.com/gulpjs/vinyl)
as used in [Gulp.js](http://gulpjs.com/), but without depending on Node.js libraries.
It's intended for more general use besides build tools.
For example, a web server or browser can transform data on the fly.
Differences from `vinyl`:
- No external dependencies.
- Can contain data types relevant to browsers: `XMLHttpRequest` result, `Uint8Array` and `string` (in addition to Node.js `ReadableStream` and `Buffer`).
- Locations are URI instead of paths. Files can represent remotely fetched content stored in memory or cached content under an abstract URN key (in addition to local `file://` paths).
- Files optionally point to other related files, such as source maps.
- Written in [TypeScript](http://www.typescriptlang.org/).
API
===
>
>
> ### [`Address`](#api-Address)
> Simple absolute URI container and resolver.
> > **new( )** ⇒ [Address](#api-Address)
> > ▪ uri string
> > ▪ base [Address](#api-Address)
> > **.resolve( )** ⇒ [Address](#api-Address)
> > Resolve another URI relative to this address.
> > ▪ uri string
> > **.format( )** ⇒ string
> > Convert to URI string.
> > **protocol** string
> > Protocol including trailing colon, eg. http: or urn:
> > **partList** string[]
> > URL split by slashes without query or hash, or URN split by colons.
> > **paramList** string[]
> > Query parameters in the form a=b.
>
>
> ### [`File`](#api-File)
> Represents a remote or local file and its contents (stream or buffer).
> > **new( )** ⇒ [File](#api-File)
> > ▪ uri string | [Address](#api-Address)
> > **baseAddress** [Address](#api-Address)
> > Where the file thinks it is, and the base of any relative paths inside it.
> > **address** [Address](#api-Address)
> > Current guess of file location. Changes until all possible redirects
are resolved (possibly to a file in disk cache).
> > **history** [Address](#api-Address)[]
> > List of earlier addresses such as resolved HTTP redirects.
> > **related** RelatedFiles
> > Related files, such as a source map.
> > **contents** FileContents
> > String, Uint8Array, XMLHttpRequest, HTTP headers, Node.js stream and/or buffer.
License
=======
[The MIT License](https://raw.githubusercontent.com/charto/cfile/master/LICENSE)
Copyright (c) 2016 BusFaster Ltd