Add prelude function for URL Query (#4135)

* Update string.ts

* Refactor

* Update string.ts

* Update wrap-url.ts

* Update string.ts

* Update get-static-image-url.ts

* Use querystring.stringify

* Update outbox.ts

* Back to the urlQuery

* Update followers.ts

* Update following.ts

* Update outbox.ts

* Update string.ts

* Update get-static-image-url.ts

* Update string.ts

* Update string.ts

* Separate prelude files
This commit is contained in:
Acid Chicken (硫酸鶏) 2019-02-13 23:45:35 +09:00 committed by GitHub
parent 3548290ff2
commit 4b6c113251
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 14 deletions

7
src/prelude/url.ts Normal file
View file

@ -0,0 +1,7 @@
import { stringify } from 'querystring';
export function query(obj: {}): string {
return stringify(Object.entries(obj)
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>));
}