Fix replacement of numbers 0 and 1 in permutations

In permutations the code replaces boolean
values with their javascript string counterparts.
This fix prevents replacing 0 and 1 (typeof int)
as they are interpreted as boolean values if not
explicietly checked.
More efficient way of value checking
Merge pull request #1 from sebastian-software/fix/boolean-handling-in-permutation

Fix replacement of numbers 0 and 1 in permutations