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

alfy

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alfy - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

21

index.js

@@ -10,3 +10,3 @@ 'use strict';

const dotProp = require('dot-prop');
const CacheConf = require('./lib/cache-conf');
const CacheConf = require('cache-conf');

@@ -100,3 +100,3 @@ const alfy = module.exports;

if (process.env.AVA) {
alfy.alfred.data = alfy.alfred.cache = os.tmpdir();
alfy.alfred.data = alfy.alfred.cache = os.tmpdir() + '/' + Date.now();
}

@@ -114,2 +114,6 @@

alfy.fetch = (url, opts) => {
opts = Object.assign({
json: true
}, opts);
if (typeof url !== 'string') {

@@ -119,5 +123,5 @@ return Promise.reject(new TypeError(`Expected \`url\` to be a \`string\`, got \`${typeof url}\``));

opts = Object.assign({
json: true
}, opts);
if (opts.transform && typeof opts.transform !== 'function') {
return Promise.reject(new TypeError(`Expected \`transform\` to be a \`function\`, got \`${typeof opts.transform}\``));
}

@@ -133,8 +137,9 @@ const rawKey = url + JSON.stringify(opts);

return got(url, opts)
.then(res => {
.then(res => opts.transform ? opts.transform(res.body) : res.body)
.then(data => {
if (opts.maxAge) {
alfy.cache.set(key, res.body, {maxAge: opts.maxAge});
alfy.cache.set(key, data, {maxAge: opts.maxAge});
}
return res.body;
return data;
})

@@ -141,0 +146,0 @@ .catch(err => {

{
"name": "alfy",
"version": "0.3.0",
"version": "0.4.0",
"description": "Create Alfred workflows with ease",

@@ -23,4 +23,3 @@ "license": "MIT",

"index.js",
"run-node.sh",
"lib"
"run-node.sh"
],

@@ -40,5 +39,6 @@ "keywords": [

"dependencies": {
"clean-stack": "^0.1.0",
"cache-conf": "^0.2.0",
"clean-stack": "^1.0.0",
"conf": "^0.11.0",
"dot-prop": "^3.0.0",
"dot-prop": "^4.0.0",
"got": "^6.3.0",

@@ -45,0 +45,0 @@ "hook-std": "^0.2.0",

@@ -71,2 +71,39 @@ # ![Alfy](https://cdn.rawgit.com/sindresorhus/alfy/4b50f0323dd99eafdd34523dc8de0680be04e049/media/header.svg)

## Publish to npm
Instead of publishing your packages to [Packal](http://www.packal.org), you can also publish them to [npm](https://npmjs.org). This way, your packages are only one simple `npm install` command away.
Add [alfred-link](https://github.com/samverschueren/alfred-link) as dependency to your package and add it as `postinstall` script.
```json
{
"name": "alfred-unicorn",
"version": "1.0.0",
"description": "My awesome unicorn workflow",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"scripts": {
"postinstall": "alfred-link"
},
"dependencies": {
"alfy": "*",
"alfred-link": "*"
}
}
```
> Tip: Prefix your workflow with `alfred-` to make them easy searchable through npm.
You can remove [these](https://github.com/samverschueren/alfred-link#infoplist) properties from your `info.plist` file as they are being added automatically at install time.
After publishing your workflow to npm, your users can easily install the workflow.
```
$ npm install --global alfred-unicorn
```
## API

@@ -229,2 +266,30 @@

###### transform
Type: `Function`
Transform the response before it gets cached.
```js
alfy.fetch('https://api.foo.com', {
transform: body => {
body.foo = 'bar';
return body;
}
})
```
You can also return a Promise.
```js
const xml2js = require('xmls2js');
const pify = require('pify');
const parseString = pify(xml2js.parseString);
alfy.fetch('https://api.foo.com', {
transform: body => parseString(body)
})
```
#### config

@@ -231,0 +296,0 @@

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