superstrict.lua
--- A module for guarding tables from new indices. Typical use is to guard the global scope.
-- Get the latest version from https://gist.github.com/britzl/546d2a7e32a3d75bab45
-- @module superstrict
-- @usage
--
-- -- Defold specific example. Allow the gameobject and gui script lifecycle functions. Also allow assignment of
-- -- facebook and iap modules for dummy implementations on desktop. The whitelist handles pattern matching and in the
-- -- example all functions prefixed with '__' will also be allowed in the global scope
-- local superstrict = require("superstrict")
-- superstrict.lock(_G, { "go", "gui", "msg", "url", "sys", "render", "factory", "particlefx", "physics", "sound", "sprite", "image", "tilemap", "vmath", "matrix4", "vector3", "vector4", "quat", "hash", "hash_to_hex", "hashmd5", "pprint", "iap", "facebook", "push", "http", "json", "spine", "zlib", "init", "final", "update", "on_input", "on_message", "on_reload", "__*" })
This file has been truncated. show original
superstrict_example.lua
local superstrict = require("superstrict")
superstrict.lock(_G, { "go", "gui", "msg", "url", "sys", "render", "factory", "particlefx", "physics", "sound", "sprite", "image", "tilemap", "vmath", "matrix4", "vector3", "vector4", "quat", "hash", "hash_to_hex", "hashmd5", "pprint", "iap", "facebook", "push", "http", "json", "spine", "zlib", "init", "final", "update", "on_input", "on_message", "on_reload", "__*" })
-- this will be allowed
__allowed = "abc"
-- and this
facebook = dummy_fb
-- this is ok
This file has been truncated. show original