Permalink
Browse files

util, feat: support util._extend.

  • Loading branch information...
xicilion committed Sep 25, 2017
1 parent f97d881 commit d93ca533c7292d6b75bb2b930304cf92973f3307
Showing with 33 additions and 0 deletions.
  1. +19 −0 fibjs/include/ifs/util.h
  2. +6 −0 fibjs/src/util/util.cpp
  3. +8 −0 idl/zh-cn/util.idl
View
@@ -59,6 +59,7 @@ class util_base : public object_base {
static result_t values(v8::Local<v8::Value> v, v8::Local<v8::Array>& retVal);
static result_t clone(v8::Local<v8::Value> v, v8::Local<v8::Value>& retVal);
static result_t extend(v8::Local<v8::Value> v, OptArgs objs, v8::Local<v8::Value>& retVal);
static result_t _extend(v8::Local<v8::Value> v, OptArgs objs, v8::Local<v8::Value>& retVal);
static result_t pick(v8::Local<v8::Value> v, OptArgs objs, v8::Local<v8::Object>& retVal);
static result_t omit(v8::Local<v8::Value> v, OptArgs keys, v8::Local<v8::Object>& retVal);
static result_t first(v8::Local<v8::Value> v, v8::Local<v8::Value>& retVal);
@@ -123,6 +124,7 @@ class util_base : public object_base {
static void s_values(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_clone(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_extend(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s__extend(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_pick(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_omit(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_first(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -183,6 +185,7 @@ inline ClassInfo& util_base::class_info()
{ "values", s_values, true },
{ "clone", s_clone, true },
{ "extend", s_extend, true },
{ "_extend", s__extend, true },
{ "pick", s_pick, true },
{ "omit", s_omit, true },
{ "first", s_first, true },
@@ -719,6 +722,22 @@ inline void util_base::s_extend(const v8::FunctionCallbackInfo<v8::Value>& args)
METHOD_RETURN();
}
inline void util_base::s__extend(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Local<v8::Value> vr;
METHOD_ENTER();
METHOD_OVER(-1, 1);
ARG(v8::Local<v8::Value>, 0);
ARG_LIST(1);
hr = _extend(v0, v1, vr);
METHOD_RETURN();
}
inline void util_base::s_pick(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Local<v8::Object> vr;
View
@@ -162,6 +162,12 @@ result_t util_base::extend(v8::Local<v8::Value> v, OptArgs objs,
return 0;
}
result_t util_base::_extend(v8::Local<v8::Value> v, OptArgs objs,
v8::Local<v8::Value>& retVal)
{
return extend(v, objs, retVal);
}
result_t util_base::pick(v8::Local<v8::Value> v, OptArgs objs,
v8::Local<v8::Object>& retVal)
{
View
@@ -243,6 +243,14 @@ module util
*/
static Value extend(Value v, ...objs);
/*! @brief 将一个或者多个对象的键值扩展到指定对象,是 extend 的别名
@param v 指定要扩展的对象
@param objs 指定一个或者多个用于扩展的对象
@return 返回扩展的结果
*/
static Value _extend(Value v, ...objs);
/*! @brief 返回一个object副本,只过滤出指定键的属性值
@param v 指定要过滤的对象

0 comments on commit d93ca53

Please sign in to comment.