From 51082bf78b887129cd2be503789952574d79689c Mon Sep 17 00:00:00 2001 From: what Date: Fri, 9 Aug 2024 17:48:20 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20toPrimitive=20null=20=E8=BD=AC=E5=85=B6?= =?UTF-8?q?=E5=AE=83=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/lodash.mixin.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/lodash.mixin.js b/lib/lodash.mixin.js index bc763a1..6ad608b 100755 --- a/lib/lodash.mixin.js +++ b/lib/lodash.mixin.js @@ -1,17 +1,11 @@ const convertFns = { - null2json: (data) => null, - null2array: (data) => null, - null2number: (data) => null, - null2bool: (data) => null, - null2string: (data) => null, - null2integer: (data) => null, - null2float: (data) => null, - - // null2json: (data) => ({}), - // null2array: (data) => ([]), - // null2number: (data) => 0, - // null2bool: (data) => false, - // null2string: (data) => '', + null2json: (data) => Object.create(), + null2array: (data) => [], + null2number: (data) => 0, + null2bool: (data) => false, + null2string: (data) => '', + null2integer: (data) => 0, + null2float: (data) => 0, string2json: (data) => data ? JSON.parse(data) : '{}', string2array: (data) => data.substr(0, 1) === '[' && data.substr(-1) === ']' ? JSON.parse(data) : data.split(','),