
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@plasma-platform/helpers
Advanced tools
Full documentation
install:
npm i @plasma-platform/helpers -S
Function for convert locale bd format (pt or etc) to app format (pt-br or etc)
locale
stringimport { convertToAppFormat } from '@plasma-platform/helpers/lib/locales';
// or
import convertToAppFormat from '@plasma-platform/helpers/lib/locales/convertToAppFormat';
const locale = convertToAppFormat(uk);
// locale === 'ua'
Returns string
Function for convert locale app format (pt-br or etc) to db format (pt or etc)
locale
stringimport { convertToDBFormat } from '@plasma-platform/helpers/lib/locales';
// or
import convertToDBFormat from '@plasma-platform/helpers/lib/locales/convertToDBFormat';
const locale = convertToDBFormat(ua);
// locale === 'uk'
Returns string
Function for get current locale form location or from cookie
location
Objectimport { getCurrent } from '@plasma-platform/helpers/lib/locales';
// or
import getCurrent from '@plasma-platform/helpers/lib/locales/getCurrent';
const locale = getCurrent(location);
// locale === { label: 'uk', value: 'ua' }
Returns object { label: 'uk', value: 'ua' }
Function for get locale for url
locale
stringimport { getLocaleForUrl } from '@plasma-platform/helpers/lib/locales';
// or
import getLocaleForUrl from '@plasma-platform/helpers/lib/locales/getLocaleForUrl';
const locale = getLocaleForUrl('ua');
// locale === '/en'
Returns string /uk
Cookie API
getItem
sKey
string (required) key to get cookieconst locale = Cookie.getItem('country_code');
Returns string cookie value
getItem
sKey
string (required) for set cookiesValue
string (required) value for set cookievEnd
string date to endsPath
string cookie pathsDomain
string cookie domainbSecure
boolean is securesSameSite
string SameSiteconst locale = Cookie.setItem('country_code', 'ua');
Returns boolean result
getItem
const locale = Cookie.removeItem('country_code');
Returns boolean result
getItem
sKey
string (required) key for check cookieconst locale = Cookie.hasItem('country_code');
Returns boolean result
Create and dispatch custom event with optional 'detail' parameter
name
string Event namedetail
any? Additional data (read only)dispatchCustomEvent('eventName', { data: 'myData' })
Returns boolean
Get element by selector
selector
stringReturns any
Get all elements by selector
selector
stringReturns any
Get data attributes
element
Returns {}
Add class
element
classList
(optional, default []
)Returns any
Attributes
element
key
value
Returns any
Remove class
element
classList
Returns any
Has class
element
className
Returns boolean
Remove Attribute
element
name
Returns any
parses html string to child node
htmlString
stringReturns ChildNode
inserts element as first child of its parent
parent
element
Returns (null | any)
inserts element as last child of its parent
parent
element
Returns (null | any)
Appends timer to html page
Utility for interacting with cookies in isomorphic way
switchToServerMode
IsomorphicCookie.switchToServerMode(req, res);
getItem
sKey
string (required) key to get cookieconst locale = IsomorphicCookie.getItem('country_code');
Returns string cookie value
setItem
sKey
string (required) for set cookiecookieValue
(string | object) (required) value for set cookievEnd
string date to endsPath
string cookie pathsDomain
string cookie domainbSecure
boolean is secureIsomorphicCookie.setItem('country_code', 'ua', 36000000, '/', '.templatemonster.me', false);
removeItem
sKey
string (required) key remove cookiesPath
string (required) cookie pathsDomain
string (required) cookie domainIsomorphicCookie.removeItem('country_code', '/', '.templatemonster.com);
Client-side utility for cookies
getItem
sKey
string (required) key to get cookieconst locale = ClientCookie.getItem('country_code');
Returns string cookie value
setItem
sKey
string (required) for set cookiesValue
string (required) value for set cookievEnd
string date to endsPath
string cookie pathsDomain
string cookie domainbSecure
boolean is secure
*ClientCookie.setItem('country_code', 'ua', 36000000, '/', '.templatemonster.me', false);
removeItem
sKey
string (required) key remove cookiesPath
string (required) cookie pathsDomain
string (required) cookie domainClientCookie.removeItem('country_code', '/', '.templatemonster.com);
Creates server-side utility for cookies
oReq
object (required) request object from ExpressoRes
object (required) response object from ExpressgetItem
sKey
string (required) key to get cookieconst locale = IsomorphicCookie.getItem('country_code');
Returns string cookie value
setItem
sKey
string (required) for set cookiesValue
string (required) value for set cookievEnd
string date to endsPath
string cookie pathsDomain
string cookie domainbSecure
boolean is secureServerCookie.setItem('country_code', 'ua', 36000000, '/', '.templatemonster.me', false);
removeItem
sKey
string (required) key remove cookiesPath
string (required) cookie pathsDomain
string (required) cookie domainServerCookie.removeItem('country_code', '/', '.templatemonster.com);
Observer lib
Get observers
name
string (required) Event nameconst observer = new Observer();
const observers = observer.getObservers('click');
Returns Array<function> Array of callback functions or empty array
Subscribe for event and pass callback function to be called
const observer = new Observer();
observer.subscribe('click');
Returns function Callback function
Unsubscribe from event
const observer = new Observer();
observer.subscribe('click');
observer.unsubscribe('click');
Broadcast event
name
string (required) Event namedata
any? Data to be passed as argument to callback functionconst observer = new Observer();
observer.subscribe('click');
observer.broadcast('click', 'Hello!');
FAQs
helpers functions for storefront project
The npm package @plasma-platform/helpers receives a total of 7 weekly downloads. As such, @plasma-platform/helpers popularity was classified as not popular.
We found that @plasma-platform/helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.