@coderich/graphql-shape
Advanced tools
Comparing version 2.2.0 to 2.2.1
{ | ||
"name": "@coderich/graphql-shape", | ||
"main": "src/GraphQLShape.js", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"publishConfig": { | ||
@@ -6,0 +6,0 @@ "access": "public" |
@@ -51,5 +51,5 @@ const get = require('lodash.get'); | ||
exports.pairs = Util.pairs; | ||
exports.pushIt = Util.push; | ||
exports.flatten = Util.flatten; | ||
exports.unflatten = Util.unflatten; | ||
exports.default = (v, ...args) => Util.ensureArray(v).concat(args.flat()).find(el => el != null); | ||
@@ -56,0 +56,0 @@ // Pick keys (with optional rename) |
@@ -120,3 +120,3 @@ const Util = require('@coderich/util'); | ||
// We assign data here because it's possible to modify the root/data itself (key: '') | ||
// We assign data here because it's possible to modify the root/data itself (via key: '') | ||
data = Util.pathmap(key, data, (value, info) => { | ||
@@ -183,3 +183,3 @@ const vars = [value]; | ||
return data; // For convenience (and testing) | ||
return data; | ||
} | ||
@@ -197,13 +197,21 @@ | ||
args = GraphQLShape.#resolveVariableArgs(vars, args.flat()); | ||
const firstUserArg = args.shift(); | ||
// Core functions have a special syntax | ||
if (core[fn]) { | ||
const method = args.shift(); | ||
if (method === 'new') return new core[fn](value, ...args); | ||
if (method === null) return core[fn](value, ...args); | ||
return core[fn][method](value, ...args); | ||
if (firstUserArg === 'new') return new core[fn](value, ...args); | ||
if (firstUserArg === null) return core[fn](value, ...args); | ||
return core[fn][firstUserArg](value, ...args); | ||
} | ||
if (functions[fn]) return functions[fn](value, ...args); | ||
if (value?.[fn]) return value[fn](...args); | ||
if (functions[fn]) { | ||
if (firstUserArg === null) return functions[fn](value, ...args); | ||
return functions[fn](value, firstUserArg, ...args); | ||
} | ||
if (typeof value?.[fn] === 'function') { | ||
if (firstUserArg === null) return value[fn](...args); | ||
return value[fn](firstUserArg, ...args); | ||
} | ||
return value; | ||
@@ -210,0 +218,0 @@ } |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
16546
5
276
1
140