# als-fo

> Collection of usefull operations with files.

Latest version **0.5.4** (published 2022-03-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install als-fo
pnpm add als-fo
yarn add als-fo
bun add als-fo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.4 |
| Published | 2022-03-26 |
| First published | 2022-01-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alex Sorkin |
| Maintainers | alexsorkin |

## Links

- npm: https://www.npmjs.com/package/als-fo
- npm.io page: https://npm.io/package/als-fo

## Recent versions

- 0.5.4 (latest) — 2022-03-26
- 0.5.33 — 2022-03-22
- 0.5.32 — 2022-03-22
- 0.5.31 — 2022-03-22
- 0.5.3 — 2022-03-22
- 0.5.2 — 2022-03-21
- 0.5.1 — 2022-03-19
- 0.5.0 — 2022-03-15
- 0.4.3 — 2022-02-10
- 0.4.2 — 2022-02-10
- 0.4.1 — 2022-02-10
- 0.4.0 — 2022-02-08
- 0.3.0 — 2022-02-05
- 0.2.0 — 2022-02-01
- 0.1.0 — 2022-01-31

## README

# als-fo (file operations)

## New in V0.5
* Added delay to fo.watch to prevent runing fn twice on windows
* Fixed ``fo.delete``
* Added ``fo.changeExt``

## New in V0.5.1
* Added ``fo.isFile``

## New in V0.5.3
* Added ``fo.buildFile``
* Fixed filtering by extension in ``getFilesList``


Collection of usefull operations with files. 

```javascript
let fo = require('als-fo)

// If obj can be stringified, returned stringified. 
   fo.isJson(obj)
// Checking if path array and return joined path or return path
   fo.path(path)

// Checking if obj is json and stringify it. Writing the file to path. Path checked by fo.path.
   fo.writeFile(path,obj,encoding = 'utf-8')

// Readigng file, if json return object. Path checked by fo.path.
   fo.readFile(path,encoding = 'utf-8')

// If path exists, return true. Else return false. Path checked by fo.path.
   fo.isExist(path)

// Check if module exists, deleting cache and return required module
   fo.require(path) // if not exists return empty object 

// Checking if folder for path are existen. Creating file with fo.path and fo.isJson
// If where givemt console.log(result)
   fo.createPath(path,content,where='')

// If folder not exists, create it. 
   fo.makeDir(dir)

// Removing dirToRemove, adding host and replace \ to /
   fo.urlFromPath(path,dirToRemove,host)

// Wathing given folder(dir) and runs function(fn) then change occures. fn(event,filename)
   fo.watchDir(dir,fn)

// Runs recursevly and return list of files in given folder(dir) and it's subfolders with given extension (ext).
// If extension not given, return all files in folder and it's subfolders.
// ignore array will include path of files to ignore
   fo.getFilesList(dir,ext,ignore=[],filelist = [])

// if path has this extension return true, else return extension of given path
   fo.ext(path,ext)

// Runs fo.getFilesList and get all files. Then add it to mainList (has to be array)
   fo.addToList(path,mainList)

// Just return time in hh:mm:ss
   fo.now()

// return path creation date
   fo.fileDate(path)
   
// delete the path
   fo.delete(path)

// recursive copy files and foldre from src to dest
   fo.copy(src, dest)

// Checks if path is directory. Retrun true if directory and false if not
   fo.isDir(path)

// Checks if path is file. Retrun true if file and false if not
   fo.isFile(path)

// If cli has 'order' parameter return fn(argv). else return error to console
   fo.cli(order,fn,error)

// return capitalized string
   fo.upperFirst(string)

// Changing extension of file to newExt(without dot). path can be array (fo.path)
   fo.changeExt(path,newExt)
// if srcFilePath is js file: fo.require(srcFilePath). if content is function running function if error, content = ''.
// hooks will include functions with parameters (content,srcFilePath) and has to return content (string)
   fo.buildFile(srcFilePath,hooks=[])
```

---
_Source: https://npm.io/package/als-fo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
