Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-dois

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-dois - npm Package Compare versions

Comparing version 1.0.0-master-466ec3b6ede17eb1d8424c94fc8210b6e837311a to 1.0.0-master-52557781f15ce177e9d2e2f51fdb8740cc23bb61

5

dist/index.test.js

@@ -20,2 +20,7 @@ "use strict";

});
it('should accept partial DOM trees', function () {
var dom = new jsdom_1.JSDOM("<!DOCTYPE html><html><head>\n <meta name=\"dc.identifier\" content=\"doi:10.31219/osf.io/khbvy\">\n </head><p>Hello there</p></html>");
var domTree = dom.window.document.getElementsByTagName('head').item(0);
expect(index_1.getDois(domTree)).toEqual(['10.31219/osf.io/khbvy']);
});
describe('Detecting DOIs located in dc.identifier meta tags', function () {

@@ -22,0 +27,0 @@ it('should not return identifiers that are not DOIs', function () {

@@ -35,2 +35,13 @@ import { JSDOM } from 'jsdom';

it('should accept partial DOM trees', () => {
const dom = new JSDOM(
`<!DOCTYPE html><html><head>
<meta name="dc.identifier" content="doi:10.31219/osf.io/khbvy">
</head><p>Hello there</p></html>`
);
const domTree = dom.window.document.getElementsByTagName('head').item(0)!;
expect(getDois(domTree)).toEqual(['10.31219/osf.io/khbvy']);
});
describe('Detecting DOIs located in dc.identifier meta tags', () => {

@@ -37,0 +48,0 @@ it('should not return identifiers that are not DOIs', () => {

2

package.json
{
"name": "get-dois",
"version": "1.0.0-master-466ec3b6ede17eb1d8424c94fc8210b6e837311a",
"version": "1.0.0-master-52557781f15ce177e9d2e2f51fdb8740cc23bb61",
"description": "Detect Digital Object Identifiers listed in the metadata of a DOM tree",

@@ -5,0 +5,0 @@ "scripts": {

@@ -1,57 +0,39 @@

WDIO Webpack Dev Server Service
get-dois
======
This service starts Webpack Dev Server for you to run [WebdriverIO](https://webdriver.io/) against.
A small module that takes a DOM tree and returns all [Digital Object Identifiers](https://www.doi.org/) (DOIs) located in that tree's metadata.
Unfortunately, academic publishers use a wide variety of metadata "standards". This package normalises between Dublin Core, Highwire Press tags, etc., and the different formatting rules used for DOIs.
To use this library outside of a browser context, you can use a library like [jsdom](https://www.npmjs.com/package/jsdom).
This project also includes TypeScript type definitions.
## Installation
```bash
npm install wdio-webpack-dev-server-service --save-dev
npm install get-dois --save
```
## Configuration
## Usage
This assumes you have:
```javascript
import { getDois } from 'get-dois';
- [set up WebdriverIO](https://webdriver.io/guide.html).
- [set up Webpack Dev Server](https://github.com/webpack/webpack-dev-server) - the example will use `webpack.dev.config.js` as the configuration file.
**Note:** If you need support for Webpack 2 or 3, use `wdio-webpack-dev-server-service@1.2.0`. If you need support for webpack-serve, use `wdio-webpack-dev-server-service@2.2.0`.
Add the Webpack Dev Server service to your WebdriverIO services list:
```js
// wdio.conf.js
export.config = {
// ...
services: ['webpack-dev-server'],
// ...
};
const head = document.getElementsByTagName('head').item(0);
const dois = getDois(head);
//=> [ '10.31222/osf.io/796tu' ]
```
Options are set directly on your WebdriverIO config as well, e.g.
## API
```js
// wdio.conf.js
export.config = {
// ...
webpackConfig: require('webpack.dev.config.js'),
webpackPort: 8080,
// ...
};
```
### `getDois(domTree: Document | Element): string[]`
## Options
#### Parameter: `domTree`
Either `window.document` or an HTML element whose children might include meta tags containing a DOI.
### `webpackConfig`
Type: `String` | `Function` | `Object`
#### Returns
An array of DOIs. If no DOIs are found, this will return an empty array. Duplicate DOIs will only be listed once. Note that a page might list multiple DOIs.
Default: `webpack.config.js`
## License
Either the absolute path to your Webpack configuration, or (a function generating) your actual Webpack configuration.
### `webpackPort`
Type: Number
Default: `8080`
The port the Dev Server should be run on. You'll want to set this same port in the `baseUrl` option of your WebdriverIO configuration.
MIT © [Vincent Tunru](https://vincenttunru.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc