2016-04-04 21:50:57 +05:30

21 lines
763 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# vim:fileencoding=utf-8
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
# globals: ρσ_str
def strings():
string_funcs = set((
'capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase'
' center count endswith startswith find rfind index rindex format join ljust rjust'
' partition rpartition replace split rsplit splitlines zfill').split(' '))
if not arguments.length:
exclude = {'split', 'replace'}
elif arguments[0]:
exclude = Array.prototype.slice.call(arguments)
else:
exclude = None
if exclude:
string_funcs = string_funcs.difference(set(exclude))
for name in string_funcs:
String.prototype[name] = ρσ_str.prototype[name]