Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove b2a dependency #7

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/relay-pagination.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/**
* Encodes a string.
*
* @callback encode
* @param {string} str
* @returns {string}
*/
import { btoa } from "b2a";
const ENCODE =
typeof btoa !== "undefined"
? btoa
: typeof Buffer !== "undefined"
? (str) => Buffer.from(str).toString("base64")
: (str) => str;

const RELAY_ARGS = ["after", "before", "first", "last"];

Expand Down Expand Up @@ -42,7 +40,7 @@ function hasField(type, fieldName) {
* @see {@link https://relay.dev/graphql/connections.htm#sec-Edge-Types}
* @returns {Object[]} A list of Relay connection edges mapped from the records.
*/
export function getEdges(records, args, typeName, encode = btoa) {
export function getEdges(records, args, typeName, encode = ENCODE) {
const { after, before, first, last } = args;
const afterIndex = getIndexOfRecord(records, after, typeName, encode);
const beforeIndex = getIndexOfRecord(records, before, typeName, encode);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"test": "jest"
},
"dependencies": {
"b2a": "^1.1.2",
"graphql": "^15.0.0",
"miragejs": "^0.1.0"
},
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1326,11 +1326,6 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2"
integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==

b2a@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/b2a/-/b2a-1.1.2.tgz#3bb0a7dbc0931c84ac97722fa4f5f51ba0a7d831"
integrity sha512-Ee7SUAyWeIx4ICRygOi7dVlGpHRxynsaLIZwOtHtGKls3LhLchTRk5KrI0O8ioWqy94ikkE8Z2Li3LWNd027/A==

babel-eslint@^10.0.2:
version "10.1.0"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.1.0.tgz#6968e568a910b78fb3779cdd8b6ac2f479943232"
Expand Down