alfy 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +1 -2
  2. package/package.json +1 -1
  3. package/readme.md +46 -1
package/index.js CHANGED
@@ -113,6 +113,7 @@ alfy.cache = new CacheConf({
113
113
 
114
114
  alfy.fetch = async (url, options) => {
115
115
  options = {
116
+ resolveBodyOnly: true,
116
117
  ...options,
117
118
  };
118
119
 
@@ -150,8 +151,6 @@ alfy.fetch = async (url, options) => {
150
151
  options.responseType = 'json';
151
152
  }
152
153
 
153
- options.resolveBodyOnly = true;
154
-
155
154
  let response;
156
155
  try {
157
156
  response = await got(url, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alfy",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Create Alfred workflows with ease",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/alfy",
package/readme.md CHANGED
@@ -366,11 +366,39 @@ Type: `number`
366
366
 
367
367
  Number of milliseconds this request should be cached.
368
368
 
369
+ ###### resolveBodyOnly
370
+
371
+ Type: `boolean`\
372
+ Default: `true`
373
+
374
+ Whether to resolve with only body or a full response.
375
+
376
+ ```js
377
+ import alfy from 'alfy';
378
+
379
+ await alfy.fetch('https://api.foo.com');
380
+ //=> {foo: 'bar'}
381
+
382
+ await alfy.fetch('https://api.foo.com', {
383
+ resolveBodyOnly: false
384
+ });
385
+ /*
386
+ {
387
+ body: {
388
+ foo: 'bar'
389
+ },
390
+ headers: {
391
+ 'content-type': 'application/json'
392
+ }
393
+ }
394
+ */
395
+ ```
396
+
369
397
  ###### transform
370
398
 
371
399
  Type: `Function`
372
400
 
373
- Transform the response before it gets cached.
401
+ Transform the response body before it gets cached.
374
402
 
375
403
  ```js
376
404
  import alfy from 'alfy';
@@ -383,6 +411,20 @@ await alfy.fetch('https://api.foo.com', {
383
411
  })
384
412
  ```
385
413
 
414
+ Transform the response.
415
+
416
+ ```js
417
+ import alfy from 'alfy';
418
+
419
+ await alfy.fetch('https://api.foo.com', {
420
+ resolveBodyOnly: false,
421
+ transform: response => {
422
+ response.body.foo = 'bar';
423
+ return response;
424
+ }
425
+ })
426
+ ```
427
+
386
428
  You can also return a Promise.
387
429
 
388
430
  ```js
@@ -639,6 +681,9 @@ Non-synced local preferences are stored within `Alfred.alfredpreferences` under
639
681
  - [alfred-amphetamine](https://github.com/demartini/alfred-amphetamine) - Start and end sessions quickly in the Amphetamine app
640
682
  - [alfred-ids](https://github.com/rizowski/alfred-ids) - Generate various types of IDs.
641
683
  - [alfred-awesome-stars](https://github.com/jopemachine/alfred-awesome-stars) - Search starred GitHub repos through awesome-stars.
684
+ - [alfred-pwgen](https://github.com/olssonm/alfred-password-generator) - Generate random and secure passwords.
685
+ - [alfred-bear](https://github.com/jmeischner/alfred-bear) - Use dynamic templates with the Bear app.
686
+ - [alfred-color-converter](https://github.com/toFrankie/alfred-color-converter) - Convert colors between RGB and Hex.
642
687
 
643
688
  ## Related
644
689