Skip to content

Commit

Permalink
Typings. (#19)
Browse files Browse the repository at this point in the history
* Create tslint.json

* Fixed typos, added typings.

* Fixed all JSDocs
  • Loading branch information
kyraNET authored and bdistin committed Sep 22, 2017
1 parent bbd733f commit 6ae25b2
Show file tree
Hide file tree
Showing 12 changed files with 417 additions and 123 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "0.3.0",
"description": "Node.js V8 native fs enhanced with util.promisify and standard extra methods.",
"main": "src/index.js",
"types": "typings/index.d.ts",
"scripts": {
"test": "npm run lint & npm run ava",
"docs": "npx jsdoc -c ./.docstrap.json -R README.md",
"lint": "npx eslint src test",
"lint": "npx eslint src test && npx tslint --fix 'typings/*.ts'",
"ava": "npx ava \"test/test.js\" -T 10000"
},
"keywords": [
Expand Down
176 changes: 88 additions & 88 deletions src/fs.js

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions src/nextra/copyFileAtomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ const { copyFile } = require('../fs');

const move = require('./move');

/**
* @typedef writeOptions
* @memberof fsn/nextra
* @property {string} [encoding = 'utf8'] The file encoding
* @property {integer} [mode = 0o666] The chmod
* @property {string} [flag = 'w'] The flag
*/

/**
* @function copyFileAtomic
* @memberof fsn/nextra
* @param {string} source The path to the file you want to copy
* @param {string} destination The path to the file destination
* @param {writeOptions|string} [options] The write options or the encoding string.
* @return {type} {description}
* @return {Promise<void>} {description}
*/
module.exports = async function copyFileAtomic(source, destination, options) {
const tempPath = tempFile();
Expand Down
9 changes: 0 additions & 9 deletions src/nextra/createFileCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ const copyFileAtomic = require('./copyFileAtomic');
const mkdirs = require('./mkdirs');
const pathExists = require('./pathExists');

/**
* Creates an empty file, making all folders required to satisfy the given file path.
* @function ensureFile
* @memberof fsn/nextra
* @param {string} file Path of the file you want to create
* @param {boolean} [atomic = false] Whether the operation should run atomicly
* @return {Promise<void>}
*/

/**
* Creates an empty file, making all folders required to satisfy the given file path.
* @function createFileCopy
Expand Down
9 changes: 0 additions & 9 deletions src/nextra/createFileCopyAtomic.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
const createFileCopy = require('./createFileCopy');

/**
* Creates an empty file, making all folders required to satisfy the given file path.
* @function ensureFile
* @memberof fsn/nextra
* @param {string} file Path of the file you want to create
* @param {boolean} [atomic = false] Whether the operation should run atomicly
* @return {Promise<void>}
*/

/**
* Creates an empty file, making all folders required to satisfy the given file path.
* @function createFileCopyAtomic
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/pathExists.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { access } = require('../fs');
* Checks if a path exists.
* @function pathExists
* @memberof fsn/nextra
* @param {type} path The path to check
* @param {string} path The path to check
* @return {Promise<boolean>}
*/
module.exports = function pathExists(path) {
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/readJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { readFile } = require('../fs');
* @typedef {object} readJSONOptions
* @memberof fsn/nextra
* @property {string} [encoding] The file encoding to use while reading
* @property {type} [reviver] The reviver function to pass to JSON.parse()
* @property {Function} [reviver] The reviver function to pass to JSON.parse()
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const util = require('../util');
/**
* @typedef {object} removeOptions
* @memberof fsn/nextra
* @property {integer} [maxBusyTries = 3] The number of times fs-nextra should retry removing a busy file.
* @property {number} [maxBusyTries = 3] The number of times fs-nextra should retry removing a busy file.
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/nextra/writeFileAtomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const move = require('./move');
* @typedef writeOptions
* @memberof fsn/nextra
* @property {string} [encoding = 'utf8'] The file encoding
* @property {integer} [mode = 0o666] The chmod
* @property {number} [mode = 0o666] The chmod
* @property {string} [flag = 'w'] The flag
*/

Expand All @@ -17,7 +17,7 @@ const move = require('./move');
* @param {string} file The path to the file you want to create
* @param {string|Buffer|Uint8Array} data The data to write to file
* @param {writeOptions|string} [options] The write options or the encoding string.
* @return {type} {description}
* @return {Promise<void>}
*/
module.exports = async function writeFileAtomic(file, data, options) {
const tempPath = tempFile();
Expand Down
4 changes: 2 additions & 2 deletions src/nextra/writeJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const writeFileAtomic = require('./writeFileAtomic');
* @typedef {Object} jsonOptions
* @memberof fsn/nextra
* @property {Function} [replacer] A JSON.stringify replacer function
* @property {integer} [spaces = null] The number of spaces to format the json file with
* @property {number} [spaces = null] The number of spaces to format the json file with
* @property {string} [encoding = 'utf8'] The file encoding
* @property {integer} [mode = 0o666] The chmod
* @property {number} [mode = 0o666] The chmod
* @property {string} [flag = 'w'] The flag
*/

Expand Down
60 changes: 60 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"rules": {
"no-inferrable-types": [false],
"no-unused-expression": true,
"no-duplicate-variable": true,
"no-shadowed-variable": true,
"comment-format": [
true, "check-space"
],
"indent": [
true, "tabs"
],
"curly": false,
"class-name": true,
"semicolon": [true],
"triple-equals": true,
"eofline": true,
"no-bitwise": false,
"no-console": [false],
"member-access": [true, "check-accessor", "check-constructor"],
"no-consecutive-blank-lines": [true],
"no-parameter-properties": true,
"one-line": [
false
],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"],
"interface-name": [true, "always-prefix"],
"no-conditional-assignment": true,
"use-isnan": true,
"no-trailing-whitespace": true,
"quotemark": [true, "single", "avoid-escape"],
"no-use-before-declare": false,
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type",
"check-typecast"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
}
}
Loading

0 comments on commit 6ae25b2

Please sign in to comment.