Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
fstk
Advanced tools
Readme
fstk is a Node.js module for extending Node's FS module with various utility methods, without relying on child processes (i.e. bash).
Install the module with: npm install fstk
var fstk = require('fstk');
All methods accept optional options object and callback as last two arguments (order doesn't matter). If options are not supplied, defaults are used. If callback is not supplied, noop is used.
path
's base filename with extension removedpath
's current extension (if any) with extension
path
's type based on extension (right now either video
, audio
, or image
). Mime type list is located in ./resources/mimes.json
path
path
. Includes automatic evaluation of Node's isFile, isDirectory, ... methods. Includes automatic mime lookup, path normalization, and check for symbolic link. Pass options.fast_stat
to skip these enhancements.path
's existence and passes true
or false
to callbackpath
, performing transformer
on all file paths found. transformer
is passed a path and a callback to include an error (if it occurs) as first element and and transformed path as second argument. Uses async.mapSeries
.stat
on path
and it's top-level contents, passing an error (if applicable) and an object to callback
containing path
's stat and path.files
with an array of stat objects for contents.path
and its subdirectories, passing to callback
an error (if applicable) and an object representing a tree-like structure of path
's deep contents.path
into arrays of directories
and files
. Passes to callback
an error (if applicable) and the flattened arrays of path
's contents (regardless of specific sub-level).path
, moving all files to the top level and deleting the now empty subdirectories. Name collisions will cause deeper paths to be overwritten with shallower paths with the same filename.path
, leaving the now empty subdirectories in their original structure.fs.writeFile
but also creates any parent directories that do not exist, similar to bash's mkdir -p
path
's data, passes it to transformer
, which passes an error (if it occurs) and the transformed contents of path
which are then used to overwrite path
. Pass options.destination
to write the transformed data somewhere other than path
data
(gzip) and write the compressed version to path
, include options.encoding
to use encoding other than utf8
path
, decompressing it, and passing the resulting buffer to callback
with an error (if it occured)obj
and write it to path
path
and pass results to callback
as an object
path
, setting property update
to value
, or calling update
with JSON set as this
mkdir -p
, makes any missing parent paths for path
before making path
rm -rf path
, removes empty and non-empty directories, while also deleting any of their contentsrm -rf
, removes path
even if it is a directory (empty or non-empty)options.serializer(data, cb)
and options.deserializer(data, cb)
provides asynchronous methods used to serialize data (when persisting to disk) and deserialize data (when loading from disk). callback
is passed an object
to callback
with the following methods and properties:
FS.fileWatcher
instancecallback
. If a disk read is in progress, callback is blocked until read is completeddata
and persists to disk, calling callback
when completepStr
) of file data to value
and persists all data to disk, calling callback
when completefiles
, an object of watched fileswatchFile
with JSON serializers and deserializers to keep a JSON file actively updated in memory as an object
files
, an object of watched JSON filesurl
to a temporary file. Pass options.dest_path
to specify a destination path. callback
is passed an error
and path
for the newly created filepath
to url
. Pass options.method
as post
or put
to change request type. Pass options.form_field
to specify a form field to post file contents to. Pass options.form_data
to include other form data in the request.Copyright (c) 2014 Ben Sack Licensed under the MIT license.
FAQs
Additions to Node's FS module, a toolkit for filesystem usage
The npm package fstk receives a total of 38 weekly downloads. As such, fstk popularity was classified as not popular.
We found that fstk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.