Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@podium/utils
Advanced tools
Common generic utility methods shared by @podium modules.
$ npm install @podium/utils
This module has the following API:
Checks if a value is a string.
The method takes the following arguments:
*
- A value to check. Required.Returns a boolean.
Checks if a value is a function.
The method takes the following arguments:
*
- A value to check. Required.Returns a boolean.
Constructs an pathname from all arguments. Returned pathname will always end without
a /
and if the first argument starts with a /
it will be preserved.
const utils = require('@podium/utils');
const foo = 'foo/a/';
const bar = '/bar/b/';
const xyz = '/xyz/';
const pathname = utils.pathnameBuilder(foo, bar, xyz);
console.log(pathname); // outputs: foo/a/bar/b/xyz
Constructs an absolute URI out of a absolute manifest URI and a relative URI.
The method takes the following arguments:
String
- Relative URI. Required.String
- Absolute manifest URI to append the input too. Required.String
- Relative path to be appended at the end of the URI. Optional.Returns a resolved URI.
const utils = require('@podium/utils');
const manifest = 'http://foo.site.com/bar/manifest.json';
const content = '/here/is/content.html';
const url = utils.uriBuilder(content, manifest);
console.log(url); // outputs: http://foo.site.com/bar/here/is/content.html
Checks if a URI is relative
The method takes the following arguments:
String
- The URI to check. Required.Returns a Boolean.
const utils = require('@podium/utils');
utils.uriIsRelative('http://foo.site.com/bar/'); // false
utils.uriIsRelative('/bar/'); // true
Check if a URI is absolute or relative and if relative compose an absolute URI out of a absolute mainfest URI.
The method takes the following arguments:
String
- Relative or absolute URI. Required.String
- Absolute manifest URI to append the possible relative input too. Required.String
- Relative path to be appended at the end of the URI. Optional.Returns a resolved URI.
const utils = require('@podium/utils');
const manifest = 'http://foo.site.com/bar/manifest.json';
const content = 'http://foo.site.com/here/is/content.html';
const url = utils.uriRelativeToAbsolute(content, manifest);
console.log(url); // outputs: http://foo.site.com/here/is/content.html
Set a value on a property on .locals.podium on a http response object. Ensures that .locals.podium exists on the http response object.
If property is not provided, .locals.podium will be created, if not already existing, on the response object.
The method takes the following arguments:
Object
- A http response object.String
- Property for the value.String
- Value to store on the property.The http response object.
const obj = utils.setAtLocalsPodium({}, 'foo', 'bar');
/*
obj is now:
{
locals: {
podium: {
foo: 'bar',
},
},
}
*/
Get the value from a property on .locals.podium on a http response object Ensures that .locals.podium exists on the http response object.
Object
- A http response objectString
- Property for the valuereturns The property, or null
if it does not exist
Get the value from a property on .locals.podium on a http response object and sets its value on another key.
Object
- A http response objectString
- Property for the existent valueString
- Property for the duplicated value@returns {Object} The http response object
Serialize a context object into a http header object.
The method takes the following arguments:
Object
- A http headers object the context will be copied into.Object
- A contect object to copy from*
- An argument value passed on to the function if a context value is a function.A http header object.
const context = {
'podium-foo': 'bar',
'podium-bar': 'foo',
};
let headers = {
test: 'xyz',
};
headers = utils.serializeContext(headers, context);
/*
headers is now:
{
'podium-foo': 'bar',
'podium-bar': 'foo',
test: 'xyz',
}
*/
Deserialize a context object from a http header object
The method takes the following arguments:
Object
- A http headers object the context will be extracted from.String
- The prefix used to mark what properties are context propertiesA object containing context properties and values
const headers = {
bar: 'foo',
'podium-foo': 'bar podium',
};
const context = utils.deserializeContext(headers);
// context is: { foo: 'bar podium' }
Shared template function for use in layout and podlet
This method takes a single argument:
Object
- An object with template variables as key/value pairsdata
can contain any of the following keys:
data.title
- document titledata.locale
- language tag/locale identifier defaults to en-US
data.encoding
- defaults to utf-8
data.head
- Any additional HTML markup that should be placed in the document <head>
data.js
- JavaScript URL, will be used as a src
value in a script tagdata.css
- CSS URL, will be used as an href
value in a link tagdata.body
- HTML body markup to be renderedFAQs
Common generic utility methods shared by @podium modules.
The npm package @podium/utils receives a total of 0 weekly downloads. As such, @podium/utils popularity was classified as not popular.
We found that @podium/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.