Library outlib
Helper functions for NSE script output
These functions are useful for ensuring output is consistently ordered between scans and following conventions for output formatting.
Author:
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/outlib.lua
Functions
- list_sep (t, sep)
Comma-separated list output
- sorted_by_key (t)
Create a table that yields elements sorted by key when iterated over with pairs()
Functions
- list_sep (t, sep)
-
Comma-separated list output
This adds a
__tostring
metamethod to a list (integer-indexed table) so that it will be formatted as a comma-separated list when converted to a string.Parameters
- t
- The table to format
- sep
- (Optional) list separator character, default: ", "
- sorted_by_key (t)
-
Create a table that yields elements sorted by key when iterated over with pairs()
The returned table is like a sorted view of the original table; it should be treated as read-only, and any new data should be added to the original table instead.
Parameters
- t
- The table whose data should be used
Return value:
out A table that can be passed to pairs() to get sorted results