forked from entrepreneur-interet-general/opensignauxfaibles
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ts): Mise en place du typage dans fonctions JavaScript (#3)
Première étape visant à rendre plus robuste le développement et l'exécution des fonctions JavaScript employées par le map-reduce de MongoDB, en typant puis transpilant ces fonctions à l'aide de TypeScript. Pour tester la chaine de transpilation (provisoire): ```sh $ ./test_js_functions.sh ```
- Loading branch information
1 parent
c282f85
commit c31baca
Showing
8 changed files
with
87 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
function raison_sociale ( | ||
denomination_unite_legale, | ||
nom_unite_legale, | ||
nom_usage_unite_legale, | ||
prenom1_unite_legale, | ||
prenom2_unite_legale, | ||
prenom3_unite_legale, | ||
prenom4_unite_legale | ||
){ | ||
|
||
if (!nom_usage_unite_legale){ | ||
var nom_usage_unite_legale = '' | ||
} else { | ||
var nom_usage_unite_legale = nom_usage_unite_legale + '/' | ||
} | ||
var raison_sociale = denomination_unite_legale || | ||
(nom_unite_legale + '*' + nom_usage_unite_legale + | ||
prenom1_unite_legale + ' ' + | ||
(prenom2_unite_legale || '') + ' ' + | ||
(prenom3_unite_legale || '') + ' ' + | ||
(prenom4_unite_legale || '') + ' ').trim() + '/' | ||
|
||
return(raison_sociale) | ||
function raison_sociale(denomination_unite_legale, nom_unite_legale, nom_usage_unite_legale, prenom1_unite_legale, prenom2_unite_legale, prenom3_unite_legale, prenom4_unite_legale) { | ||
if (!nom_usage_unite_legale) { | ||
var nom_usage_unite_legale = ""; | ||
} | ||
else { | ||
var nom_usage_unite_legale = nom_usage_unite_legale + "/"; | ||
} | ||
var raison_sociale = denomination_unite_legale || | ||
(nom_unite_legale + | ||
"*" + | ||
nom_usage_unite_legale + | ||
prenom1_unite_legale + | ||
" " + | ||
(prenom2_unite_legale || "") + | ||
" " + | ||
(prenom3_unite_legale || "") + | ||
" " + | ||
(prenom4_unite_legale || "") + | ||
" ").trim() + "/"; | ||
return raison_sociale; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
declare function debug(string); // supported by jsc, to print in stdout | ||
|
||
function raison_sociale( | ||
denomination_unite_legale: string, | ||
nom_unite_legale: string, | ||
nom_usage_unite_legale: string, | ||
prenom1_unite_legale: string, | ||
prenom2_unite_legale: string, | ||
prenom3_unite_legale: string, | ||
prenom4_unite_legale: string | ||
): string { | ||
if (!nom_usage_unite_legale) { | ||
var nom_usage_unite_legale = ""; | ||
} else { | ||
var nom_usage_unite_legale = nom_usage_unite_legale + "/"; | ||
} | ||
var raison_sociale = | ||
denomination_unite_legale || | ||
( | ||
nom_unite_legale + | ||
"*" + | ||
nom_usage_unite_legale + | ||
prenom1_unite_legale + | ||
" " + | ||
(prenom2_unite_legale || "") + | ||
" " + | ||
(prenom3_unite_legale || "") + | ||
" " + | ||
(prenom4_unite_legale || "") + | ||
" " | ||
).trim() + "/"; | ||
|
||
return raison_sociale; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
echo "Transpiling TypeScript files, and generating the jsFunctions.go bundle..." | ||
cd dbmongo/lib/engine | ||
go generate -x | ||
cd - | ||
echo "Running tests against the JS files (including the ones transpiled from TS)..." | ||
cd dbmongo/js/test/ && ./test_common.sh | ||
echo "✅ Tests passed." |