Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit b8c041710dbcfc7611882b5de266086edf56d55b 0 parents
@TooTallNate authored
3  .gitignore
@@ -0,0 +1,3 @@
+node_modules
+npm-debug.log
+build
13 LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2012, Nathan Rajlich <nathan@tootallnate.net>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
46 README.md
@@ -0,0 +1,46 @@
+node-function-name
+==================
+### Set the "name" property of `Function` objects
+
+Very simple module. Sets the, usually immutable, `name` property of `Function`
+objects. This functionality is exposed internally to V8, but not exposed to
+JavaScript, so this native module is required.
+
+Note that unfortunately _only_ String values are allowed.
+
+Installation
+------------
+
+Install with `npm`:
+
+``` bash
+$ npm install function-name
+```
+
+
+Example
+-------
+
+``` js
+var set = require('function-name');
+
+function test () {
+}
+
+console.log(test.name);
+// "test"
+
+// change the "name" property to 'foo'
+set(test, 'foo');
+
+console.log(test.name);
+// "foo"
+
+// spaces are allowed, and even usually illegal UTF8 chars
+set(test, '');
+
+console.log(test.name);
+// " ☃ "
+```
+
+That's it!
8 binding.gyp
@@ -0,0 +1,8 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'binding',
+ 'sources': [ 'src/binding.cc' ]
+ }
+ ]
+}
2  index.js
@@ -0,0 +1,2 @@
+module.exports = require('bindings')('binding').set;
+module.exports(module.exports, 'set function name');
22 package.json
@@ -0,0 +1,22 @@
+{
+ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
+ "name": "function-name",
+ "description": "Set the \"name\" property of `function` objects",
+ "keywords": [
+ "function",
+ "set",
+ "name"
+ ],
+ "version": "0.0.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/TooTallNate/node-function-name.git"
+ },
+ "main": "index.js",
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {
+ "bindings": "*"
+ }
+}
24 src/binding.cc
@@ -0,0 +1,24 @@
+#include "v8.h"
+#include "node.h"
+
+using namespace v8;
+using namespace node;
+
+namespace {
+
+Handle<Value> Set(const Arguments& args) {
+ HandleScope scope;
+ Local<Function> fn = Local<Function>::Cast(args[0]);
+ Local<String> name = args[1]->ToString();
+ fn->SetName(name);
+ return Undefined();
+}
+
+void Initialize(Handle<Object> target) {
+ HandleScope scope;
+ NODE_SET_METHOD(target, "set", Set);
+}
+
+} // anonymous namespace
+
+NODE_MODULE(binding, Initialize);
Please sign in to comment.
Something went wrong with that request. Please try again.