Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
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.
@cobalt-engine/utils
Advanced tools
Readme
Set of useful methods.
Module is a part of core functionality so you don't need to install it.
var utils = require('utils');
mixin(target, source, keys)
Copies properties from source
object to target
object. Returns target object. keys
- array of property names to copy (if not specified - all properties will be copied).
toObject(keys, values)
Creates an object using keys
as property names and values
as property values.
mapToArray(map)
Represents map
as array of its elements. Each element in the array is maps element extended with its id in the map. Example:
var object = {
value1: { number: 3 },
value2: { number: 4 }
};
utils.mapToArray(object); // [{ id: 'value1', number: 3 }, { id: 'value2', number: 4 }]
template(string, data)
string
- templatedata
- data objectInterpolation of string. Example:
utils.template('Hello {name}', { name: 'Ann' }); // 'Hello Ann'
Insert the data from the data
in pattern string.
rangeValue(value, min, max)
If value
is beyond the range [min..max]
the nearest limit will be returned. Example:
utils.rangeValue(10, 2, 5); // 5
utils.rangeValue(0, 2, 5); // 2
utils.rangeValue(3, 2, 5); // 3
dispatchEvent(target, event, options)
target
- element which receives eventevent
- event nameoptions
- object with settings, transferred to constructor CustomEvent
.Options can include a field detail
for transmission of additional information.
load(url, callback, async)
Simple XMLHttpRequest.
To create instance of Observer user Observer
constructor:
var observer = new utils.Observer();
Instance of constructor has the following methods:
subscribe(event, callback)
- adds callback for event. When event publishes Observer
executes callback
unsubscribe(event, callback)
- removes callback
listener for event event
publish(event, data)
- create an event event
and send data
to all listeners of this event.
destroy()
- removes all added subscriptions
FAQs
Useful utils
The npm package @cobalt-engine/utils receives a total of 188 weekly downloads. As such, @cobalt-engine/utils popularity was classified as not popular.
We found that @cobalt-engine/utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
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.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.