Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
metarhia-common
Advanced tools
Namespace: api.common
in Impress Application Server
$ npm install metasync
common.splitAt(index, array)
index:number
- index defining end of first part and start of secondarray:array
- to be splittedReturns: tuple with two parts of the array
common.isScalar(value)
value
- scalar value or ObjectReturns: boolean
common.copy(ds)
ds:array of objects
- source datasetReturns: array of objects
common.clone(obj)
obj:object or array
Returns: object or array
common.duplucate(obj)
obj:object or array
Returns: object or array
common.getByPath(data, dataPath)
data:hash
dataPath:string
- dot-separated pathReturns: value
common.setByPath(data, dataPath, value)
data:hash
dataPath:string
- dot-separated pathvalue
- new valuecommon.deleteByPath(data, dataPath)
data:object
dataPath:string
- dot-separated pathReturns: boolean
common.merge(...args)
args:array of array
Returns: array
common.subst(tpl, data, dataPath, escapeHtml)
tpl:string
- template bodydata:hash
- data structure to visualizedataPath:string
- current position in data structureescapeHtml:boolean
- escape html special characters if trueReturns: string
common.htmlEscape(content)
content:string
- to escapeReturns: string
Example: htmlEscape('5>=5') = '5<=5'
common.fileExt(fileName, Result)
fileName:string
- file nameReturns: string
Example: fileExt('/dir/file.txt')
Result: 'txt'
common.removeExt(fileName, Result)
fileName:string
- file nameReturns: string
Example: fileExt('file.txt')
Result: 'file'
common.spinalToCamel(name)
name:string
Returns: string
common.escapeRegExp(s)
s:string
Returns: string
Example: escapeRegExp('/path/to/res?search=this.that')`
common.newEscapedRegExp(s)
s:string
Returns: RegExp, instance
common.addTrailingSlash(s)
s:string
Returns: string
common.stripTrailingSlash(s)
s:string
Returns: string
common.dirname(filePath)
filePath:string
Returns: string
common.capitalize(s)
s:string
common.between(s, prefix, suffix)
s:string
- sourceprefix:string
- before needed fragmentsuffix:string
- after needed fragmentReturns: string
common.removeBOM(s)
s:string
- possibly starts with BOMReturns: string
common.arrayRegExp(items)
items:array of string
Returns: RegExp, instance
Example: ['/css/*', '/index.html']
common.isTimeEqual(time1, time2)
time1:string
- time or millisecondstime2:string
- time or millisecondsReturns: boolean
Example: isTimeEqual(sinceTime, buffer.stats.mtime);
common.nowDate(now)
now:Date
(optional)Returns: string
common.nowDateTime(now)
now:Date
(optional)Returns: string
common.partial(fn, ...args)
fn:function
...args:array
- argumantsReturns: function
common.omap(mapFn, obj)
mapFn:funtion
- to appy to every field valueobj:object
- which fields used for mappingReturns: object, with same reference but with transformed fields
common.compose(...fns)
fns:array of function
Returns: function, composed
common.maybe(fn, defVal, value)
fn:function
defVal
- default valuevalue
(optional)Returns: result of fn
or defVal
common.zip(...arrays)
arrays
- array of arrayReturns: array, length is minimal of input arrays length
Hint: Element with index i of resulting array is array with elements with index i from input arrays
common.replicate(count, elem)
count:number
- new array lengthelem
- value to replicateReturns: array, replicated
common.zipWith(fn, ...arrays)
fn:function
- for zipping elements with index iarrays:array of array
Returns: array
Hint: Element with index i of resulting array is result of fn called with arguments from arrays
common.curryUntil(condition, fn, ...args)
condition:function
- (argsI, argsParts) returns booleanfn:function
- which will be curriedargs:array
- arguments for fnReturns: function, curried
common.curryN(fn, count, ...args)
fn:function
- curriedcount:number
- of times function should be curriedargs:array
- arguments for first curryingReturns: function, curried given times count
common.curryTwice(fn)
fn:function
- to be curriedReturns: function, to pass arguments that returns curried fn
common.curry(fn, ...args)
fn:function
args:array
- argumentsReturns: function, curried
common.applyArgs(...args)
args:array
- arguments to save in closureReturns: function, to pass (fn) arguments will be applied
common.either(fn)
fn:function
- to be calledReturns: result of fn
common.falseness()
Returns: boolean, always false
common.trueness()
Returns: boolean, always true
common.emptiness()
Returns: always undefined
common.nop(callback)
callback:function
- callback to be called with (null)common.noop(empty, callback)
empty
- incoming value to be ignoredcallback:function
- callback to be called with (null, null)common.once(fn)
fn:function (optional)
Returns: function, wrapped callback
Hint: previous name: common.cb
(deprecated)
It's unsafe: may return null, allow multiple calls
common.unsafeCallback(args)
args:array
- argumentsReturns: function, callback or null
Hint: previous name: common.cbUnsafe
(deprecated)
Hint: another alias: common.extractCallback
(deprecated)
Wrap collback with once and return common.emptiness if no callback
common.safeCallback(args)
args:array
- argumentsReturns: function, wrapped callback
Hint: previous name: cbExtract
(deprecated)
common.requiredCallback(args)
args:array
- argumentsReturns: function
common.onceCallback(args)
Wrap collback with once()
and return common.emptiness if no callback
args:array
- argumentsReturns: function
fn.inherited
common.override(obj, fn, Hint)
obj:object
- containing method to overridefn:function
- name will be used to find methodHint: Previous function will be accessible by obj.fnName.inherited
common.range(from, to)
from:naumber
- range startto:naumber
- range endReturns: array
Example: range(1, 5) = [1, 2, 3, 4, 5]
common.sequence(seq, max, list, range from..to, range from..count, range from..max-to)
seq:array
max:number
- optional maxReturns: array
Example:
common.last(arr)
arr:array
Returns: element
common.safe(fn)
fn:function
Returns: function, wrapped with try/catch interception
common.random(min, max)
min:number
- range startmax:number
- range endReturns: number
common.shuffle(arr)
arr:array
Returns: array
common.emitter()
Returns: EventEmitter, instance
common.restLeft(fn)
fn:function
- (args, arg1..argN, callback)Returns: function, (arg1..argN, ...args, callback)
common.duration(s)
s:string
- duration syntaxReturns: number, milliseconds
Example: duration('1d 10h 7m 13s')
common.bytesToSize(bytes)
bytes:number
- sizeReturns: string
common.sizeToBytes(size)
size:string
- sizeReturns: number
common.ip2int(ip)
ip:string
- IP addressReturns: number
common.localIPs()
Returns: srray of strings
common.parseHost(host)
host:string
- host or empty string, may contain :port
Returns: string, host without port but not empty
(i.e., not longer than a machine word) in-place and return the remainder
common.longDivModBE(buffer, divisor)
buffer:Buffer
- containing a dividentdivisor:a divisor as a Number
Returns: number, the remainder
common.generateKey(length, possible)
length:number
- key lengthpossible:string
- with possible charactersReturns: string, key
common.generateGUID()
Returns: string, GUID
common.generateSID(config)
config:record
- { length, characters, secret }Returns: string, SID
common.crcSID(config, key)
config:record
- { length, characters, secret }key:string
- SID keyReturns: string, CRC
common.validateSID(config, sid)
config:record
- { length, characters, secret }sid:string
- session idReturns: boolean
common.hash(password, salt)
password:string
salt:string
Returns: string, hash
common.validateHash(hash, password, salt)
hash:string
password:string
salt:string
Returns: boolean
common.sortComparePriority(priority, s1, s2)
priority:array of strings with priority
s1, s2:string
- to compareReturns: number
Example: files.sort(common.sortComparePriority)
common.sortCompareDirectories(a, b)
a, b:string
- to compareReturns: number
Example: files.sort(sortCompareDirectories);
common.sortCompareByName(a, b)
a, b:object
- { name } to compareReturns: number
Example: files.sort(sortCompareByName)
common.cache()
Returns: object, cache instance
cache.allocated
- total allocated sizecache.add(key, val)
- add recordcache.del(key)
- delete recordcache.clr(prefix, fn)
- delete all if key.startsWith(prefix)
common.section(s, separator)
s:string
separator:string
- or charReturns: ['All you need ', ' JavaScript']
Example: rsection('All you need is JavaScript', 'is')
common.rsection(s, separator)
s:string
separator:string
- or charReturns: ['All you need is Jav', 'Script']
Example: rsection('All you need is JavaScript', 'a')
common.split(s, separator, limit)
s:string
separator:string (optional)
- default: ','limit:number (optional)
- max length of result arrayExample: split('a,b,c,d')
Result: ['a', 'b', 'c', 'd']
Example: split('a,b,c,d', ',', 2)
Result: ['a', 'b']
common.rsplit(s, separator, limit)
s:string
separator:string (optional)
- default: ','limit:number (optional)
- max length of result arrayExample: split('a,b,c,d', ',', 2)
Result: ['c', 'd']
common.rsplit(s, separator, limit)
s:string
separator:string (optional)
- default: ','limit:number (optional)
- max length of result arrayExample: split('a,b,c,d', ',', 2)
Result: ['c', 'd']
common.mixin(target, source)
target
- mixin to targetsource
- source methodscommon.forwardEvents(from, to, events)
from:EventEmitter
- to listen for eventto:EventEmitter
- to emit event onevents:array of string
- event namesExample: common.forwardEvent(from, to);
Example: common.forwardEvent(from, to, 'eventName');
Example: common.forwardEvent(from, to, { eventName: 'newEventName' });
Example: common.forwardEvent(from, to, ['eventName1', 'eventName2']);
common.methods(iface)
iface:object
- to be introspectedReturns: array of string, method names
common.properties(iface)
iface:object
- to be introspectedReturns: array of string, property names
common.generateStorageKey()
Returns: Array of string, [folder1, folder2, code]
FAQs
Metarhia Common Library
The npm package metarhia-common receives a total of 4 weekly downloads. As such, metarhia-common popularity was classified as not popular.
We found that metarhia-common 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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.