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.
@hyperjump/browser
Advanced tools
The Hyperjump browser is an experimental generic hypermedia client. It aims to provide a uniform interface for working with hypermedia enabled media types. When you use a web browser, you don't interact with HTML, you interact with the UI that the HTML represents. The Hyperjump browser aims to do the same except with data. It abstracts away the hypermedia so you can work data as if it's just plain JSON data without having to leave the browser.
The Hyperjump browser allows you to plug in support for different media types, but it comes with support for and was initially designed for JSON Reference (JRef). The Hyperjump browser also has support for JSON, but you won't get support for the interesting things the browser supports.
npm install @hyperjump/browser --save
Run the tests
npm test
Run the tests with a continuous test runner
npm test -- --watch
When using with the Rollup bundler, you will need to include the
browser: true
config option.
plugins: [
resolve({
browser: true
}),
commonjs()
]
The following is short demo. See the API section below to see all of the things you can do.
This example uses the API at https://swapi.hyperjump.io. It's a variation of the Star Wars API (SWAPI) implemented using the JRef media type.
Hyperjump Pact is used to apply standard higher-order functions that work with promises.
const Hyperjump = require("@hyperjump/browser");
const Pact = require("@hyperjump/pact");
const characterHomeworlds = Pact.map(async (character) => {
const name = await character.name;
const homeworld = await character.homeworld.name;
return `${name} is from ${homeworld}`;
});
const ladies = Pact.pipeline([
Pact.filter(async (character) => (await character.gender) === "female"),
Pact.map((character) => character.name)
]);
const mass = Pact.reduce(async (acc, character) => {
return acc + (parseInt(await character.mass, 10) || 0);
}, 0);
(async function () {
const film = Hyperjump.fetch("https://swapi.hyperjump.io/api/films/1");
await film.title; // --> A New Hope
await characterHomeworlds(film.characters); // --> [ 'Luke Skywalker is from Tatooine',
// --> 'C-3PO is from Tatooine',
// --> 'R2-D2 is from Naboo',
// --> ... ]
await ladies(film.characters); // --> [ 'Leia Organa', 'Beru Whitesun lars' ]
await mass(film.characters); // --> 1290
}());
Except for all the promises, this looks exactly like it might if you were working with a normal in-memory data structure.
Document
The nil document. This is like the blank page you see when you first open your browser.
(Url, Document|Promise<Document>, Options?) => Promise<Document>
Retrieve a document with respect to a context document. Options can be passed to set custom headers. If the value of the document is a link, it will be followed.
(Url, Options?) => Hyperjump
Retrieve a document. Options can be passed to set custom headers. If the value of the document is a link, it will be followed.
(Document|any) => any
The value of a document.
(Document) => string
The raw source of a document.
(string, Document|Promise<Document>, Options) => Promise<Document|any>
Step into a document using the key given.
(Url, Headers, string) => Document
Construct a document given a URL, headers, and body. For internal use.
(Document, Object) => Document
Modify or add fields to a document. For internal use.
(string, ContentTypeHandler) => void
Add support for a new content type. The ContentTypeHandler
is an object with
three functions: get
, value
, and step
.
FAQs
Browse JSON-compatible data with hypermedia references
The npm package @hyperjump/browser receives a total of 3,292 weekly downloads. As such, @hyperjump/browser popularity was classified as popular.
We found that @hyperjump/browser demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
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.