Skip to content

Commit

Permalink
Feature: Add web docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nick spragg committed Feb 13, 2017
1 parent 71fd6be commit 6bacd86
Show file tree
Hide file tree
Showing 94 changed files with 34,669 additions and 245 deletions.
246 changes: 1 addition & 245 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,251 +57,7 @@ if (file.isDirectorySync()) {
}
```

#### Type checking

```js
const pathname = File.create('myFile');
if (pathname.isFile()) {
console.log(`process ${pathname}`)
}
```

#### List files for a directory

Synchronously list files:
```js
const dir = File.create('myDirectory');
const files = dir.getListSync()

console.log(files.forEach(console.log));
```

Asynchronously list files:
```js
const dir = File.create('myDirectory');
dir.getList().each(console.log);
```

#### File locking

Perform operations on a file whilst locked:
```js
const fs = require('fs');
const file = File.create('myFile');

file.withLock(() => {
file.isWritable((w_ok) => {
if (w_ok) {
fs.writeFileSync(file.getAbsolutePath(), 'my data\n');
}
});
});
```
#### Check permissions

Check that a pathname has write permission:
```js
const file = File.create('myFile');
file.isWritable((isWritable) => {
if (isWritable) {
console.log(`Able to write to ${file.getName()}`);
}
});
```

Check that a pathname is executable:
```js
const file = File.create('myFile');
file.isExecutable((isExecutable) => {
if (isExecutable) {
console.log(`Able to execute ${file.getName()}`);
}
});
```

#### Pathname changes and access

Get the last time a pathname was modified:
```js
const file = File.create('myFile');
const lastModified = file.lastModifiedSync();

console.log(`${file.getName()} was last modified on ${lastModified}`);
```

Get the last time a pathname was accessed:
```js
const file = File.create('myFile');
const lastAccessed = file.lastAccessedSync();

console.log(`${file.getName()} was last accessed on ${lastAccessed}`);
```

#### File size

Check a file is less than 1k:

```js
const file = File.create('myFile');
if (file.sizeSync() < 1024) {
console.log(`${file.getName()} < 1k`);
}
```

#### Supports callbacks

Get list of files for a directory:

```js
const dir = File.create('myDir');
dir.getList((err, files) => {
if (err) return console.error(err);

console.log(files);
});
```

## API

### Static methods

### `File.create() -> File`

##### Parameters - None

##### Returns
Returns a File instance.

## Instance methods

### `.getList() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is an array of files in the directory or null if it's a file

### `.getListSync() -> Promise`
Synchronous version of `.getList()`

### `.isDirectory() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is a boolean indicating if the pathname is a directory

### `.isDirectorySync() -> Promise`
Synchronous version of `.isDirectory()`

### `.isFile() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is a boolean indicating if the pathname is a file

### `.isFileSync() -> Promise`
Synchronous version of `.isFile()`

### `.isHidden() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is a boolean indicating if the pathname is hidden

### `.isHiddenSync() -> Promise`
Synchronous version of `.isHidden()`

### `.isMatch(globPattern) -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is a boolean indicating if the pathname matches `globPattern`

### `.isMatchSync() -> Promise`
Synchronous version of `.isMatch()`

### `.lastAccessed() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is a datetime when the file was last accessed

### `.lastAccessedSync() -> Promise`
Synchronous version of `.lastAccessed()`

### `.lastModified() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is a datetime when the file was last modified

### `.lastModifiedSync() -> Promise`
Synchronous version of `.lastModified()`

### `.size() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is is the size of the file in bytes

### `.sizeSync() -> Promise`
Synchronous version of `.size()`

### `.isWritable() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is true is the file has write permissions

### `.isWritableSync() -> Promise`
Synchronous version of `.isWritable()`

### `.isReadable() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is true is the file has read permissions

### `.isReadableSync() -> Promise`
Synchronous version of `.isReadable()`

### `.isExecutable() -> Promise`

##### Parameters
* None

##### Returns
* If the Promise fulfils, the fulfilment value is true is the file is executable

### `.isExecutableSync() -> Promise`
Synchronous version of `.isExecutable()`

### `.getName() -> String`

##### Parameters
* None

##### Returns
* pathname as a string associated with the object
## Documentation

## Test

Expand Down
20 changes: 20 additions & 0 deletions docconfig/jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc"]
},
"source": {
"include": [ "./src" ]
},
"plugins": ["plugins/markdown"],
"opts": {
"readme": "docs.md",
"template": "docconfig/template",
"encoding": "utf8",
"destination": "./docs",
"recurse": true
},
"templates": {
"cleverLinks": false
}
}
61 changes: 61 additions & 0 deletions docconfig/template/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# License

Minami is free software, licensed under the Apache License, Version 2.0 (the
"License"). Commercial and non-commercial use are permitted in compliance with
the License.

Copyright (c) 2014-2015 Nijiko Yonskai <nijikokun@gmail.com> and the
[contributors to Minami](https://github.com/Nijikokun/minami/graphs/contributors).
All rights reserved.

You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0

In addition, a copy of the License is included with this distribution.

As stated in Section 7, "Disclaimer of Warranty," of the License:

> Licensor provides the Work (and each Contributor provides its Contributions)
> on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
> express or implied, including, without limitation, any warranties or
> conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
> PARTICULAR PURPOSE. You are solely responsible for determining the
> appropriateness of using or redistributing the Work and assume any risks
> associated with Your exercise of permissions under this License.

The source code for JSDoc 3 is available at:
https://github.com/Nijikokun/minami

# Third-Party Software

Minami includes or depends upon the following third-party software, either in
whole or in part. Each third-party software package is provided under its own
license.

## JSDoc 3

JSDoc 3 is free software, licensed under the Apache License, Version 2.0 (the
"License"). Commercial and non-commercial use are permitted in compliance with
the License.

Copyright (c) 2011-2015 Michael Mathews <micmath@gmail.com> and the
[contributors to JSDoc](https://github.com/jsdoc3/jsdoc/graphs/contributors).
All rights reserved.

You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0

In addition, a copy of the License is included with this distribution.

As stated in Section 7, "Disclaimer of Warranty," of the License:

> Licensor provides the Work (and each Contributor provides its Contributions)
> on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
> express or implied, including, without limitation, any warranties or
> conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
> PARTICULAR PURPOSE. You are solely responsible for determining the
> appropriateness of using or redistributing the Work and assume any risks
> associated with Your exercise of permissions under this License.

The source code for JSDoc 3 is available at:
https://github.com/jsdoc3/jsdoc
Loading

0 comments on commit 6bacd86

Please sign in to comment.