node extensions should use stringification instead of verification.

Some of the node.js extensions uses type verification like following code:

if (args.Length() <= 0 || !args[0]->IsString()) {
  return ThrowException(Exception::TypeError(String::New("Gahh")));
}

String::Utf8Value VAR(args[0]->ToString());

It's not good.

It's not allows String object.

func(new String("cho45"));

You should use just ToString without type verification.

if (args.Length() <= 0) {
  return ThrowException(Exception::TypeError(String::New("Gahh")));
}

String::Utf8Value VAR(args[0]->ToString());

Thanks to kazuhooku.

Published: 2012-09-02(Sun) 01:16