An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

cfile
=====

[![build status](https://travis-ci.org/charto/cfile.svg?branch=master)](http://travis-ci.org/charto/cfile)
[![npm version](https://img.shields.io/npm/v/cfile.svg)](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