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
2
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.4.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
decreased by-57.78%
Maintainers
2
Weekly downloads
 
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');
const property = utils.deepGet(obj, 'path.to.nested.property');

Functions

t(key)string

Translate using an English key.

beautifyTemplate(extendedTemplate)string

Beautify an HTML-like template. Any Feplet/Mustache code within will be beautified as well.

deepGet(obj, path)* | null

Get data from a nested property within an object.

extendButNotOverride(...objects)object

Recursively merge properties of two or more objects into the first object.

regexReservedCharsEscape(regexStr)string

Escape reserved regular expression characters.

shuffle(a)array

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

strReplaceGlobal(haystack, needle, replacement)string

More efficient global string replace than String.prototype.replace.

backendDirCheck(backendDir)string

Validate existence of a backend subdirectory.

rmRfFilesNotDirs(dirToEmpty)

Recursively empty a directory of files, but not nested directories.

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(...pathSegments)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, [appDir])object

Normalize UI config values. Strip leading dot+slashes and trailing slashes from relative paths and save. Turn relative paths into absolute paths and save. Prepend leading dots to extension nnames if necessary.

error(...args)

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

i(obj, [depth], [showHidden])

"i" for "inspect". Shorthand for util.inspect or console.dir. This exists primarily for internal debugging.

info(...args)

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

log(...args)

Abstract console.log to not trigger lint warnings/errors.

warn(...args)

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

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.

t(key) ⇒ string

Translate using an English key.

Kind: exported function
Returns: string - The phrase in another language (or an English alternative).

ParamTypeDescription
keystringThe phrase in English.

beautifyTemplate(extendedTemplate) ⇒ string

Beautify an HTML-like template. Any Feplet/Mustache code within will be beautified as well.

Kind: exported function
Returns: string - The beautified template code.

ParamTypeDescription
extendedTemplatestringThe string contents of an HTML-like template.

deepGet(obj, path) ⇒ * | null

Get data from a nested property within an object.

Kind: exported function
Returns: * | null - The retrieved data or null on failure.

ParamTypeDescription
objobjectThe object from which to get the data.
pathstring | arrayDot-notation string to the nested property, or array of keys if dot-notation won't work.

extendButNotOverride(...objects) ⇒ object

Recursively merge properties of two or more objects into the first object.

Kind: exported function
Returns: object - The mutated first object.

ParamTypeDescription
...objectsobjectThe objects to get merged. The first object will not have its properties overwritten. It will be extended with additional properties from the additional objects. Since the first object gets mutated, the return value is only necessary for referencing to a new variable.

regexReservedCharsEscape(regexStr) ⇒ string

Escape reserved regular expression characters.

Kind: exported 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: exported 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.

strReplaceGlobal(haystack, needle, replacement) ⇒ string

More efficient global string replace than String.prototype.replace.

Kind: exported function
Returns: string - Modified full string.

ParamTypeDescription
haystackstringFull string to be modified.
needlestringThe substring to be replaced.
replacementstringThe substring to replace needle.

backendDirCheck(backendDir) ⇒ string

Validate existence of a backend subdirectory.

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

ParamTypeDescription
backendDirstringThe path to a subdirectory of the backend.

rmRfFilesNotDirs(dirToEmpty)

Recursively empty a directory of files, but not nested directories.

Kind: exported function

ParamTypeDescription
dirToEmptystringDirectory to empty.

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: exported 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: exported 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(...pathSegments) ⇒ 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: exported function
Returns: string - Path.

ParamTypeDescription
...pathSegmentsstringPath or path segments.

uiConfigNormalize(uiObj, workDir, [appDir]) ⇒ object

Normalize UI config values. Strip leading dot+slashes and trailing slashes from relative paths and save. Turn relative paths into absolute paths and save. Prepend leading dots to extension nnames if necessary.

Kind: exported 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.
[appDir]stringThe absolute path to the fepper-npm directory. Only necessary when Pattern Lab is instantiated without Fepper.

error(...args)

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

Kind: exported function

ParamTypeDescription
...args*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.

Kind: exported function

ParamTypeDefaultDescription
objobjectThe object to inspect.
[depth]null | numbernullNumber of times to recurse while inspecting the object. null means infinity.
[showHidden]booleanfalseWhether the object's non-enumerable properties will be included in the result.

info(...args)

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

Kind: exported function

ParamTypeDescription
...args*Same arguments as console.info.

log(...args)

Abstract console.log to not trigger lint warnings/errors.

Kind: exported function

ParamTypeDescription
...args*Same arguments as console.log.

warn(...args)

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

Kind: exported function

ParamTypeDescription
...args*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.

Kind: exported 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: exported 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 04 Jun 2024

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