New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fepper-utils

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fepper-utils

Fepper utilities

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Fepper Utilities

If you are creating a Fepper extension:

npm install --save fepper-utils

Then, require in your JavaScript:

const utils = require('fepper-utils');

Functions

extendButNotOverride(obj1, obj2)object

Recursively merge properties of two objects.

regexReservedCharsEscape(regexStr)string

Escape reserved regular expression characters.

shuffle(a)array

Shuffle the elements of an array with the Fisher-Yates algorithm.

backendDirCheck(backendDir)string

Validate existence of a backend subdirectory.

extNormalize(ext)string

Normalize a file extension. Ensure that it is trimmed of extraneous whitespace, contains only valid characters, and is prepended with a dot if it was omitted as the first valid character.

findup(filename, workDir)string

Search the file system from a starting directory upward.

pathResolve()string

Concatenate and normalize path segments, and also ensure that path separators are forward-slashes. Resolution will not occur with the file system, so relative paths will stay relative and wrong paths will stay wrong. Accepts string arguments to be concatenated into a forward-slash separated path.

uiConfigNormalize(uiObj, workDir)object

Normalize UI config values. Turn relative paths into absolute paths. Prepend leading dots to extnames if necessary.

error()

Abstract console.error to not trigger lint warnings/errors. Outputs the error in red text. Accepts the same arguments as console.error.

i(obj, depth, showHidden)

"i" for "inspect". Shorthand for util.inspect or console.dir. This exists primarily for internal debugging. Be sure to remove invocations when done because they won't pass lint.

info()

Abstract console.info to not trigger lint warnings/errors. Outputs the info in green text. Accepts the same arguments as console.info.

log()

Abstract console.log to not trigger lint warnings/errors. Accepts the same arguments as console.log.

warn()

Abstract console.warn to not trigger lint warnings/errors. Outputs the warning in yellow text. Accepts the same arguments as console.warn.

webservedDirnamesTruncate(webservedDirsFull)array

Remove first path segment from values in webservedDirsFull array. Return a new array composed of these new values.

webservedDirsCopy(webservedDirsFull, webservedDirsShort, staticDir)

Copy webserved dirs to static site dir.

extendButNotOverride(obj1, obj2) ⇒ object

Recursively merge properties of two objects.

Kind: global function
Returns: object - The mutated obj1 object.

ParamTypeDescription
obj1objectThis object's properties have priority over obj2.
obj2objectIf obj2 has properties obj1 doesn't, add to obj1, but do not override. Since obj1 gets mutated, the return value is only necessary for the purpose of referencing to a new variable.

regexReservedCharsEscape(regexStr) ⇒ string

Escape reserved regular expression characters.

Kind: global function
Returns: string - A regular expression with escaped reserved characters.

ParamTypeDescription
regexStrstringThe regular expression with unescaped reserved characters.

shuffle(a) ⇒ array

Shuffle the elements of an array with the Fisher-Yates algorithm.

Kind: global function
Returns: array - Shuffled array.
See

ParamTypeDescription
aarrayArray to be shuffled. Since a gets mutated, the return value is only necessary for the purpose of referencing to a new variable.

backendDirCheck(backendDir) ⇒ string

Validate existence of a backend subdirectory.

Kind: global function
Returns: string - A valid absolute path to the backend subdirectory, or an empty string.

ParamTypeDescription
backendDirstringThe relative path to a subdirectory of the backend.

extNormalize(ext) ⇒ string

Normalize a file extension. Ensure that it is trimmed of extraneous whitespace, contains only valid characters, and is prepended with a dot if it was omitted as the first valid character.

Kind: global function
Returns: string - A normalized file extension, or an empty string if it fails validation.

ParamTypeDescription
extstringFile extension.

findup(filename, workDir) ⇒ string

Search the file system from a starting directory upward.

Kind: global function
Returns: string - The absolute path to the found file or an empty string if the search fails.

ParamTypeDescription
filenamestringThe file being searched for.
workDirstringThe absolute path where the search starts.

pathResolve() ⇒ string

Concatenate and normalize path segments, and also ensure that path separators are forward-slashes. Resolution will not occur with the file system, so relative paths will stay relative and wrong paths will stay wrong. Accepts string arguments to be concatenated into a forward-slash separated path.

Kind: global function
Returns: string - Path.

uiConfigNormalize(uiObj, workDir) ⇒ object

Normalize UI config values. Turn relative paths into absolute paths. Prepend leading dots to extnames if necessary.

Kind: global function
Returns: object - The mutated uiObj.

ParamTypeDescription
uiObjobjectThe UI configuration object. Since uiObj gets mutated, the return value is only necessary for the purpose of referencing to a new variable.
workDirstringThe absolute path to the directory directly above the relative paths in the uiObj.

error()

Abstract console.error to not trigger lint warnings/errors. Outputs the error in red text. Accepts the same arguments as console.error.

Kind: global function

i(obj, depth, showHidden)

"i" for "inspect". Shorthand for util.inspect or console.dir. This exists primarily for internal debugging. Be sure to remove invocations when done because they won't pass lint.

Kind: global function

ParamTypeDescription
objobjectThe object to inspect.
depthnull | numberThe number of times to recurse while inspecting the object. null means infinity.
showHiddenbooleanWhether the object's non-enumerable properties will be included in the result.

info()

Abstract console.info to not trigger lint warnings/errors. Outputs the info in green text. Accepts the same arguments as console.info.

Kind: global function

log()

Abstract console.log to not trigger lint warnings/errors. Accepts the same arguments as console.log.

Kind: global function

warn()

Abstract console.warn to not trigger lint warnings/errors. Outputs the warning in yellow text. Accepts the same arguments as console.warn.

Kind: global function

webservedDirnamesTruncate(webservedDirsFull) ⇒ array

Remove first path segment from values in webservedDirsFull array. Return a new array composed of these new values.

Kind: global function
Returns: array - The webserved directories stripped of configuration prefix.

ParamTypeDescription
webservedDirsFullarrayThe array of webserved directories.

webservedDirsCopy(webservedDirsFull, webservedDirsShort, staticDir)

Copy webserved dirs to static site dir.

Kind: global function

ParamTypeDescription
webservedDirsFullarrayPath to directories webserved by Fepper.
webservedDirsShortarrayPath to directories webserved by Fepper truncated for publishing to static site.
staticDirstringThe destination directory.

Keywords

FAQs

Package last updated on 06 Aug 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc