Skip to content

Commit

Permalink
feat: write README and expose functions (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xstoudi authored Mar 22, 2021
1 parent e3cbdbc commit d558e3d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

.
Small utility to check if a file is ready to be worked with.

## Installation

Expand All @@ -14,19 +14,46 @@
## Usage

```js
import { myModule } from 'is-my-file-ready';

const result = myModule(args);
// result is ...
import isMyFileReady, { sameSize, endsWithStr } from 'is-my-file-ready';

const expectedSize = 4242;
const expectedEnds = 'sit amet.';

const result = await isMyFileReady('./myfile.txt', [
sameSize(expectedSize),
endsWithStr(expectedEnds),
]);
if (!result.isReady) {
result.checks
.filter((check) => !check.isReady)
.forEach((check) => {
let toPrint = '';
toPrint += `${check.name} failed. `;
switch (check.name) {
case 'sameSize':
toPrint += `Expected "${expectedSize}", got "${check.size}."`;
break;
case 'endsWithStr':
toPrint += `Expected "${expectedEnds}", got "${check.endsWith}."`;
break;
}
console.log(toPrint);
});
} else {
console.log('File is ready !');
}
```

## Documentation
See [https://zakodium.github.io/is-my-file-ready](https://zakodium.github.io/is-my-file-ready)

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/is-my-file-ready.svg
[npm-url]: https://www.npmjs.com/package/is-my-file-ready
[ci-image]: https://github.com/zakodium/is-my-file-ready/workflows/Node.js%20CI/badge.svg?branch=master
[ci-image]: https://github.com/zakodium/is-my-file-ready/workflows/Node.js%20CI/badge.svg?branch=main
[ci-url]: https://github.com/zakodium/is-my-file-ready/actions?query=workflow%3A%22Node.js+CI%22
[codecov-image]: https://img.shields.io/codecov/c/github/zakodium/is-my-file-ready.svg
[codecov-url]: https://codecov.io/gh/zakodium/is-my-file-ready
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "is-my-file-ready",
"version": "0.0.0",
"description": "",
"description": "Small utility to check if a file is ready to be worked with.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"keywords": [],
Expand Down
6 changes: 6 additions & 0 deletions src/checks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { editTime } from './editTime';
import { endsWithBytes } from './endsWithBytes';
import { endsWithStr } from './endsWithStr';
import { sameSize } from './sameSize';

export { editTime, endsWithBytes, endsWithStr, sameSize };
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export default async function isMyFileReady(
}

export * from './types';
export * from './checks';

0 comments on commit d558e3d

Please sign in to comment.