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

tiny-updater

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-updater - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

3

dist/utils.d.ts
declare const Utils: {
getExitSignal: () => any;
fetch: (url: string) => any;
getExitSignal: () => import("aborter/dist/signal").default;
getLatestVersion: (name: string) => Promise<string | undefined>;

@@ -4,0 +5,0 @@ isUpdateAvailable: (current: string, latest: string) => boolean;

@@ -9,3 +9,3 @@ "use strict";

const colorette_1 = require("colorette");
const node_fetch_1 = __importDefault(require("node-fetch"));
const simple_get_1 = __importDefault(require("simple-get"));
const semver_compare_1 = __importDefault(require("semver-compare"));

@@ -16,12 +16,21 @@ const signal_exit_1 = __importDefault(require("signal-exit"));

/* API */
fetch: (url) => {
return new Promise((resolve, reject) => {
const signal = Utils.getExitSignal();
const request = simple_get_1.default.concat(url, (error, response, data) => {
if (error)
return reject(error);
return resolve(JSON.parse(data.toString()));
});
signal.addEventListener('abort', request.abort.bind(request));
});
},
getExitSignal: () => {
const aborter = new aborter_1.default();
signal_exit_1.default(() => aborter.abort());
return aborter.signal; //TSC: Not techincally 100% compliant with AbortSignal, but good enough for node-fetch
return aborter.signal;
},
getLatestVersion: async (name) => {
const latestUrl = `http://registry.npmjs.org/${name}/latest`;
const signal = Utils.getExitSignal();
const response = await node_fetch_1.default(latestUrl, { signal });
const latest = await response.json();
const latest = await Utils.fetch(latestUrl);
return latest.version;

@@ -28,0 +37,0 @@ },

{
"name": "tiny-updater",
"description": "The smallest update notifier for NPM packages, useful for CLI apps.",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/index.js",

@@ -38,8 +38,8 @@ "types": "dist/index.d.ts",

"colorette": "^1.2.2",
"node-fetch": "^2.6.1",
"semver-compare": "^1.0.0",
"signal-exit": "^3.0.3"
"signal-exit": "^3.0.3",
"simple-get": "^4.0.0"
},
"devDependencies": {
"@types/node-fetch": "^2.5.10",
"@types/node": "^16.11.7",
"@types/semver-compare": "^1.0.1",

@@ -46,0 +46,0 @@ "@types/signal-exit": "^3.0.0",

@@ -6,3 +6,3 @@

import {cyan, gray, green} from 'colorette';
import fetch from 'node-fetch';
import get from 'simple-get';
import compare from 'semver-compare';

@@ -17,6 +17,17 @@ import onExit from 'signal-exit';

fetch: ( url: string ): any => {
return new Promise ( ( resolve, reject ) => {
const signal = Utils.getExitSignal ();
const request = get.concat ( url, ( error, response, data ) => {
if ( error ) return reject ( error );
return resolve ( JSON.parse ( data.toString () ) );
});
signal.addEventListener ( 'abort', request.abort.bind ( request ) );
});
},
getExitSignal: () => {
const aborter = new Aborter ();
onExit ( () => aborter.abort () );
return aborter.signal as any; //TSC: Not techincally 100% compliant with AbortSignal, but good enough for node-fetch
return aborter.signal;
},

@@ -26,5 +37,3 @@

const latestUrl = `http://registry.npmjs.org/${name}/latest`;
const signal = Utils.getExitSignal ();
const response = await fetch ( latestUrl, {signal} );
const latest = await response.json ();
const latest = await Utils.fetch ( latestUrl );
return latest.version;

@@ -31,0 +40,0 @@ },

/* IMPORT */
const updater = require ( '../dist' );
const {default: updater} = require ( '../dist' );

@@ -6,0 +6,0 @@ /* MAIN */

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