Skip to content

Commit b7ebd6b

Browse files
committed
minor improvements
1 parent 1d29a1e commit b7ebd6b

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

hjson.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local encoder = require "hjson.encoder"
44
local encoderH = require "hjson.encoderH"
55

66
local function decode(str, strict, object_hook, object_pairs_hook)
7-
local _decoder = decoder:new(strict, object_hook, object_pairs_hoo)
7+
local _decoder = decoder:new(strict, object_hook, object_pairs_hook)
88
return _decoder:decode(str)
99
end
1010

hjson/encoderH.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ local escape_char_map = {
1212

1313
local COMMONRANGE = "\x7f-\x9f" -- // TODO: add unicode escape sequences
1414

15-
function containsSequences(s, sequences)
15+
local function containsSequences(s, sequences)
1616
for _, v in ipairs(sequences) do
1717
if s:find(v) then
1818
return true
@@ -21,11 +21,11 @@ function containsSequences(s, sequences)
2121
return false
2222
end
2323

24-
function needsEscape(s)
24+
local function needsEscape(s)
2525
return containsSequences(s, {'[\\"\x00-\x1f' .. COMMONRANGE .. "]"})
2626
end
2727

28-
function needsQuotes(s)
28+
local function needsQuotes(s)
2929
local sequences = {
3030
"^%s",
3131
'^"',
@@ -45,17 +45,17 @@ function needsQuotes(s)
4545
return containsSequences(s, sequences)
4646
end
4747

48-
function needsEscapeML(s)
48+
local function needsEscapeML(s)
4949
local sequences = {"'''", "^[\\s]+$", "[\x00-\x08\x0b\x0c\x0e-\x1f" .. COMMONRANGE .. "]"}
5050
return containsSequences(s, sequences)
5151
end
5252

53-
function needsEscapeName(s)
53+
local function needsEscapeName(s)
5454
local sequences = {'[,{%[}%]%s:#"\']', "//", "/%*", "'''"}
5555
return containsSequences(s, sequences) or needsQuotes(s)
5656
end
5757

58-
function startsWithNumber(s)
58+
local function startsWithNumber(s)
5959
local integer = s:match("^[\t ]*(-?[1-9]%d*)") or s:match("^[\t ]*(-?0)", begin)
6060
if integer then
6161
local frac = s:match("^(%.%d+)", #integer + 1) or ""
@@ -74,7 +74,7 @@ function startsWithNumber(s)
7474
return false
7575
end
7676

77-
function startsWithKeyword(s)
77+
local function startsWithKeyword(s)
7878
local sequences = {"^true%s*$", "^false%s*$", "^null%s*$"}
7979
local startSequences = {"^true%s*[,%]}#].*$", "^false%s*[,%]}#].*$", "^null%s*[,%]}#].*$"}
8080

@@ -234,7 +234,7 @@ function HjsonEncoder:new(options)
234234
currentIndentLevel = currentIndentLevel + 1
235235
local newlineIndent = "\n" .. string.rep(indent, currentIndentLevel)
236236
local separator = newlineIndent
237-
keySeparator = ": "
237+
local keySeparator = ": "
238238

239239
-- stringified key (sk) is key in keysetMap pointing to original non stringified key key
240240
local keysetMap = {}

0 commit comments

Comments
 (0)