lib: use setImmediate when supported