nadesiko3 3.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/bin/cnako3 +10 -0
- package/bin/cnako3.bat +11 -0
- package/bin/nako3server.bat +6 -0
- package/demo/ace_editor.html +90 -0
- package/demo/ace_editor_tabs.html +162 -0
- package/demo/basic.html +71 -0
- package/demo/browsers.html +128 -0
- package/demo/css/basic.css +3 -0
- package/demo/css/common.css +157 -0
- package/demo/css/editor.css +8 -0
- package/demo/css/flow.css +3 -0
- package/demo/css/index.css +3 -0
- package/demo/extlib/ace@1.4.12/ace.js +17 -0
- package/demo/extlib/ace@1.4.12/ext-code_lens.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-language_tools.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-options.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-settings_menu.js +8 -0
- package/demo/extlib/ace@1.4.12/keybinding-vscode.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-monokai.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-xcode.js +8 -0
- package/demo/extlib/chart.js@3.2.1/chart.min.js +13 -0
- package/demo/extlib/pure-min.css +11 -0
- package/demo/flow.html +97 -0
- package/demo/graph.html +53 -0
- package/demo/image/nako.png +0 -0
- package/demo/image/nakopad-icon256.png +0 -0
- package/demo/image/turtle.fla +0 -0
- package/demo/image/turtle.png +0 -0
- package/demo/index.html +134 -0
- package/demo/js/common.js +17 -0
- package/demo/js/turtle3d_test.js +44 -0
- package/demo/js/turtle_test.js +44 -0
- package/demo/runscript.html +47 -0
- package/demo/runscript2.html +33 -0
- package/demo/turtle.html +58 -0
- package/demo/turtle2.html +141 -0
- package/demo/turtle3.html +278 -0
- package/demo/turtle3d.html +58 -0
- package/demo/turtle3d2.html +107 -0
- package/demo/version.html +24 -0
- package/doc/SETUP.md +172 -0
- package/doc/about.md +34 -0
- package/doc/browsers.md +60 -0
- package/doc/docgen.md +21 -0
- package/doc/editor.md +44 -0
- package/doc/files.md +37 -0
- package/doc/plugins.md +195 -0
- package/doc/release.md +78 -0
- package/doc/win32.md +57 -0
- package/package.json +196 -0
- package/release/_hash.txt +65 -0
- package/release/_script-tags.txt +13 -0
- package/release/command.json +1 -0
- package/release/command.json.js +1 -0
- package/release/command_cnako3.json +1 -0
- package/release/command_list.json +1 -0
- package/release/editor.js +2 -0
- package/release/editor.js.LICENSE.txt +32 -0
- package/release/josi.json +48 -0
- package/release/nako_gen_async.js +1 -0
- package/release/nako_gen_async.js.LICENSE.txt +595 -0
- package/release/plugin_caniuse.js +1 -0
- package/release/plugin_caniuse.js.LICENSE.txt +411 -0
- package/release/plugin_csv.js +1 -0
- package/release/plugin_csv.js.LICENSE.txt +367 -0
- package/release/plugin_datetime.js +1 -0
- package/release/plugin_datetime.js.LICENSE.txt +471 -0
- package/release/plugin_kansuji.js +1 -0
- package/release/plugin_kansuji.js.LICENSE.txt +491 -0
- package/release/plugin_markup.js +1 -0
- package/release/plugin_markup.js.LICENSE.txt +363 -0
- package/release/plugin_turtle.js +1 -0
- package/release/plugin_turtle.js.LICENSE.txt +435 -0
- package/release/plugin_webworker.js +1 -0
- package/release/plugin_webworker.js.LICENSE.txt +491 -0
- package/release/version.js +2 -0
- package/release/version.js.LICENSE.txt +32 -0
- package/release/wnako3.js +2 -0
- package/release/wnako3.js.LICENSE.txt +1 -0
- package/release/wnako3webworker.js +1 -0
- package/release/wnako3webworker.js.LICENSE.txt +847 -0
- package/release/yoyakugo.json +30 -0
- package/src/browsers.md +60 -0
- package/src/cnako3.js +466 -0
- package/src/commander_ja.js +154 -0
- package/src/enako3.js +69 -0
- package/src/era.json +22 -0
- package/src/index.js +5 -0
- package/src/nako3.js +836 -0
- package/src/nako3_assert.js +37 -0
- package/src/nako3editorfix.sfd +106 -0
- package/src/nako3editorfix.woff +0 -0
- package/src/nako3server.js +51 -0
- package/src/nako_colors.js +86 -0
- package/src/nako_errors.js +176 -0
- package/src/nako_gen.js +1459 -0
- package/src/nako_gen_async.js +1622 -0
- package/src/nako_global.js +113 -0
- package/src/nako_indent.js +480 -0
- package/src/nako_josi_list.js +46 -0
- package/src/nako_lex_rules.js +259 -0
- package/src/nako_lexer.js +576 -0
- package/src/nako_logger.js +138 -0
- package/src/nako_parser3.js +1768 -0
- package/src/nako_parser_base.js +265 -0
- package/src/nako_parser_const.js +37 -0
- package/src/nako_prepare.js +293 -0
- package/src/nako_reserved_words.js +35 -0
- package/src/nako_source_mapping.js +251 -0
- package/src/nako_test.js +37 -0
- package/src/nako_version.js +8 -0
- package/src/plugin_browser.js +191 -0
- package/src/plugin_browser_ajax.js +352 -0
- package/src/plugin_browser_audio.js +109 -0
- package/src/plugin_browser_canvas.js +462 -0
- package/src/plugin_browser_chart.js +296 -0
- package/src/plugin_browser_color.js +49 -0
- package/src/plugin_browser_crypto.js +26 -0
- package/src/plugin_browser_dialog.js +53 -0
- package/src/plugin_browser_dom_basic.js +322 -0
- package/src/plugin_browser_dom_event.js +193 -0
- package/src/plugin_browser_dom_parts.js +163 -0
- package/src/plugin_browser_geolocation.js +51 -0
- package/src/plugin_browser_hotkey.js +25 -0
- package/src/plugin_browser_html.js +59 -0
- package/src/plugin_browser_in_worker.js +44 -0
- package/src/plugin_browser_location.js +21 -0
- package/src/plugin_browser_speech.js +111 -0
- package/src/plugin_browser_storage.js +121 -0
- package/src/plugin_browser_system.js +12 -0
- package/src/plugin_browser_websocket.js +73 -0
- package/src/plugin_caniuse.js +24 -0
- package/src/plugin_csv.js +57 -0
- package/src/plugin_datetime.js +414 -0
- package/src/plugin_express.js +212 -0
- package/src/plugin_kansuji.js +224 -0
- package/src/plugin_keigo.js +55 -0
- package/src/plugin_markup.js +32 -0
- package/src/plugin_math.js +319 -0
- package/src/plugin_node.js +1018 -0
- package/src/plugin_promise.js +94 -0
- package/src/plugin_system.js +2109 -0
- package/src/plugin_test.js +38 -0
- package/src/plugin_turtle.js +646 -0
- package/src/plugin_webworker.js +334 -0
- package/src/plugin_weykturtle3d.js +1216 -0
- package/src/plugin_worker.js +92 -0
- package/src/repl.nako3 +63 -0
- package/src/turtle-elephant.png +0 -0
- package/src/turtle-panda.png +0 -0
- package/src/turtle64.png +0 -0
- package/src/wnako3.js +162 -0
- package/src/wnako3_editor.css +215 -0
- package/src/wnako3_editor.js +1645 -0
- package/src/wnako3_editor_marker_red.png +0 -0
- package/src/wnako3_editor_marker_red.xcf +0 -0
- package/src/wnako3_editor_marker_yellow.png +0 -0
- package/src/wnako3_editor_marker_yellow.xcf +0 -0
- package/src/wnako3webworker.js +70 -0
- package/test/ace_editor/karma.config.js +94 -0
- package/test/ace_editor/test/.babelrc.json +3 -0
- package/test/ace_editor/test/ace_editor_test.js +178 -0
- package/test/ace_editor/test/html/custom_context.html +140 -0
- package/test/async/async_basic_test.js +124 -0
- package/test/browser/karma.config.js +212 -0
- package/test/browser/test/.babelrc.json +3 -0
- package/test/browser/test/compare_util.js +50 -0
- package/test/browser/test/html/canvas_basic.html +1 -0
- package/test/browser/test/html/div_basic.html +2 -0
- package/test/browser/test/html/event_dom_form.html +4 -0
- package/test/browser/test/html/event_dom_scrolldiv.html +5 -0
- package/test/browser/test/image/canvas_test1.png +0 -0
- package/test/browser/test/image/canvas_test2.png +0 -0
- package/test/browser/test/image/canvas_test3.png +0 -0
- package/test/browser/test/image/canvas_test4.png +0 -0
- package/test/browser/test/image/canvas_test7.png +0 -0
- package/test/browser/test/image/canvas_test8.png +0 -0
- package/test/browser/test/image/canvas_test_blank.png +0 -0
- package/test/browser/test/image/elephant_kana.png +0 -0
- package/test/browser/test/image/panda_kana.png +0 -0
- package/test/browser/test/image/turtle_kana.png +0 -0
- package/test/browser/test/import_plugin_checker.js +24 -0
- package/test/browser/test/plugin_browser_test.js +52 -0
- package/test/browser/test/plugin_browser_test_ajax.js +123 -0
- package/test/browser/test/plugin_browser_test_color.js +18 -0
- package/test/browser/test/plugin_browser_test_dialog.js +72 -0
- package/test/browser/test/plugin_browser_test_dom_event.js +598 -0
- package/test/browser/test/plugin_browser_test_dom_parts.js +125 -0
- package/test/browser/test/plugin_browser_test_system.js +9 -0
- package/test/browser/test/plugin_turtle_test.js +817 -0
- package/test/browser/test/plugin_webworker_test.js +87 -0
- package/test/browser/test/require_test.js +71 -0
- package/test/bundled/karma.config.base.js +117 -0
- package/test/bundled/karma.config.js +86 -0
- package/test/bundled/test/.babelrc.json +3 -0
- package/test/bundled/test/bundled_test.js +69 -0
- package/test/bundled/test/html/custom_context.html +65 -0
- package/test/bundled/test/html/custom_debug.html +66 -0
- package/test/bundled/test4b.cmd +52 -0
- package/test/bundled/test_base/.babelrc.json +3 -0
- package/test/bundled/test_base/_checktool_test.js +25 -0
- package/test/bundled/test_base/basic_ajax_test.js +56 -0
- package/test/bundled/test_base/basic_async_test.js +18 -0
- package/test/bundled/test_base/basic_test.js +153 -0
- package/test/bundled/test_base/calc_test.js +132 -0
- package/test/bundled/test_base/css/browsers_box.css +114 -0
- package/test/bundled/test_base/html/custom_context.html +69 -0
- package/test/bundled/test_base/html/custom_debug.html +71 -0
- package/test/bundled/test_base/js/browsers_box.js +72 -0
- package/test/bundled/test_base/plugin_csv_test.js +37 -0
- package/test/bundled/test_base/plugin_datetime_test.js +115 -0
- package/test/bundled/test_base/plugin_kansuji_test.js +49 -0
- package/test/bundled/test_base/plugin_system_test.js +410 -0
- package/test/bundled/test_base/plugin_webworker_test.js +53 -0
- package/test/bundled/test_base/resources/ok.txt +1 -0
- package/test/bundled/test_base/test_utils.js +191 -0
- package/test/common/array_test.js +40 -0
- package/test/common/basic_test.js +317 -0
- package/test/common/calc_test.js +139 -0
- package/test/common/debug_test.js +16 -0
- package/test/common/error_test.js +16 -0
- package/test/common/flow_test.js +360 -0
- package/test/common/func_call.js +136 -0
- package/test/common/func_test.js +149 -0
- package/test/common/indent_test.js +362 -0
- package/test/common/lex_test.js +146 -0
- package/test/common/literal_test.js +72 -0
- package/test/common/nako_logger_test.js +26 -0
- package/test/common/plugin_browser_test.js +24 -0
- package/test/common/plugin_browser_ut_audio_test.js +88 -0
- package/test/common/plugin_browser_ut_color_test.js +21 -0
- package/test/common/plugin_browser_ut_dialog_test.js +100 -0
- package/test/common/plugin_browser_ut_html_test.js +13 -0
- package/test/common/plugin_browser_ut_system_test.js +10 -0
- package/test/common/plugin_csv_test.js +39 -0
- package/test/common/plugin_datetime_test.js +120 -0
- package/test/common/plugin_kansuji_test.js +59 -0
- package/test/common/plugin_promise_test.js +18 -0
- package/test/common/plugin_system_test.js +451 -0
- package/test/common/prepare_test.js +93 -0
- package/test/common/re_test.js +20 -0
- package/test/common/variable_scope_test.js +105 -0
- package/test/jsconfig.json +19 -0
- package/test/karma.config.js +91 -0
- package/test/node/add_test.nako3 +1 -0
- package/test/node/async_test.js +80 -0
- package/test/node/commander_ja_test.js +82 -0
- package/test/node/error_message_test.js +244 -0
- package/test/node/kai_test.nako3 +6 -0
- package/test/node/node_test.js +43 -0
- package/test/node/plugin_broken.js.txt +3 -0
- package/test/node/plugin_browser_ut_ajax_test.js +355 -0
- package/test/node/plugin_browser_ut_location_test.js +32 -0
- package/test/node/plugin_markup_test.js +44 -0
- package/test/node/plugin_math_test.js +42 -0
- package/test/node/plugin_node_test.js +93 -0
- package/test/node/plugin_test.js +16 -0
- package/test/node/relative_import_test_1.nako3 +1 -0
- package/test/node/relative_import_test_2.nako3 +2 -0
- package/test/node/require_nako3_test.js +59 -0
- package/test/node/requiretest.nako3 +4 -0
- package/test/node/requiretest_indirect.nako3 +1 -0
- package/test/node/requiretest_name.nako3 +5 -0
- package/test/node/runtime_error.nako3 +2 -0
- package/test/node/side_effects_test.js +106 -0
- package/test/node/sjis.txt +5 -0
- package/test/node/syntax_error.nako3 +2 -0
- package/test/node/wnako3_editor_test.js +360 -0
- package/tools/README.md +7 -0
- package/tools/nako3edit/html/edit.html +83 -0
- package/tools/nako3edit/html/edit_plugin.js +6 -0
- package/tools/nako3edit/html/files.html +49 -0
- package/tools/nako3edit/html/nako3edit.css +66 -0
- package/tools/nako3edit/index.nako3 +145 -0
- package/tools/nako3edit/run.js +12 -0
- package/tools/nako3server/html/edit.html +104 -0
- package/tools/nako3server/html/edit_plugin.js +6 -0
- package/tools/nako3server/html/files.html +53 -0
- package/tools/nako3server/html/nako3edit.css +66 -0
- package/tools/nako3server/index.nako3 +129 -0
- package/tools/nako3server/run.js +12 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const PluginKansuji = {
|
|
3
|
+
|
|
4
|
+
'初期化': {
|
|
5
|
+
type: 'func',
|
|
6
|
+
josi: [],
|
|
7
|
+
pure: true,
|
|
8
|
+
fn: function (sys) {
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
// @漢数字関連
|
|
13
|
+
'漢数字': { // @引数を数字と解釈して漢数字の文字列を返す // @かんすうじ
|
|
14
|
+
type: 'func',
|
|
15
|
+
josi: [['を', 'の']],
|
|
16
|
+
pure: true,
|
|
17
|
+
fn: function (input) {
|
|
18
|
+
function preprocesser (input) {
|
|
19
|
+
// eslint-disable-next-line camelcase
|
|
20
|
+
function if_number_is_exponent (input) {
|
|
21
|
+
const match = input.match(/[0-9]*\.?[0-9]+[eE][-+]?[0-9]+/)
|
|
22
|
+
if (match && match[0] === input) {
|
|
23
|
+
const base = input.match(/[0-9]*\.?[0-9]+[eE]/)[0].slice(0, -1)
|
|
24
|
+
const exponent = input.match(/[eE][-+]?[0-9]+/)[0].slice(1)
|
|
25
|
+
// eslint-disable-next-line no-inner-declarations
|
|
26
|
+
function movepoint (base, exponent) {
|
|
27
|
+
const sign = exponent[0]
|
|
28
|
+
const curpointidx = base.includes('.') ? base.indexOf('.') : base.length
|
|
29
|
+
const idx = sign === '-' ? curpointidx - parseInt(exponent.slice(1)) : curpointidx + parseInt(exponent.match(/[0-9]+$/)[0])
|
|
30
|
+
function strIns (str, idx, val) {
|
|
31
|
+
return str.slice(0, idx) + val + str.slice(idx)
|
|
32
|
+
}
|
|
33
|
+
if (idx > 0) {
|
|
34
|
+
if (base.length - curpointidx > idx) {
|
|
35
|
+
return strIns(base.replace('.', ''), idx, '.')
|
|
36
|
+
} else {
|
|
37
|
+
if (base.includes('.')) {
|
|
38
|
+
return base.replace('.', '') + '0'.repeat(idx - base.length + curpointidx)
|
|
39
|
+
} else {
|
|
40
|
+
return base + '0'.repeat(idx - base.length + curpointidx - 1)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
return '0.' + '0'.repeat(-idx) + base.replace('.', '')
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
input = movepoint(base, exponent)
|
|
48
|
+
}
|
|
49
|
+
return input
|
|
50
|
+
}
|
|
51
|
+
function asciify (input) { // 全角数字を半角数字に
|
|
52
|
+
return input.replace(/[0-9]/g, s => {
|
|
53
|
+
return String.fromCharCode(s.charCodeAt(0) - 65248)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
input = asciify(input)
|
|
57
|
+
if (Number.isNaN(Number(input))) { throw new Error('『漢数字』命令の中に無効な文字が含まれています。') }
|
|
58
|
+
const output = if_number_is_exponent(input.toString())
|
|
59
|
+
// eslint-disable-next-line no-loss-of-precision
|
|
60
|
+
if (output > BigInt(999999999999999999999999999999999999999999999999999999999999999999999999)) { throw new Error('『漢数字』命令の中に含められる数の大きさを超えています。') }
|
|
61
|
+
return output
|
|
62
|
+
}
|
|
63
|
+
input = preprocesser(String(input))
|
|
64
|
+
function separater (str) {
|
|
65
|
+
let isminus = str.includes('.')
|
|
66
|
+
return str.split('').reverse().reduce((acc, cur) => {
|
|
67
|
+
if (cur === '.') {
|
|
68
|
+
isminus = false
|
|
69
|
+
acc.splice(1, 0, '.')
|
|
70
|
+
return acc
|
|
71
|
+
} else if (isminus) {
|
|
72
|
+
acc.splice(1, 0, cur)
|
|
73
|
+
return acc
|
|
74
|
+
}
|
|
75
|
+
if (acc[0].length === 軸数字.length) {
|
|
76
|
+
acc.unshift([])
|
|
77
|
+
}
|
|
78
|
+
acc[0].unshift(cur)
|
|
79
|
+
return acc
|
|
80
|
+
}, [[]])
|
|
81
|
+
}
|
|
82
|
+
function converter (arr) {
|
|
83
|
+
function replacer (str) {
|
|
84
|
+
return 基本漢数字[基本算用数字.indexOf(str)]
|
|
85
|
+
}
|
|
86
|
+
let adjuster = 0
|
|
87
|
+
const result = arr.reverse().reduce((acc, cur, idx) => {
|
|
88
|
+
if (typeof cur === 'string') {
|
|
89
|
+
if (cur === '.') {
|
|
90
|
+
acc = '・' + acc
|
|
91
|
+
adjuster = idx + 1
|
|
92
|
+
} else {
|
|
93
|
+
acc = replacer(cur) + acc
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
const unit = cur.reduce((acc, cur, idx, src) => {
|
|
97
|
+
if (cur === '0') {
|
|
98
|
+
return acc
|
|
99
|
+
} else if (cur === '1' && 軸数字[src.length - 1 - idx] !== '') {
|
|
100
|
+
return acc + 軸数字[src.length - 1 - idx]
|
|
101
|
+
} else {
|
|
102
|
+
return acc + replacer(cur) + 軸数字[src.length - 1 - idx]
|
|
103
|
+
}
|
|
104
|
+
}, '')
|
|
105
|
+
acc = (unit ? unit + 単位数字[idx - adjuster] : '') + acc
|
|
106
|
+
}
|
|
107
|
+
return acc
|
|
108
|
+
}, '')
|
|
109
|
+
return result[0] === '・' ? '零' + result : result
|
|
110
|
+
}
|
|
111
|
+
// フラグを覚えておく #874
|
|
112
|
+
let flag = ''
|
|
113
|
+
if (input.charAt(0) === '+' || input.charAt(0) === '-') {
|
|
114
|
+
flag = input.charAt(0)
|
|
115
|
+
input = input.substr(1)
|
|
116
|
+
}
|
|
117
|
+
let res = converter(separater(input))
|
|
118
|
+
if (res === '') { res = '零' }
|
|
119
|
+
return flag + res
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
'算用数字': { // @U引数を漢数字と解釈して数値を返す // @さんようすうじ
|
|
123
|
+
type: 'func',
|
|
124
|
+
josi: [['を', 'の']],
|
|
125
|
+
pure: true,
|
|
126
|
+
fn: function (input) {
|
|
127
|
+
function converter (src) {
|
|
128
|
+
const multibytes = 単位数字.filter(a => a.length > 1)
|
|
129
|
+
const result = []
|
|
130
|
+
for (let idx = 0; idx < src.length; idx++) {
|
|
131
|
+
const cur = src.slice(idx, idx + 1)
|
|
132
|
+
const 指数 = 単位数字.includes(cur) ? cur : multibytes.find(v => v === src.slice(idx, idx + v.length))
|
|
133
|
+
const 位 = 軸数字.includes(cur) ? cur : null
|
|
134
|
+
const 底 = 基本漢数字.includes(cur) ? cur : null
|
|
135
|
+
if (指数) {
|
|
136
|
+
if (指数.length > 1) {
|
|
137
|
+
idx += 指数.length - 1
|
|
138
|
+
}
|
|
139
|
+
result.push(BigInt('1' + '0'.repeat(4 * 単位数字.indexOf(指数))))
|
|
140
|
+
} else if (位) {
|
|
141
|
+
result.push(10 ** (軸数字.indexOf(位)))
|
|
142
|
+
} else if (底) {
|
|
143
|
+
result.push(基本漢数字.indexOf(底))
|
|
144
|
+
} else if (cur === '・') {
|
|
145
|
+
result.push('.')
|
|
146
|
+
} else if (cur === '零') {
|
|
147
|
+
result.push('0')
|
|
148
|
+
} else {
|
|
149
|
+
throw new Error('『算用数字』命令の中に無効な文字が含まれています。')
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return result
|
|
153
|
+
}
|
|
154
|
+
function separater (arr) {
|
|
155
|
+
let base = []
|
|
156
|
+
let unit = []
|
|
157
|
+
let isminus = false
|
|
158
|
+
return arr.reduce((acc, cur, idx) => {
|
|
159
|
+
if (cur === '.') {
|
|
160
|
+
if (base.length === 0) { base.push(0, 1) }
|
|
161
|
+
if (base.length === 1) { base.push(1) }
|
|
162
|
+
unit.push(base)
|
|
163
|
+
base = []
|
|
164
|
+
acc.push(unit)
|
|
165
|
+
acc.push('.')
|
|
166
|
+
unit = []
|
|
167
|
+
isminus = true
|
|
168
|
+
} else if (isminus) {
|
|
169
|
+
acc.push(String(cur))
|
|
170
|
+
} else if (cur > 1000) {
|
|
171
|
+
if (base.length === 0) { base.push(0, 1) }
|
|
172
|
+
if (base.length === 1) { base.push(1) }
|
|
173
|
+
unit.push(base)
|
|
174
|
+
base = []
|
|
175
|
+
unit.push(cur)
|
|
176
|
+
acc.push(unit)
|
|
177
|
+
unit = []
|
|
178
|
+
} else if (cur >= 10 && cur <= 1000) {
|
|
179
|
+
if (base.length === 0) { base.push(1) }
|
|
180
|
+
base.push(cur)
|
|
181
|
+
unit.push(base)
|
|
182
|
+
base = []
|
|
183
|
+
} else if (cur < 10) {
|
|
184
|
+
base.push(cur)
|
|
185
|
+
}
|
|
186
|
+
if (idx + 1 === arr.length && isminus === false) {
|
|
187
|
+
if (base.length === 1) {
|
|
188
|
+
base.push(1)
|
|
189
|
+
unit.push(base)
|
|
190
|
+
}
|
|
191
|
+
acc.push(unit)
|
|
192
|
+
}
|
|
193
|
+
return acc
|
|
194
|
+
}, [])
|
|
195
|
+
}
|
|
196
|
+
function calculator (arr) {
|
|
197
|
+
return arr.reduce((acc, cur, idx) => {
|
|
198
|
+
return typeof cur === 'string'
|
|
199
|
+
? acc + cur
|
|
200
|
+
: acc + cur.reduce((acc, cur, idx) => {
|
|
201
|
+
return cur > 1000 ? acc * cur : acc + BigInt(cur[0] * cur[1])
|
|
202
|
+
}, BigInt(0))
|
|
203
|
+
}, BigInt(0))
|
|
204
|
+
}
|
|
205
|
+
const tmp = calculator(separater(converter(input.toString())))
|
|
206
|
+
return tmp > Number.MAX_SAFE_INTEGER ? tmp : Number(tmp)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const 単位数字 = [
|
|
212
|
+
'', '万', '億', '兆', '京', '垓', '𥝱', '穣', '溝', '澗', '正',
|
|
213
|
+
'載', '極', '恒河沙', '阿僧祇', '那由他', '不可思議', '無量大数'
|
|
214
|
+
]
|
|
215
|
+
const 軸数字 = [
|
|
216
|
+
'', '十', '百', '千'
|
|
217
|
+
]
|
|
218
|
+
const 基本算用数字 = '0123456789'.split('')
|
|
219
|
+
const 基本漢数字 = '〇一二三四五六七八九'.split('')
|
|
220
|
+
|
|
221
|
+
module.exports = PluginKansuji
|
|
222
|
+
|
|
223
|
+
// scriptタグで取り込んだ時、自動で登録する
|
|
224
|
+
if (typeof (navigator) === 'object' && typeof (navigator.nako3) === 'object') { navigator.nako3.addPluginObject('PluginKansuji', PluginKansuji) }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// 敬語を使いたい人のためのプラグイン (お遊び機能)
|
|
3
|
+
|
|
4
|
+
const PluginKeigo = {
|
|
5
|
+
'初期化': {
|
|
6
|
+
type: 'func',
|
|
7
|
+
josi: [],
|
|
8
|
+
pure: true,
|
|
9
|
+
fn: function (sys) {
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
// @丁寧語
|
|
13
|
+
'お世話': { type: 'const', value: 1 }, // @おせわ
|
|
14
|
+
'な': { // @Aになる // @なる
|
|
15
|
+
type: 'func',
|
|
16
|
+
josi: [['に', 'へ']],
|
|
17
|
+
pure: true,
|
|
18
|
+
fn: function (a, sys) {
|
|
19
|
+
return a
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
'おります': { // @ソースコードを読む人を気持ちよくする // @おります
|
|
23
|
+
type: 'func',
|
|
24
|
+
josi: [],
|
|
25
|
+
pure: true,
|
|
26
|
+
fn: function (sys) {
|
|
27
|
+
if (!sys.__reisetu) { sys.__reisetu = 0 }
|
|
28
|
+
sys.__reisetu++
|
|
29
|
+
},
|
|
30
|
+
return_none: true
|
|
31
|
+
},
|
|
32
|
+
'どうぞ': { // @ソースコードを読む人を気持ちよくする // @どうぞ
|
|
33
|
+
type: 'func',
|
|
34
|
+
josi: [],
|
|
35
|
+
pure: true,
|
|
36
|
+
fn: function (sys) {
|
|
37
|
+
if (!sys.__reisetu) { sys.__reisetu = 0 }
|
|
38
|
+
sys.__reisetu++
|
|
39
|
+
},
|
|
40
|
+
return_none: true
|
|
41
|
+
},
|
|
42
|
+
'よろしくお願': { // @ソースコードを読む人を気持ちよくする // @よろしくおねがいします
|
|
43
|
+
type: 'func',
|
|
44
|
+
josi: [],
|
|
45
|
+
pure: true,
|
|
46
|
+
fn: function (sys) {
|
|
47
|
+
if (!sys.__reisetu) { sys.__reisetu = 0 }
|
|
48
|
+
sys.__reisetu++
|
|
49
|
+
},
|
|
50
|
+
return_none: true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = PluginKeigo
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* file: plugin_markup.js
|
|
4
|
+
* マークアップ言語関連のプラグイン
|
|
5
|
+
*/
|
|
6
|
+
const PluginMarkup = {
|
|
7
|
+
// @マークアップ
|
|
8
|
+
'マークダウンHTML変換': { // @マークダウン形式で記述された文字列SをHTML形式に変換する // @まーくだうんHTMLへんかん
|
|
9
|
+
type: 'func',
|
|
10
|
+
josi: [['を']],
|
|
11
|
+
pure: true,
|
|
12
|
+
fn: function (s) {
|
|
13
|
+
const marked = require('marked')
|
|
14
|
+
const html = marked(s)
|
|
15
|
+
return html
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
'HTML整形': { // @HTML形式で記述された文字列Sを整形する // @HTMLせいけい
|
|
19
|
+
type: 'func',
|
|
20
|
+
josi: [['を']],
|
|
21
|
+
pure: true,
|
|
22
|
+
fn: function (s) {
|
|
23
|
+
const html = require('html')
|
|
24
|
+
return html.prettyPrint(s, { indent_size: 2 })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = PluginMarkup
|
|
30
|
+
|
|
31
|
+
// scriptタグで取り込んだ時、自動で登録する
|
|
32
|
+
if (typeof (navigator) === 'object') { navigator.nako3.addPluginObject('PluginMarkup', PluginMarkup) }
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const PluginMath = {
|
|
3
|
+
'初期化': {
|
|
4
|
+
type: 'func',
|
|
5
|
+
josi: [],
|
|
6
|
+
pure: true,
|
|
7
|
+
fn: function (sys) {
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
// @三角関数
|
|
11
|
+
'SIN': { // @ラジアン単位VのSINを求める // @SIN
|
|
12
|
+
type: 'func',
|
|
13
|
+
josi: [['の']],
|
|
14
|
+
pure: true,
|
|
15
|
+
fn: function (v) {
|
|
16
|
+
return Math.sin(v)
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
'COS': { // @ラジアン単位VのCOSを求める // @COS
|
|
20
|
+
type: 'func',
|
|
21
|
+
josi: [['の']],
|
|
22
|
+
pure: true,
|
|
23
|
+
fn: function (v) {
|
|
24
|
+
return Math.cos(v)
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'TAN': { // @ラジアン単位VのTANを求める // @TAN
|
|
28
|
+
type: 'func',
|
|
29
|
+
josi: [['の']],
|
|
30
|
+
pure: true,
|
|
31
|
+
fn: function (v) {
|
|
32
|
+
return Math.tan(v)
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
'ARCSIN': { // @ラジアン単位VのARCSINを求める // @ARCSIN
|
|
36
|
+
type: 'func',
|
|
37
|
+
josi: [['の']],
|
|
38
|
+
pure: true,
|
|
39
|
+
fn: function (v) {
|
|
40
|
+
return Math.asin(v)
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
'ARCCOS': { // @ラジアン単位VのARCCOSを求める // @ARCCOS
|
|
44
|
+
type: 'func',
|
|
45
|
+
josi: [['の']],
|
|
46
|
+
pure: true,
|
|
47
|
+
fn: function (v) {
|
|
48
|
+
return Math.acos(v)
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
'ARCTAN': { // @ラジアン単位VのARCTANを求める // @ARCTAN
|
|
52
|
+
type: 'func',
|
|
53
|
+
josi: [['の']],
|
|
54
|
+
pure: true,
|
|
55
|
+
fn: function (v) {
|
|
56
|
+
return Math.atan(v)
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
'ATAN2': { // @ARCTAN(Y/X)をラジアン単位で返す // @ATAN2
|
|
60
|
+
type: 'func',
|
|
61
|
+
josi: [['と'], ['の']],
|
|
62
|
+
pure: true,
|
|
63
|
+
fn: function (y, x) {
|
|
64
|
+
return Math.atan2(y, x)
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
'座標角度計算': { // @点[0,0]から[x,y]の直線とX軸の角度(度)を返す // @ざひょうかくどけいさん
|
|
68
|
+
type: 'func',
|
|
69
|
+
josi: [['の']],
|
|
70
|
+
pure: true,
|
|
71
|
+
fn: function (XY) {
|
|
72
|
+
return Math.atan2(XY[1], XY[0]) * 180 / Math.PI
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
'RAD2DEG': { // @ラジアンから度に変換 // @RAD2DEG
|
|
76
|
+
type: 'func',
|
|
77
|
+
josi: [['を']],
|
|
78
|
+
pure: true,
|
|
79
|
+
fn: function (v) {
|
|
80
|
+
return v / Math.PI * 180
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
'DEG2RAD': { // @度からラジアンに変換 // @DEG2RAD
|
|
84
|
+
type: 'func',
|
|
85
|
+
josi: [['を']],
|
|
86
|
+
pure: true,
|
|
87
|
+
fn: function (v) {
|
|
88
|
+
return (v / 180) * Math.PI
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
'度変換': { // @ラジアンから度に変換 // @どへんかん
|
|
92
|
+
type: 'func',
|
|
93
|
+
josi: [['を']],
|
|
94
|
+
pure: true,
|
|
95
|
+
fn: function (v) {
|
|
96
|
+
return v / Math.PI * 180
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
'ラジアン変換': { // @度からラジアンに変換 // @らじあんへんかん
|
|
100
|
+
type: 'func',
|
|
101
|
+
josi: [['を']],
|
|
102
|
+
pure: true,
|
|
103
|
+
fn: function (v) {
|
|
104
|
+
return (v / 180) * Math.PI
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// @算術関数
|
|
109
|
+
'SIGN': { // @Vが0なら0を、0超なら1を、0未満なら-1を返す // @SIGN
|
|
110
|
+
type: 'func',
|
|
111
|
+
josi: [['の']],
|
|
112
|
+
pure: true,
|
|
113
|
+
fn: function (v) {
|
|
114
|
+
return (parseFloat(v) === 0) ? 0 : (v > 0) ? 1 : -1
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
'符号': { // @Vが0なら0を、0超なら1を、0未満なら-1を返す // @ふごう
|
|
118
|
+
type: 'func',
|
|
119
|
+
josi: [['の']],
|
|
120
|
+
pure: false,
|
|
121
|
+
fn: function (v, sys) {
|
|
122
|
+
return sys.__exec('SIGN', [v])
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
'ABS': { // @Vの絶対値を返す // @ABS
|
|
126
|
+
type: 'func',
|
|
127
|
+
josi: [['の']],
|
|
128
|
+
pure: true,
|
|
129
|
+
fn: function (a) {
|
|
130
|
+
return Math.abs(a)
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
'絶対値': { // @Vの絶対値を返す // @ぜったいち
|
|
134
|
+
type: 'func',
|
|
135
|
+
josi: [['の']],
|
|
136
|
+
pure: true,
|
|
137
|
+
fn: function (a) {
|
|
138
|
+
return Math.abs(a)
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
'EXP': { // @e(自然対数の底)の A 乗の値を返す // @EXP
|
|
142
|
+
type: 'func',
|
|
143
|
+
josi: [['の']],
|
|
144
|
+
pure: true,
|
|
145
|
+
fn: function (a) {
|
|
146
|
+
return Math.exp(a)
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
'HYPOT': { // @直角三角形の二辺の長さA,Bから斜辺を求めて返す。 // @HYPOT
|
|
150
|
+
type: 'func',
|
|
151
|
+
josi: [['と'], ['の']],
|
|
152
|
+
pure: true,
|
|
153
|
+
fn: function (a, b) {
|
|
154
|
+
return Math.hypot(a, b)
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
'斜辺': { // @直角三角形の二辺の長さA,Bから斜辺を求めて返す。 // @しゃへん
|
|
158
|
+
type: 'func',
|
|
159
|
+
josi: [['と'], ['の']],
|
|
160
|
+
pure: true,
|
|
161
|
+
fn: function (a, b) {
|
|
162
|
+
return Math.hypot(a, b)
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
'LN': { // @実数式 A の自然対数(Ln(A) = 1)を返す // @LN
|
|
166
|
+
type: 'func',
|
|
167
|
+
josi: [['の']],
|
|
168
|
+
pure: true,
|
|
169
|
+
fn: function (a) {
|
|
170
|
+
return Math.log(a)
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
'LOG': { // @Aの自然対数(底はE)を返す // @LOG
|
|
174
|
+
type: 'func',
|
|
175
|
+
josi: [['の']],
|
|
176
|
+
pure: true,
|
|
177
|
+
fn: function (a) {
|
|
178
|
+
return Math.log(a)
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
'LOGN': { // @指定された底AでBの対数を計算して返す // @LOGN
|
|
182
|
+
type: 'func',
|
|
183
|
+
josi: [['で'], ['の']],
|
|
184
|
+
pure: true,
|
|
185
|
+
fn: function (a, b) {
|
|
186
|
+
if (a === 2) { return Math.LOG2E * Math.log(b) }
|
|
187
|
+
if (a === 10) { return Math.LOG10E * Math.log(b) }
|
|
188
|
+
return Math.log(b) / Math.log(a)
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
'FRAC': { // @実数Aの小数部分を返す // @FRAC
|
|
192
|
+
type: 'func',
|
|
193
|
+
josi: [['の']],
|
|
194
|
+
pure: true,
|
|
195
|
+
fn: function (a) {
|
|
196
|
+
return a % 1
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
'小数部分': { // @実数Aの小数部分を返す // @しょうすうぶぶん
|
|
200
|
+
type: 'func',
|
|
201
|
+
josi: [['の']],
|
|
202
|
+
pure: true,
|
|
203
|
+
fn: function (a) {
|
|
204
|
+
return a % 1
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
'整数部分': { // @実数Aの整数部分を返す // @せいすうぶぶん
|
|
208
|
+
type: 'func',
|
|
209
|
+
josi: [['の']],
|
|
210
|
+
pure: true,
|
|
211
|
+
fn: function (a) {
|
|
212
|
+
return Math.trunc(a)
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
'乱数': { // @0から(A-1)までの乱数を返す // @らんすう
|
|
216
|
+
type: 'func',
|
|
217
|
+
josi: [['の']],
|
|
218
|
+
pure: true,
|
|
219
|
+
fn: function (a) {
|
|
220
|
+
return Math.floor(Math.random() * a)
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
'SQRT': { // @Aの平方根を返す // @SQRT
|
|
224
|
+
type: 'func',
|
|
225
|
+
josi: [['の']],
|
|
226
|
+
pure: true,
|
|
227
|
+
fn: function (a) {
|
|
228
|
+
return Math.sqrt(a)
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
'平方根': { // @Aの平方根を返す // @へいほうこん
|
|
232
|
+
type: 'func',
|
|
233
|
+
josi: [['の']],
|
|
234
|
+
pure: true,
|
|
235
|
+
fn: function (a) {
|
|
236
|
+
return Math.sqrt(a)
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
// @数値切上切捨丸め
|
|
241
|
+
'ROUND': { // @実数型の値Vを丸めてもっとも近い整数値を返す // @ROUND
|
|
242
|
+
type: 'func',
|
|
243
|
+
josi: [['を']],
|
|
244
|
+
pure: true,
|
|
245
|
+
fn: function (v) {
|
|
246
|
+
return Math.round(v)
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
'四捨五入': { // @実数型の値Vを丸めてもっとも近い整数値を返す // @ししゃごにゅう
|
|
250
|
+
type: 'func',
|
|
251
|
+
josi: [['を', 'の']],
|
|
252
|
+
pure: true,
|
|
253
|
+
fn: function (v) {
|
|
254
|
+
return Math.round(v)
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
'小数点切上': { // @整数Aを小数点第B桁で切り上げして返す // @しょうすうてんきりあげ
|
|
258
|
+
type: 'func',
|
|
259
|
+
josi: [['を'], ['で']],
|
|
260
|
+
pure: true,
|
|
261
|
+
fn: function (a, b) {
|
|
262
|
+
const base = Math.pow(10, b)
|
|
263
|
+
return Math.ceil(a * base) / base
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
'小数点切下': { // @整数Aを小数点第B桁で切り下げして返す // @しょうすうてんきりさげ
|
|
267
|
+
type: 'func',
|
|
268
|
+
josi: [['を'], ['で']],
|
|
269
|
+
pure: true,
|
|
270
|
+
fn: function (a, b) {
|
|
271
|
+
const base = Math.pow(10, b)
|
|
272
|
+
return Math.floor(a * base) / base
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
'小数点四捨五入': { // @実数Aを小数点第B桁で四捨五入して返す // @しょうすうてんししゃごにゅう
|
|
276
|
+
type: 'func',
|
|
277
|
+
josi: [['を'], ['で']],
|
|
278
|
+
pure: true,
|
|
279
|
+
fn: function (a, b) {
|
|
280
|
+
const base = Math.pow(10, b)
|
|
281
|
+
return Math.round(a * base) / base
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
'CEIL': { // @数値を正の無限大方向へ切り上げて返す。 // @CEIL
|
|
285
|
+
type: 'func',
|
|
286
|
+
josi: [['を']],
|
|
287
|
+
pure: true,
|
|
288
|
+
fn: function (v) {
|
|
289
|
+
return Math.ceil(v)
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
'切上': { // @数値を正の無限大方向へ切り上げて返す。 // @きりあげ
|
|
293
|
+
type: 'func',
|
|
294
|
+
josi: [['を']],
|
|
295
|
+
pure: true,
|
|
296
|
+
fn: function (v) {
|
|
297
|
+
return Math.ceil(v)
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
'FLOOR': { // @数値を負の無限大方向へ切り下げて返す。 // @FLOOR
|
|
301
|
+
type: 'func',
|
|
302
|
+
josi: [['を']],
|
|
303
|
+
pure: true,
|
|
304
|
+
fn: function (v) {
|
|
305
|
+
return Math.floor(v)
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
'切捨': { // @数値を負の無限大方向へ切り下げて返す。// @きりすて
|
|
309
|
+
type: 'func',
|
|
310
|
+
josi: [['を']],
|
|
311
|
+
pure: true,
|
|
312
|
+
fn: function (v) {
|
|
313
|
+
return Math.floor(v)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
module.exports = PluginMath
|