
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
RDF Prefix helper to expand and compact iri (compatible with json-ld context)
RDF Prefix helper to expand and compact iri (compatible with json-ld context)
npm install --save rdfprefix
var rdfprefix = require('rdfprefix')
// Basic initialization
var prefixes = rdfprefix()
// Initialize with prefixes
var prefixes = rdfprefix({schema: 'http://schema.org'})
// Initialize with an array of prefixes
var prefixes = rdfprefix([
{owl: 'http://www.w3.org/2002/07/owl#'},
{schema: 'http://schema.org/'}
])
// Supports Json-ld @context
var prefixes = rdfprefix({
'@vocab': 'http://purl.org/dc/terms/',
'schema': 'http://schema.org/',
'displayName': 'schema:name',
'alias': {
'@id': 'schema:alternateName',
'@container': '@set'
},
'schema:sameAs': {
'@type': 'schema:URL',
'@container': '@set'
}
})
// Add prefixes...
prefixes('owl', 'http://www.w3.org/2002/07/owl#')
prefixes({
'cc': 'http://creativecommons.org/ns#',
'rdfs': 'http://www.w3.org/2000/01/rdf-schema#',
'Class': 'rdfs:Class'
})
// Use prefixes
var schema = prefixes('schema')
schema('name') // -> 'http://schema.org/name'
// Expand prefixed iri
prefixes.expand('schema:name') // -> 'http://schema.org/name'
prefixes.expand('abstract') // -> 'http://purl.org/dc/terms/abstract' (see '@vocab')
prefixes.expand('http://www.exemple.org/play') // -> 'http://www.exemple.org/play'
prefixes.expand('undefinedprefix:foo') // -> throw Error()
prefixes.expand('undefinedprefix:foo', true) // -> 'undefinedprefix:foo' (tolerant = true)
// Compact iri
prefix.compact('http://schema.org/name') // -> 'schema:name'
prefix.compact('http://purl.org/dc/terms/abstract') // -> 'abstract' (see '@vocab')
prefix.compact('http://www.exemple.org/play') // -> 'http://www.exemple.org/play'
// Get a serializable copy of prefixes
prefix.toJSON() // -> { schema: 'http://schema.org/', ... } (without '@vocab')
// Like toJSON but with the '@vocab' prefix if any
prefix.toContext() // -> { '@vocab': 'http://purl.org/dc/terms/abstract', schema: ... }
Statements | 100% ( 76/76 ) |
Branches | 100% ( 52/52 ) |
Functions | 100% ( 14/14 ) |
Lines | 100% ( 76/76 ) |
FAQs
RDF Prefix helper to expand and compact iri (compatible with json-ld context)
We found that rdfprefix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.