Javascript.RU

Автоудаление отладочных свойств и объектов

Как правило, в нашем коде есть отладочные вызовы.
Например:

console.info("created "+object)

Или даже такие:

my.ajax.debugSend(message)

Google Closure Compiler позволяет удалять такие вызовы из production-кода. Здесь вопрос даже не столько в размере кода и в быстродействии, как в удобстве. Как правило, никому не нужны вызовы console.debug на боевом сервере.

Для этого можно добавить флаги, устанавливающие несколько недокументированных внутренних опций.

--strip_types
Типы, которые будут удалены. Например, "--strip_types console" приведет к удалению всех вызовов вида "console.*": console.log, console.debug и т.п.
--strip_name_prefixes
Удаляет все вызовы, которые начинаются с указанной строки. Например, "--strip_name_prefixes debug" приведет к удалению вызовов вида "debug*" для любых объектов.
В частности, удалятся console.debug(..), my.debugMethod(..).
--strip_name_suffixes
Аналогично --strip_name_prefixes, но вызовы должны заканчиваться на строку.
--strip_type_prefixes
То же самое, что --strip_types, но проверяет не точное совпадение названия типа, а его начало.

Например:

/** @constructor */
function Animal(name, speed) {
   my.ajax.debugSend(name)   
   console.info("created animal "+name)   
   this.name = name
   this.speed = speed
}

После запуска с флагами:

--strip_types console --strip_name_prefixes debug

Останется:

function Animal(a, b) {
  this.name = a;
  this.speed = b
}

Чтобы подключить эту опцию, необходимо добавить соответствующие флаги компилятору:

@FlagSpec(help = "Specify stripTypes. You can include multiple.")
private static final Flag<List<String>> FLAG_strip_types
        = Flag.stringCollector();

@FlagSpec(help = "Specify stripTypePrefixes. You can include multiple.")
public static final Flag<List<String>> FLAG_strip_type_prefixes = Flag.stringCollector();

@FlagSpec(help = "Specify stripTypeSuffixes. You can include multiple.")
private static final Flag<List<String>> FLAG_strip_name_suffixes
        = Flag.stringCollector();

@FlagSpec(help = "Specify stripNamePrefixes. You can include multiple.")
private static final Flag<List<String>> FLAG_strip_name_prefixes
        = Flag.stringCollector();

Здесь использован тип флагов stringCollector. Он допускает многократное указание одного и того же флага и собирает значения в список:
--strip_types console --strip_types debug ....

В опции компилятора добавим значения из флагов.

options.stripTypes = new HashSet<String>(FLAG_strip_types.get());
options.stripTypePrefixes = new HashSet<String>(FLAG_strip_type_prefixes.get());
options.stripNameSuffixes = new HashSet<String>(FLAG_strip_name_suffixes.get());
options.stripNamePrefixes = new HashSet<String>(FLAG_strip_name_prefixes.get());

Эти опции запускают встроенный проход компилятора, который удаляет символы, подпадающие под strip-флаги.

Готовый файл MyCompilerRunner.java с этими опциями вы можете увидеть в конце статьи Использование внутренних опций и собственные флаги.


Автор: VAL (не зарегистрирован), дата: 24 февраля, 2011 - 14:47
#permalink

Подскажите чем еще(какие инструменеты), кроме Google Closure Compiler, можно убрать отладочный код?
С Closure Compiler проблема, что он обновился и убраны флаги com.google.common.flags.Flag. Та и не все js разработчики знают java.


Автор: justicehwrknz807 (не зарегистрирован), дата: 10 января, 2022 - 11:49
#permalink

No doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post. Local Lead Generation


Автор: dramaticrecent, дата: 7 июня, 2022 - 05:00
#permalink

Such calls should be removed from production code, according to dordle you. The issue here isn't so much about code size and performance as it is about convenience. On the production server, no one usually needs to use console.debug.


Автор: milian (не зарегистрирован), дата: 16 июля, 2022 - 03:56
#permalink

Свойства отладки и объекты отладки используются для отслеживания проблем в вашем drift hunters приложении. Они также называются отслеживаемыми свойствами и отслеживаемыми объектами, что означает, что их можно отследить до исходного кода. Это полезно для отладки проблем в самом приложении или даже в других приложениях.


Автор: herri (не зарегистрирован), дата: 24 августа, 2022 - 12:03
#permalink

When you launch your app, it automatically gets rid of any gartic phone debug properties and phrazle objects created during the build process.


Автор: antiguans2000, дата: 2 сентября, 2022 - 09:53
#permalink

Google Closure Compiler allows you to remove such calls from production code.

rent atv st george utah


