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

browser-bookmarks

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-bookmarks - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

__mocks__/.eslintrc

39

__tests__/browsers/chrome.js

@@ -1,5 +0,7 @@

const os = require('os');
const path = require('path');
const chrome = require('../../browsers/chrome');
import os from 'os';
import path from 'path';
import chrome from '../../browsers/chrome';
jest.mock('fs');
describe('retrieve the default directory', () => {

@@ -130,2 +132,19 @@ const homedir = os.homedir();

it('should retrieve local bookmarks', async () => {
const mockData = {
roots: {
bookmarks_bar: {
children: [
{
date_added: 0,
id: 1,
name: 'GitHub',
type: 'url',
url: 'https://github.com',
},
],
},
},
};
// eslint-disable-next-line global-require, no-underscore-dangle
require('fs').__setFileContents(JSON.stringify(mockData));
const dir = path.join(chrome.getDirectory('darwin'));

@@ -135,5 +154,19 @@ const bookmarks = await chrome.extractBookmarks(dir);

expect(bookmarks instanceof Array).toBeTruthy();
expect(bookmarks.length).toBeGreaterThan(0);
});
it('should retrieve no bookmarks', async () => {
const mockData = {};
// eslint-disable-next-line global-require, no-underscore-dangle
require('fs').__setFileContents(JSON.stringify(mockData));
const dir = path.join(chrome.getDirectory('darwin'));
const bookmarks = await chrome.extractBookmarks(dir);
expect(bookmarks).toBeDefined();
expect(bookmarks instanceof Array).toBeTruthy();
expect(bookmarks.length).toBe(0);
});
it('should return nothing for an invalid file', async () => {
// eslint-disable-next-line global-require, no-underscore-dangle
require('fs').__setIsInvalidFile(true);
const dir = 'INVALID_DIR';

@@ -140,0 +173,0 @@ const bookmarks = await chrome.extractBookmarks(dir);

8

browsers/chrome.js

@@ -68,6 +68,6 @@ const fs = require('fs');

*/
const getChildren = children => {
const getChildren = (children) => {
// build the bookmarks list
let bookmarks = [];
children.forEach(child => {
children.forEach((child) => {
// if it's a folder, recursively retrieve it's childs

@@ -93,3 +93,3 @@ if (child.type === 'folder') {

*/
const extractBookmarks = file => new Promise(resolve => {
const extractBookmarks = file => new Promise((resolve) => {
fs.readFile(file, 'utf8', (err, data) => {

@@ -103,3 +103,3 @@ if (err) {

let bookmarks = [];
Object.keys(dataJson.roots).forEach(folder => {
Object.keys(dataJson.roots).forEach((folder) => {
const rootObject = dataJson.roots[folder];

@@ -106,0 +106,0 @@ // retrieve child nodes in each root folder

{
"name": "browser-bookmarks",
"version": "0.1.0",
"version": "0.1.2",
"description": "Retrieve bookmarks from different browsers.",

@@ -19,13 +19,13 @@ "keywords": [

"devDependencies": {
"babel-eslint": "^6.1.2",
"babel-jest": "^15.0.0",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-0": "^6.5.0",
"coveralls": "^2.11.12",
"eslint": "^3.4.0",
"eslint-config-airbnb": "^11.0.0",
"eslint-plugin-import": "^1.14.0",
"jest": "^15.1.1"
"babel-eslint": "^7.0.0",
"babel-jest": "^16.0.0",
"babel-plugin-transform-async-to-generator": "^6.16.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.16.0",
"coveralls": "^2.11.14",
"eslint": "^3.7.1",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^2.0.0",
"jest": "^16.0.1"
}
}
# browser-bookmarks
[![Build Status](https://travis-ci.org/vutran/browser-bookmarks.svg?branch=master)](https://travis-ci.org/vutran/browser-bookmarks) [![Coverage Status](https://coveralls.io/repos/github/vutran/browser-bookmarks/badge.svg?branch=master)](https://coveralls.io/github/vutran/browser-bookmarks?branch=master)
[![Travis](https://img.shields.io/travis/vutran/browser-bookmarks/develop.svg?maxAge=2592000&style=flat-square)](https://travis-ci.org/vutran/browser-bookmarks) [![Coveralls branch](https://img.shields.io/coveralls/vutran/browser-bookmarks/develop.svg?maxAge=2592000&style=flat-square)](https://coveralls.io/github/vutran/browser-bookmarks) [![license](https://img.shields.io/github/license/vutran/browser-bookmarks.svg?maxAge=2592000&style=flat-square)](LICENSE)

@@ -50,4 +50,10 @@ > Retrieve bookmarks from different browsers.

### folder
The folder in which the bookmark item belongs.
Type: `String`
## License
MIT © [Vu Tran](https://github.com/vutran/)

@@ -9,3 +9,3 @@ const url = require('url');

*/
const getFavicon = link => {
const getFavicon = (link) => {
if (link && link.length) {

@@ -12,0 +12,0 @@ const o = url.parse(link);

Sorry, the diff of this file is not supported yet

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