Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Split examples in readme

  • Loading branch information...
commit 5912c908f0fa3ab5e5c8af73297e2fc28bc7f37c 1 parent 8aabfab
@eldargab authored
Showing with 19 additions and 6 deletions.
  1. +19 −6 README.md
View
25 README.md
@@ -8,36 +8,49 @@ future.
``` javascript
var fs = require('fake-fs')
+```
+
+Define a dir
-// define a dir
+``` javascript
+// note that it works like mkdir -p
fs.dir('a/b/c')
-// it works like mkdir -p
fs.existsSync('a').should.be.true
fs.existsSync('a/b/c').should.be.true
+```
+
+Dir with some meta
-// specify some meta
+``` javascript
fs.dir('bin', {
mtime: 100,
atime: 300,
ctime: 50
})
+fs.statSync('bin').should.have.property('mtime').equal(100)
+```
+Define an empty file
-// define an empty file
+``` javascript
fs.file('foo/bar.txt')
fs.readFileSync('foo/bar.txt', 'utf8').should.equal('')
fs.statSync('foo').isDirectory().should.be.true // foo automatically created
+```
+Define a file with content
-// define a file with content
+``` javascript
fs.file('hello.txt', 'Hello world') // utf8 assumed
fs.file('base64.txt', 'TWFu', 'base64')
fs.file('bin', new Buffer([10, 20]))
+```
+Define a file with arbitrary attributes
-// define a file with arbitrary attributes
+``` javascript
fs.file('file', {
content: 'asdf',
mtime: new Date,
Please sign in to comment.
Something went wrong with that request. Please try again.