Автор: Гость (не зарегистрирован), дата: 2 сентября, 2022 - 16:15
#permalink

The main goal of the Wordle Today game is to guess the hidden word in 6 tries. In each line, you need to enter any word from 4 to 11 letters to find out what letters are in the target word. Depending on which word you entered, the letters will be highlighted in three colors.


Автор: Гость (не зарегистрирован), дата: 7 сентября, 2022 - 12:13
#permalink

During coloring pages, There are numerous images available that are appropriate for every age, gender, or level of difficulty. If both you and your youngster are adept in coloring, you can select more challenging, advanced images to challenge your creativity!


Автор: Charles Dummer (не зарегистрирован), дата: 17 сентября, 2022 - 06:33
#permalink

The Cinema HD V2 app offers users the ability to watch movies, series, and TV shows for free. The app is available for both iOS and Android devices. The app has a movie section that includes new releases, popular movies, and top rated movies. The TV show section includes popular shows, new episodes, and top rated shows. The app also has a search feature so users can easily find what they're looking for. The Cinema HD V2 app is a must-have for anyone who loves to watch movies and TV shows.


Автор: Lorraine (не зарегистрирован), дата: 23 сентября, 2022 - 05:02
#permalink

Runner gamers can't miss color tunnel . You may enjoy adventures in colorful tunnels for a first-time playing impression. If you play this game often, the tunnel's color will vary with each round.


Автор: timber (не зарегистрирован), дата: 29 сентября, 2022 - 11:41
#permalink

Whereas there are similarities between wordle and a number of other different video games, there are two key variations between the 2. The words have been modified to make them extra fascinating and difficult. The Pandemic pipeline image is used to characterize the output stream of every word. This game has extra difficult guidelines than easy empty cells that have to be crammed in.


Автор: antiguans2000, дата: 18 октября, 2022 - 16:55
#permalink

Google Closure Compiler allows you to remove such calls from production code. Here the question is not even so much in the size of the code and in speed, as in convenience. best carpet cleaning company


Автор: meerabgraves, дата: 26 октября, 2022 - 11:32
#permalink

Looking for a fun and addictive game that will keep you entertained for hours on end? Look no further than Cookie Run: Kingdom Codes! This captivating game has over 200 levels of delicious gameplay, making it the perfect choice for anyone looking for a challenge. What’s more, with new levels added regularly, you’ll never get bored!

In Cookie Run: Kingdom Codes, your goal is to help our little hero Cookies escape the evil ovens of the Wicked Witch. To do this, you’ll need to use your quick reflexes and problem-solving skills to crack codes and unlock exit gates. With physics-based gameplay, every level is different and you’ll never know what to expect!

So what are you waiting for? Give Cookie Run: Kingdom Codes a try today and see if you can become the ultimate code-cracking champion!


Автор: nickyvarian, дата: 27 октября, 2022 - 05:37
#permalink

Romskostenlos is a website where you can download ROMS games for free. Whether you're looking for classic games or the latest releases, we have them all! Our extensive collection includes all the popular titles, as well as some hidden gems that you'll love discovering.

We pride ourselves on providing a safe and easy-to-use website, so you can focus on enjoying your games. With just a few clicks, you'll be able to start playing the classics or try out the newest releases. And because we're always updating our selection, there's always something new to explore.

So why wait? Start your gaming journey today with https://romskostenlos.de/!


Автор: run 3 (не зарегистрирован), дата: 28 декабря, 2022 - 13:21
#permalink

I've read a number of other blogs, but yours has convinced me; I hope you'll continue to provide more wonderful blogs in the future. run 3 online


Автор: timeline (не зарегистрирован), дата: 1 февраля, 2023 - 12:53
#permalink

Thank you for your post. I have read through several similar topics! However, your article gave me a very special impression, unlike other articles. I hope you continue to have valuable articles like this or more to share with everyone! nytimes crossword


Автор: htrhrt (не зарегистрирован), дата: 10 апреля, 2023 - 06:19
#permalink

This is a fantastic article. This is, in my opinion, one of the most well-written pieces ever. Your work is outstanding and inspirational. Thank you once again.
hurdle


Автор: htrhrt (не зарегистрирован), дата: 10 апреля, 2023 - 06:19
#permalink

This is a fantastic article. This is, in my opinion, one of the most well-written pieces ever. Your work is outstanding and inspirational. Thank you once again.
hurdle


Автор: 먹튀검증 (не зарегистрирован), дата: 24 апреля, 2023 - 10:46
#permalink

It in fact was a amusement account it. Look advanced to far added agreeable from you! By the way, how can we communicate? 먹튀검증


Автор: JellyMin (не зарегистрирован), дата: 9 мая, 2023 - 10:47
#permalink

