Permalink
Browse files

the program

  • Loading branch information...
1 parent aa4800c commit f8008c232b937e9536ec2b91fe91a5d65f2b76c1 @isaacs committed Nov 16, 2011
Showing with 38 additions and 0 deletions.
  1. +22 −0 nosync.js
  2. +16 −0 package.json
View
@@ -0,0 +1,22 @@
+var fs = require("fs")
+ , child_process = require("child_process")
+
+process.nextTick(function () {
+ Object.keys(process.binding("natives")).map(function (n) {
+ if (n === "sys") return []
+ var module = require(n)
+ return Object.keys(module).filter(function (f) {
+ return f.match(/Sync$/)
+ }).map(function (f) {
+ return [module, f, n]
+ })
+ }).reduce(function (l, r) {
+ return l.concat(r)
+ }, []).forEach(function (fn) {
+ fn[0][fn[1]] = thrower(fn)
+ })
+})
+
+function thrower (fn) { return function () {
+ throw new Error("Sync function called after first tick: "+fn[2]+"."+fn[1])
+}}
View
@@ -0,0 +1,16 @@
+{
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "name": "nosync",
+ "description": "Prevent *Sync functions from being run after the first tick",
+ "version": "1.0.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/nosync.git"
+ },
+ "main": "nosync.js",
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {},
+ "devDependencies": {}
+}

0 comments on commit f8008c2

Please sign in to comment.