Как правило, drywall tapingникому не нужны вызовы console.


Автор: grouchbutthead, дата: 9 мая, 2023 - 11:45
#permalink

Helpful post and great sharing. I am glad to discover this post Very valuable for me, as it contains part of data drive mad.


Автор: adelebrown68 (не зарегистрирован), дата: 20 июня, 2023 - 09:26
#permalink

Whether you're in the mood for cooking up some mouth-watering burgers and fries, crafting the perfect pizza, or serving up some delectable desserts, Papa's Games has got you covered. With a variety of different game modes to choose from, including time management and strategy elements, these games are sure to keep you entertained for hours on end.


Автор: DisegnidaColorareWK (не зарегистрирован), дата: 15 августа, 2023 - 10:24
#permalink

Siete alla ricerca di attività divertenti e gratuite per i vostri bambini che non coinvolgano gli schermi? Disegnidacolorarewk.com è perfetto per offrire ai vostri bambini uno sbocco divertente per essere creativi e accendere la loro immaginazione in modo educativo e piacevole! Con migliaia di pagine da colorare, dagli animali ai supereroi, ce n'è per tutti i gusti. Inoltre, è completamente gratuito!

Su Disegnidacolorarewk.com, la nostra priorità è assicurarci che i vostri bambini abbiano la migliore esperienza di colorazione. Poiché le nostre pagine sono gratuite, possono esprimere la loro creatività senza preoccuparsi di sprecare denaro per gli extra. Ogni pagina è completa di effetti speciali, colori vivaci e sfumature che rendono il disegno ancora più divertente! La parte migliore? Aggiungiamo sempre nuovi disegni alla collezione, così non ci sono mai le stesse pagine.

Quindi liberatevi di pastelli e penne e iniziate a colorare con Disegnidacolorarewk.com. Le nostre pagine sono sicure di tenere i vostri bambini impegnati e deliziati per ore! Iniziate a scoprire le possibilità divertenti ed educative oggi stesso: è tutto gratuito e accessibile online. Siate creativi e iniziate a colorare ora!


Автор: Adam Wall (не зарегистрирован), дата: 31 октября, 2023 - 13:23
#permalink

I've read a number of other blogs, but yours has convinced me. You may also be interested in an online movie and TV viewing application Dixmax Apk.


Автор: eren23 (не зарегистрирован), дата: 3 ноября, 2023 - 10:47
#permalink

Your code is exceptionally clean and well-structured, fnf making it easy to understand and maintain.


Автор: gbdfst (не зарегистрирован), дата: 29 января, 2024 - 06:08
#permalink

This is a good and quality article that I just read. Thank you very much for sharing the article.
papa's freezeria


Автор: slope game (не зарегистрирован), дата: 16 марта, 2024 - 01:12
#permalink

Experience the exhilarating rush of Slope game as you defy gravity and conquer challenges, immersing yourself in dynamic gameplay, minimalist design, and heart-pounding excitement that caters to gamers of all levels.


Автор: JodyPatrick JoeMullinss (не зарегистрирован), дата: 3 апреля, 2024 - 18:14
#permalink

This is a good and quality article that I just read. Thank you very much for sharing the article APKMia.Com


Автор: antiguans2000, дата: 11 апреля, 2024 - 11:18
#permalink

There are many different types of residential roofing systems, just search for roofing contractor near me, Each with their own benefits and considerations. Materials include metal, tile, wood, and asphalt shingles.


Отправить комментарий

Приветствуются комментарии:
  • Полезные.
  • Дополняющие прочитанное.
  • Вопросы по прочитанному. Именно по прочитанному, чтобы ответ на него помог другим разобраться в предмете статьи. Другие вопросы могут быть удалены.
    Для остальных вопросов и обсуждений есть форум.
P.S. Лучшее "спасибо" - не комментарий, как все здорово, а рекомендация или ссылка на статью.
Содержание этого поля является приватным и не предназначено к показу.
  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Разрешены HTML-таги: <strike> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <u> <i> <b> <pre> <img> <abbr> <blockquote> <h1> <h2> <h3> <h4> <h5> <p> <div> <span> <sub> <sup>
  • Строки и параграфы переносятся автоматически.
  • Текстовые смайлы будут заменены на графические.

Подробнее о форматировании

CAPTCHA
Антиспам
4 + 0 =
Введите результат. Например, для 1+3, введите 4.
 
Текущий раздел
Поиск по сайту
Содержание

Учебник javascript

Основные элементы языка

Сундучок с инструментами

Интерфейсы

Все об AJAX

Оптимизация

Разное

Дерево всех статей

Последние комментарии
Последние темы на форуме
Forum